LAPTOP-T815PCOQ\25526
2024-11-19 b43897d4f69cf85a425f48df9270a289bc0a0125
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: 在此添加控件通知处理程序代码
   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";