📄 dlglogin.cpp
字号:
// DlgLogin.cpp : implementation file
//
#include "stdafx.h"
#include "afxdb.h"
#include "Train.h"
#include "DlgGuanliyuan.h"
#include "DlgShoupiaoyuan.h"
#include "DlgLogin.h"
#include "UserSet.h"
#include "User.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgLogin dialog
CDlgLogin::CDlgLogin(CWnd* pParent /*=NULL*/)
: CDialog(CDlgLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgLogin)
m_userkey = _T("");
m_username = _T("");
//}}AFX_DATA_INIT
}
void CDlgLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgLogin)
DDX_Control(pDX, IDC_LOGIN_OK, m_loginok);
DDX_Control(pDX, IDC_LOGIN_CANCEL, m_logincancel);
DDX_Text(pDX, IDC_EDT_USER_KEY, m_userkey);
DDX_Text(pDX, IDC_EDT_USER_NAME, m_username);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgLogin, CDialog)
//{{AFX_MSG_MAP(CDlgLogin)
ON_BN_CLICKED(IDC_LOGIN_OK, OnLoginOk)
ON_BN_CLICKED(IDC_LOGIN_CANCEL, OnLoginCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgLogin message handlers
void CDlgLogin::OnLoginOk()
{
// TODO: Add your control notification handler code here
UpdateData();
CUserSet set;
CDatabase db;
try
{
if (set.IsOpen())
set.Close();
set.m_strFilter.Format("username='%s'and userkey='%s'",m_username,m_userkey);
set.Open(CRecordset::snapshot,NULL,CRecordset::none);
if(set.IsEOF())
{
set.Close();
AfxMessageBox("密码错误请重试!");
return;
}
else
{
set.Close();
AfxMessageBox("密码正确登录成功!");
}
}
catch(CDBException* pe)
{
pe->ReportError();
return;
}
CString a=set.m_usertype;
if(a=="1")//管理员
{
CDlgGuanliyuan dlg;
dlg.DoModal();
}
if(a=="0")//售票员
{
CDlgShoupiaoyuan shou;
shou.DoModal();
}
}
void CDlgLogin::OnLoginCancel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -