You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.5 KiB
C++

// DlgCreatAccount.cpp : 实现文件
//
#include "stdafx.h"
#include "LaiPuLaser.h"
#include "DlgAuthorityCreatAccount.h"
#include "afxdialogex.h"
#include "AuthorityMgr.h"
#include "MsgBox.h"
// CDlgAuthorityCreatAccount 对话框
IMPLEMENT_DYNAMIC(CDlgAuthorityCreatAccount, CDialogEx)
CDlgAuthorityCreatAccount::CDlgAuthorityCreatAccount(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgAuthorityCreatAccount::IDD, pParent)
{
}
CDlgAuthorityCreatAccount::~CDlgAuthorityCreatAccount()
{
}
void CDlgAuthorityCreatAccount::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_NAME, m_Name);
DDX_Text(pDX, IDC_PASSWORD, m_PassWord1);
DDX_Text(pDX, IDC_PASSWORD2, m_PassWord2);
DDX_Control(pDX, IDC_AUTHORITY_COMB, m_AuthorityComb);
}
BEGIN_MESSAGE_MAP(CDlgAuthorityCreatAccount, CDialogEx)
ON_BN_CLICKED(IDOK, &CDlgAuthorityCreatAccount::OnBnClickedOk)
END_MESSAGE_MAP()
// CDlgAuthorityCreatAccount 消息处理程序
BOOL CDlgAuthorityCreatAccount::OnInitDialog()
{
CDialogEx::OnInitDialog();
IniAuthorityComb();
UpdateData(FALSE);
return TRUE;
}
//初始化AuthorityComb
void CDlgAuthorityCreatAccount::IniAuthorityComb()
{
eAuthorityType CurAuthority = gAuthorityMgr->GetCurAuthority();
int idx = 0;
m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_Authority_Operator));
m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_Authority_OperatorAdmin));
m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_Authority_Engineer));
m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_Authority_Technics));
if(CurAuthority== _Authority_Factory)
{
m_AuthorityComb.InsertString(idx++,gAuthorityMgr->GetAccountName(_Authority_Factory));
}
m_AuthorityComb.SetCurSel(0);
}
void CDlgAuthorityCreatAccount::OnBnClickedOk()
{
eAuthorityType CurAuthority = gAuthorityMgr->GetCurAuthority();
if(!UpdateData(TRUE))
return;
if(m_Name=="")
{
CMsgBox MsgBox;
MsgBox.Show("用户名不能为空!");
return;
}
if(m_PassWord1=="")
{
CMsgBox MsgBox;
MsgBox.Show("密码不能为空!");
return;
}
if(m_PassWord1 != m_PassWord2)
{
CMsgBox MsgBox;
MsgBox.Show("确认密码不一致!");
return;
}
CAccount Account;
Account.m_Name = m_Name;
Account.m_PassWord = m_PassWord1;
Account.m_Authority = (eAuthorityType)(m_AuthorityComb.GetCurSel()+1);//权限
gAuthorityMgr->AddAccount(Account);
CDialogEx::OnOK();
}