?? dlglogon.cpp
字號:
// dlgLogOn.cpp : implementation file
//
#include "stdafx.h"
#include "CheckIn.h"
#include "dlgLogOn.h"
#include "userrecordset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CdlgLogOn dialog
CdlgLogOn::CdlgLogOn(CWnd* pParent /*=NULL*/)
: CDialog(CdlgLogOn::IDD, pParent)
{
//{{AFX_DATA_INIT(CdlgLogOn)
m_strUserName = _T("");
m_strPassword = _T("");
//}}AFX_DATA_INIT
}
void CdlgLogOn::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CdlgLogOn)
DDX_Text(pDX, IDC_EDIT_USERNAME, m_strUserName);
DDX_Text(pDX, IDC_EDIT_USERPASSWORD, m_strPassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CdlgLogOn, CDialog)
//{{AFX_MSG_MAP(CdlgLogOn)
ON_BN_CLICKED(IDC_OK, OnConfirm)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CdlgLogOn message handlers
void CdlgLogOn::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CdlgLogOn::OnConfirm()
{
// TODO: Add your control notification handler code here
CEdit *pEditUser = (CEdit*)this->GetDlgItem(IDC_EDIT_USERNAME);
CEdit *pEditPass = (CEdit*)this->GetDlgItem(IDC_EDIT_USERPASSWORD);
CUserRecordset rsUser;
this->UpdateData(true);
try
{
if(!rsUser.IsOpen())
rsUser.Open(CRecordset::dynaset,_T("select * from tbUser where UserName ='"+m_strUserName+"'"));
if (rsUser.MyGetRecordCount() <= 0)
{
::MessageBox(NULL,"沒有此用戶,請使用其它用戶登錄!","登錄錯誤",MB_ICONINFORMATION);
pEditUser->SetWindowText("");
/*也可以使用DDX機制*/
//this->m_strUserName = "";
//this->UpdateData(false);
pEditUser->SetFocus();
return;
}
else//輸入的用戶存在表中,那么檢查密碼是否正確
{
rsUser.Close();
rsUser.Open(CRecordset::dynaset,_T("select * from tbUser where Password ='"+m_strPassword+"' and UserName ='"+m_strUserName+"'"));
if (rsUser.MyGetRecordCount() <= 0)
{
::MessageBox(NULL,"密碼輸入不正確,請重新登錄!","登錄錯誤",MB_ICONINFORMATION);
pEditPass->SetWindowText("");
pEditPass->SetFocus();
return;
}
else
{
//表明用戶和密碼輸入完全正確
//這時利用EndDialog函數的參數來返回用戶的權限
if (rsUser.m_Authority == "超級用戶")
{
this->EndDialog(IDSUPER);
}
if (rsUser.m_Authority == "簽到用戶")
{
this->EndDialog(IDCHECK);
}
}
}
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return;
}
}
BOOL CdlgLogOn::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
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 + -