chengxr hai 1 ano
pai
achega
dbc348c081

+ 3 - 3
QFD/common/QFDAlert.cpp

@@ -27,15 +27,15 @@ void QFDAlert::showAlertWithCode(int code, QWidget *w)
         msg = "不能与旧密码相同,请修改后重试";
     } else if (code == QF_CODE_DATA_ERROR) {
         msg = "数据异常";
-    }
-
-    if (code == QF_CODE_EMPTY_USERNAME) {
+    } else if (code == QF_CODE_EMPTY_USERNAME) {
         msg = "专家名不能为空";
     } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
         msg = "用户名已存在或者数据库存储异常!";
     } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
         msg  = "已添加";
         type = Success;
+    } else if (code == QF_CODE_DELETE_USER_FAILED) {
+        msg = "删除用户失败";
     }
 
     if (!msg.isEmpty()) {

+ 5 - 3
QFD/dbService/ClassSet.h

@@ -5,9 +5,10 @@
 
 #include <QDate>
 
-const int QF_CODE_SUCCEEDED          = 1000;
-const int QF_CODE_ALREADY_LOGIN      = 1001;
-const int QF_CODE_ADD_USER_SUCCEEDED = 1002;
+const int QF_CODE_SUCCEEDED             = 1000;
+const int QF_CODE_ALREADY_LOGIN         = 1001;
+const int QF_CODE_ADD_USER_SUCCEEDED    = 1002;
+const int QF_CODE_DELETE_USER_SUCCEEDED = 1003;
 
 const int QF_CODE_FAILED             = 2000;
 const int QF_CODE_EMPTY_ACCOUNT      = 2001;
@@ -20,6 +21,7 @@ const int QF_CODE_PASSWORD_UNCHANGED = 2007;
 const int QF_CODE_DATA_ERROR         = 2008;
 const int QF_CODE_EMPTY_USERNAME     = 2009;
 const int QF_CODE_ACCOUNT_OCCUPIED   = 2010;
+const int QF_CODE_DELETE_USER_FAILED = 2011;
 
 /**
  * @projectName   QFD

+ 17 - 4
QFD/view/ExpertManageView.cpp

@@ -157,8 +157,6 @@ void ExpertManageView::slotDetailClicked()
     }
     QFUser *user = m_userList[row];
 
-    qDebug() << __FUNCTION__ << __LINE__ << user->id << user->userNo << user->userName << user->role << user->remark;
-
     showExpertInfo(user);
 }
 
@@ -166,6 +164,7 @@ void ExpertManageView::slotDeleteClicked()
 {
     hideExpertInfoWidget();
     MessageBox *m = new MessageBox("删除专家信息", "删除后不可恢复,确认删除?", topLevelWidget());
+    connect(m, &MessageBox::yesSignal, this, &ExpertManageView::slotConfirmDeleteExpert);
     m->exec();
 }
 
@@ -190,10 +189,24 @@ void ExpertManageView::slotConfirmAddExpert()
     int code = ExpertManager::addUser(*user);
     QFDAlert::showAlertWithCode(code, this);
 
-    qDebug() << __FUNCTION__ << __LINE__ << code << user->id << user->userNo << user->userName;
-
     if (code == QF_CODE_ADD_USER_SUCCEEDED) {
         hideExpertInfoWidget();
         refreshList();
     }
 }
+
+void ExpertManageView::slotConfirmDeleteExpert()
+{
+    int row = m_expertListWidget->selectedRow();
+    if (row < 0 || row >= m_userList.count()) {
+        return;
+    }
+    QFUser *user = m_userList[row];
+
+    int code = ExpertManager::deleteUser(user->id);
+    QFDAlert::showAlertWithCode(code, this);
+
+    if (code == QF_CODE_DELETE_USER_SUCCEEDED) {
+        refreshList();
+    }
+}

+ 1 - 0
QFD/view/ExpertManageView.h

@@ -55,6 +55,7 @@ private slots:
     void slotListItemDoubleClicked(int row);
 
     void slotConfirmAddExpert();
+    void slotConfirmDeleteExpert();
 
 private:
     bool m_initilized = false;

+ 2 - 0
QFD/widgets/ExpertListWidget.cpp

@@ -40,6 +40,8 @@ void ExpertListWidget::showUsers(QList<QFUser *> list)
         QLabel *name = new QLabel(list[i]->userName);
         hBox->addWidget(name);
         hBox->addStretch();
+        QLabel *time = new QLabel(list[i]->writeTime);
+        hBox->addWidget(time);
     }
 }
 

BIN=BIN
bin/data/qfd.db