📄 registdlg.cpp
字号:
// RegistDlg.cpp : implementation file
//
#include "stdafx.h"
#include "database.h"
#include "RegistDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRegistDlg dialog
CRegistDlg::CRegistDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRegistDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRegistDlg)
m_name = _T("");
m_pwd1 = _T("");
m_pwd2 = _T("");
m_right = 0;
//}}AFX_DATA_INIT
m_costom_right00 = TRUE;
m_costom_right01 = TRUE;
m_costom_right02 = TRUE;
m_costom_right03 = TRUE;
m_costom_right04 = TRUE;
m_costom_right05 = TRUE;
m_costom_right06 = TRUE;
m_costom_right07 = TRUE;
m_costom_right08 = TRUE;
}
void CRegistDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRegistDlg)
DDX_Control(pDX, IDC_EDIT_REG_USER, m_edit_name);
DDX_Text(pDX, IDC_EDIT_REG_USER, m_name);
DDX_Text(pDX, IDC_EDIT_REG_PWD, m_pwd1);
DDX_Text(pDX, IDC_EDIT_REG_PWD2, m_pwd2);
DDX_Radio(pDX, IDC_RADIO2, m_right);
DDX_Check(pDX, IDC_CHECK_CREATE, m_costom_right00);
DDX_Check(pDX, IDC_CHECK_SELECT, m_costom_right01);
DDX_Check(pDX, IDC_CHECK_DROP, m_costom_right02);
DDX_Check(pDX, IDC_CHECK_DELETE, m_costom_right03);
DDX_Check(pDX, IDC_CHECK_UPDATE, m_costom_right04);
DDX_Check(pDX, IDC_CHECK_ALTER, m_costom_right05);
DDX_Check(pDX, IDC_CHECK_REVOKE, m_costom_right06);
DDX_Check(pDX, IDC_CHECK_GRANT, m_costom_right07);
DDX_Check(pDX, IDC_CHECK_INSERT, m_costom_right08);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRegistDlg, CDialog)
//{{AFX_MSG_MAP(CRegistDlg)
ON_BN_CLICKED(IDC_CHECK_CREATE, OnCheckCreate)
ON_BN_CLICKED(IDC_CHECK_SELECT, OnCheckSelect)
ON_BN_CLICKED(IDC_CHECK_DROP, OnCheckDrop)
ON_BN_CLICKED(IDC_CHECK_ALTER, OnCheckAlter)
ON_BN_CLICKED(IDC_CHECK_DELETE, OnCheckDelete)
ON_BN_CLICKED(IDC_CHECK_GRANT, OnCheckGrant)
ON_BN_CLICKED(IDC_CHECK_INSERT, OnCheckInsert)
ON_BN_CLICKED(IDC_CHECK_REVOKE, OnCheckRevoke)
ON_BN_CLICKED(IDC_CHECK_UPDATE, OnCheckUpdate)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRegistDlg message handlers
void CRegistDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
if(m_pwd1 != m_pwd2)
{
m_pwd1.Empty();
m_pwd2.Empty();
UpdateData(false);
AfxMessageBox("两次密码输入不相同!");
return ;
}
if(m_costom_right00)
m_right |= CREATE_RIGHT;
if(m_costom_right01)
m_right |= SELECT_RIGHT;
if(m_costom_right02)
m_right |= DROP_RIGHT;
if(m_costom_right03)
m_right |= DELETE_RIGHT;
if(m_costom_right04)
m_right |= UPDATE_RIGHT;
if(m_costom_right05)
m_right |= ALTER_RIGHT;
if(m_costom_right06)
m_right |= REVOKE_RIGHT;
if(m_costom_right07)
m_right |= GRANT_RIGHT;
if(m_costom_right08)
m_right |= INSERT_RIGHT;
CUser user;
user.addUser(m_name, m_pwd1, m_right);
CDialog::OnOK();
}
BOOL CRegistDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_costom_right01 = true;
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRegistDlg::OnCheckCreate()
{
// TODO: Add your control notification handler code here
m_costom_right00 = !m_costom_right00;
}
void CRegistDlg::OnCheckSelect()
{
// TODO: Add your control notification handler code here
m_costom_right01 = !m_costom_right01;
}
void CRegistDlg::OnCheckDrop()
{
// TODO: Add your control notification handler code here
m_costom_right02 = !m_costom_right02;
}
void CRegistDlg::OnCheckAlter()
{
// TODO: Add your control notification handler code here
m_costom_right05 = !m_costom_right05;
}
void CRegistDlg::OnCheckDelete()
{
// TODO: Add your control notification handler code here
m_costom_right03 = !m_costom_right03;
}
void CRegistDlg::OnCheckGrant()
{
// TODO: Add your control notification handler code here
m_costom_right07 = !m_costom_right07;
}
void CRegistDlg::OnCheckInsert()
{
// TODO: Add your control notification handler code here
m_costom_right08 = !m_costom_right08;
}
void CRegistDlg::OnCheckRevoke()
{
// TODO: Add your control notification handler code here
m_costom_right06 = !m_costom_right06;
}
void CRegistDlg::OnCheckUpdate()
{
// TODO: Add your control notification handler code here
m_costom_right04 = !m_costom_right04;
}
void CRegistDlg::OnRadio3() //普通用户
{
// TODO: Add your control notification handler code here
UpdateData();
m_costom_right00 = false;
m_costom_right01 = true;
m_costom_right02 = false;
m_costom_right03 = false;
m_costom_right04 = false;
m_costom_right05 = false;
m_costom_right06 = false;
m_costom_right07 = false;
m_costom_right08 = false;
UpdateData(false);
}
void CRegistDlg::OnRadio2() //系统用户
{
// TODO: Add your control notification handler code here
UpdateData();
m_costom_right00 = true;
m_costom_right01 = true;
m_costom_right02 = true;
m_costom_right03 = true;
m_costom_right04 = true;
m_costom_right05 = true;
m_costom_right06 = true;
m_costom_right07 = true;
m_costom_right08 = true;
UpdateData(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -