?? 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 + -