chengxr 1 жил өмнө
parent
commit
fb064a8f28

+ 5 - 1
QFD/common/ProjectManager.cpp

@@ -116,7 +116,11 @@ int ProjectManager::insertProject(ProjectInfo &proj)
 {
     int code = verifyProjectInfo(proj);
     if (code == QF_CODE_SUCCEEDED) {
-        ProjectService().AddProjectInfo(proj);
+        int index = ProjectService().AddProjectInfo(proj);
+        qDebug() << __FUNCTION__ << __LINE__ << "id:" << index;
+        if (index == -1) {
+            code = QF_CODE_PROJ_CREATE_FALIED;
+        }
     }
     return code;
 }

+ 8 - 0
QFD/common/QFDAlert.cpp

@@ -36,6 +36,14 @@ void QFDAlert::showAlertWithCode(int code, QWidget *w)
         type = Success;
     } else if (code == QF_CODE_DELETE_USER_FAILED) {
         msg = "删除用户失败";
+    } else if (code == QF_CODE_NEED_PROJ_SUMMARY) {
+        msg = "请补全项目概要信息";
+    } else if (code == QF_CODE_NEED_PROJ_NAME) {
+        msg = "请填写项目名称";
+    } else if (code == QF_CODE_NEED_PROJ_TYPE) {
+        msg = "请选额评估类型";
+    } else if (code == QF_CODE_PROJ_CREATE_FALIED) {
+        msg = "创建失败,数据库异常";
     }
 
     if (!msg.isEmpty()) {

+ 4 - 3
QFD/dbService/ClassSet.h

@@ -23,9 +23,10 @@ const int QF_CODE_EMPTY_USERNAME     = 2009;
 const int QF_CODE_ACCOUNT_OCCUPIED   = 2010;
 const int QF_CODE_DELETE_USER_FAILED = 2011;
 
-const int QF_CODE_NEED_PROJ_SUMMARY = 2020;
-const int QF_CODE_NEED_PROJ_NAME    = 2021;
-const int QF_CODE_NEED_PROJ_TYPE    = 2022;
+const int QF_CODE_NEED_PROJ_SUMMARY  = 2020;
+const int QF_CODE_NEED_PROJ_NAME     = 2021;
+const int QF_CODE_NEED_PROJ_TYPE     = 2022;
+const int QF_CODE_PROJ_CREATE_FALIED = 2023;
 
 /**
  * @projectName   QFD

+ 8 - 0
QFD/view/HomeView.cpp

@@ -6,6 +6,7 @@
 #include "QFDAlert.h"
 #include "QFDIcon.h"
 #include "ProjectListWidget.h"
+#include "QFDAlert.h"
 
 #include <Widgets/Button.h>
 #include <Widgets/LineEdit.h>
@@ -127,4 +128,11 @@ void HomeView::slotSearchTextChanged()
 void HomeView::slotConfirmCreate()
 {
     ProjectInfo info = m_createProjWidget->projectInfo();
+    int code         = ProjectManager::insertProject(info);
+    QFDAlert::showAlertWithCode(code, m_createProjWidget);
+    if (code == QF_CODE_SUCCEEDED) {
+        m_createProjWidget->close();
+        m_search->clear();
+        loadProjects();
+    }
 }

+ 0 - 1
QFD/widgets/CreateProjWidget.cpp

@@ -191,7 +191,6 @@ void CreateProjWidget::slotCreateClicked()
              << p.estimatePerson << p.positionalTitles << p.remark << p.projectName << p.estimateType;
 
     emit signalCreate();
-    close();
 }
 
 void CreateProjWidget::slotCancelClicked()