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.

109 lines
2.5 KiB
C++

// DlgAuthorityMgr->cpp : 实现文件
//
#include "stdafx.h"
#include "LaiPuLaser.h"
#include "DlgAuthorityLogin.h"
#include "afxdialogex.h"
#include "MsgBox.h"
#include "AuthorityMgr.h"
#include "DlgAuthorityAccount.h"
IMPLEMENT_DYNAMIC(CDlgAuthorityLogin, CDialogEx)
CDlgAuthorityLogin::CDlgAuthorityLogin(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgAuthorityLogin::IDD, pParent)
, m_CurUser(_T(""))
{
m_bShowLockMsg = true;//锁定的时候是否提示对话框
}
CDlgAuthorityLogin::~CDlgAuthorityLogin()
{
}
void CDlgAuthorityLogin::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_AUTHORITY, m_CurAuthority);
DDX_Text(pDX, IDC_NAME, m_Name);
DDX_Text(pDX, IDC_PASSWORD, m_PassWord);
DDX_Text(pDX, IDC_CUR_USER, m_CurUser);
}
BEGIN_MESSAGE_MAP(CDlgAuthorityLogin, CDialogEx)
ON_BN_CLICKED(IDC_LOGIN, &CDlgAuthorityLogin::OnBnClickedLogin)
ON_BN_CLICKED(IDC_LOCK_USER, &CDlgAuthorityLogin::OnBnClickedLock)
ON_BN_CLICKED(NEW_USER_MGR_BTN, &CDlgAuthorityLogin::OnBnClickedUpdateConfigBtn)
END_MESSAGE_MAP()
//截获一部分键盘输入
BOOL CDlgAuthorityLogin::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
char c = pMsg->wParam;
if(c==VK_RETURN || c==VK_ESCAPE)
{
return TRUE;
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
BOOL CDlgAuthorityLogin::OnInitDialog()
{
CDialogEx::OnInitDialog();
//刷新当前权限
RefreashAuthority();
CRect cr;
GetClientRect(&cr);//获取对话框客户区域大小
ClientToScreen(&cr);//转换为荧幕坐标
MoveWindow(370 ,170,cr.Width(),cr.Height()+20);
UpdateData(FALSE);
return TRUE;
}
//登录
void CDlgAuthorityLogin::OnBnClickedLogin()
{
if(!UpdateData(TRUE))
return;
if(gAuthorityMgr->Login(m_Name,m_PassWord))
{
//刷新当前权限
RefreashAuthority();
OnOK();
}
}
//刷新当前权限
void CDlgAuthorityLogin::RefreashAuthority()
{
m_CurAuthority = gAuthorityMgr->GetAccountName(gAuthorityMgr->GetCurAuthority());
//用户名
{
COperateCommStringPar OperatePar;
OperatePar.m_StringValType = _CommStringValType_CurUserName;
OperatePar.m_bReadOrWrite = _ReadOrWrite_Read;
gDeviceStateMgr->OperateCommString(OperatePar);
m_CurUser = OperatePar.m_StringVal;
}
UpdateData(FALSE);
}
void CDlgAuthorityLogin::OnBnClickedLock()
{
gAuthorityMgr->Lock();
CDialogEx::OnCancel();
}
void CDlgAuthorityLogin::OnBnClickedUpdateConfigBtn()
{
CDlgAuthorityAccount dlg;
dlg.DoModal();
}