📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "BankSystem.h"
#include "Login.h"
#include "BankSystemDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogin dialog
CLogin::CLogin(CWnd* pParent /*=NULL*/)
: CDialog(CLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogin)
m_strUser = _T("");
m_strPassW = _T("");
//}}AFX_DATA_INIT
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Text(pDX, IDC_EDIT1, m_strUser);
DDX_Text(pDX, IDC_EDIT2, m_strPassW);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogin message handlers
void CLogin::OnOK()
{
// TODO: Add extra validation here
BOOL flag=true;
UpdateData(true);
if(m_strUser.IsEmpty()||m_strPassW.IsEmpty())
AfxMessageBox("请填写详细信息");
else
{
CString strSQL,m_strRealPassW;
_variant_t varPower;
strSQL="SELECT * FROM Admin where 账号=";
strSQL+=m_strUser;
m_pRec.CreateInstance(__uuidof(Recordset));
m_pRec->Open(_variant_t(strSQL),m_pCon.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(m_pRec->adoEOF)
{
AfxMessageBox("不存在此账号!");
return;
}
m_strRealPassW=(LPCSTR)_bstr_t(m_pRec->GetCollect("密码"));
if(m_strRealPassW==m_strPassW)
{
CBankSystemApp *App = (CBankSystemApp*)AfxGetApp();
CBankSystemDlg *m_pMain = (CBankSystemDlg*)App->m_pMainWnd;
varPower=m_pRec->GetCollect("权限");
m_pMain->m_iPower = varPower.intVal;
m_pMain->m_strOpr = m_strUser;
AfxMessageBox("登陆成功!");
CDialog::OnOK();
}
else
{
AfxMessageBox("密码错误!");
m_pRec->Close();
return;
}
m_pRec->Close();
}
// CDialog::OnOK();
}
BOOL CLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CBankSystemApp *App = (CBankSystemApp*)AfxGetApp();
CBankSystemDlg *m_pMain = (CBankSystemDlg*)App->m_pMainWnd;
m_pCon=m_pMain->m_pConnection;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -