📄 logindlg.cpp
字号:
// LoginDlg.cpp : implementation file
//
#include "stdafx.h"
#include "StuManage.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog
extern CStuManageApp theApp;
CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLoginDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLoginDlg)
m_strLoginPwd = _T("");
m_strLoginName = _T("");
m_nLoginLevel = 0;
//}}AFX_DATA_INIT
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Text(pDX, IDC_EDIT_LOGIN_PWD, m_strLoginPwd);
DDX_Text(pDX, IDC_EDIT_LOGIN_NAME, m_strLoginName);
DDX_Radio(pDX, IDC_RADIO_STUDENT, m_nLoginLevel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
ON_BN_CLICKED(ID_LOGIN_BTN, OnLoginBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
void CLoginDlg::OnLoginBtn()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString strname,strpwd;
int nlevel;
m_pRecordset_user.CreateInstance("ADODB.Recordset");
m_pRecordset_user->Open("select * from SysUser",_variant_t((IDispatch *)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
if(m_pRecordset_user->GetRecordCount() != 0)
{
while(!m_pRecordset_user->adoEOF)
{
strname = m_pRecordset_user->GetCollect("NAME").bstrVal;
strpwd = m_pRecordset_user->GetCollect("PASSWORD").bstrVal;
nlevel = m_pRecordset_user->GetCollect("LEVEl").lVal;
if(strname.CompareNoCase(m_strLoginName) == 0 && strpwd.CompareNoCase(m_strLoginPwd) == 0 && nlevel == m_nLoginLevel)
{
//记录权限
theApp.m_Level = m_nLoginLevel;
theApp.Loginstatus = true;
MessageBox("登录系统","系统登录");
CDialog::OnOK();
return;
}
m_pRecordset_user->MoveNext();
}
MessageBox("用户名和密码错误","系统登录");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -