From b43897d4f69cf85a425f48df9270a289bc0a0125 Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期二, 19 十一月 2024 18:04:20 +0800
Subject: [PATCH] 1. 添加用户管理的菜单栏 2.更新菜单栏的状态
---
SourceCode/Bond/BondEq/UserManagerDlg.cpp | 38 ++++++++++++++++++++++++++++++++++++--
1 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/SourceCode/Bond/BondEq/UserManagerDlg.cpp b/SourceCode/Bond/BondEq/UserManagerDlg.cpp
index 993edb9..24df33f 100644
--- a/SourceCode/Bond/BondEq/UserManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/UserManagerDlg.cpp
@@ -5,9 +5,12 @@
#include "BondEq.h"
#include "afxdialogex.h"
#include "UserManagerDlg.h"
+#include "InputDialog.h"
#include "UserManager.h"
#include "NewCellTypes/GridCellCombo.h"
#include "NewCellTypes/GridCellNumeric.h"
+
+#include <set>
// CUserManagerDlg 瀵硅瘽妗�
@@ -190,6 +193,22 @@
return;
}
+ CInputDialog inputDialog(_T("娣诲姞鐢ㄦ埛"), _T("璇疯緭鍏ョ敤鎴峰悕锛�"));
+ if (inputDialog.DoModal() != IDOK) {
+ return;
+ }
+
+ CString inputText = inputDialog.GetInputText();
+ if (inputText.IsEmpty()) {
+ AfxMessageBox(_T("鐢ㄦ埛鍚嶄笉鑳戒负绌猴紒"), MB_OK | MB_ICONEXCLAMATION);
+ return;
+ }
+
+ if (IsUsernameDuplicate(inputText)) {
+ AfxMessageBox(_T("鐢ㄦ埛鍚嶉噸澶嶏紒"), MB_OK | MB_ICONEXCLAMATION);
+ return;
+ }
+
int nRowCount = pGridCtrl->GetRowCount();
pGridCtrl->SetRowCount(nRowCount + 1);
int newRowIndex = nRowCount;
@@ -197,8 +216,7 @@
CString strText;
strText.Format(_T("%d"), newRowIndex);
pGridCtrl->SetItemText(newRowIndex, 0, strText);
- strText.Format(_T("User%d"), newRowIndex);
- pGridCtrl->SetItemText(newRowIndex, 1, strText);
+ pGridCtrl->SetItemText(newRowIndex, 1, inputText);
pGridCtrl->SetItemText(newRowIndex, 2, _T("123456"));
pGridCtrl->SetItemText(newRowIndex, 3, _T("鎿嶄綔鍛�"));
pGridCtrl->SetItemText(newRowIndex, 4, _T("30"));
@@ -540,11 +558,27 @@
{
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
std::vector<std::vector<std::string>> vecData;
+ std::set<std::string> usernameSet; // 鐢ㄤ簬瀛樺偍鐢ㄦ埛鍚嶏紝妫�鏌ユ槸鍚﹂噸澶�
+
for (int i = 1; i < m_gridUserManager.GetRowCount(); ++i) {
std::vector<std::string> rowData;
+ CString cellText = m_gridUserManager.GetItemText(i, 1);
+ std::string username = CT2A(cellText.GetString());
+
+ if (usernameSet.find(username) != usernameSet.end()) {
+ CString message;
+ message.Format(_T("鐢ㄦ埛鍚� [%s] 閲嶅锛岃淇敼鍚庝繚瀛橈紒"), cellText);
+ AfxMessageBox(message, MB_ICONEXCLAMATION);
+ return;
+ }
+
+ usernameSet.insert(username);
+
for (int j = 1; j < m_gridUserManager.GetColumnCount() - 1; ++j) {
CString cellText = m_gridUserManager.GetItemText(i, j);
std::string cellString = CT2A(cellText.GetString());
+
+ // 绗�4鍒楁槸鏉冮檺锛岃浆鎹负鏁板瓧瀛楃涓�
if (j == 3) {
if (cellText == _T("绠$悊鍛�"))
cellString = "0";
--
Gitblit v1.9.3