?? logindlg.cpp
字號:
// LoginDLG.cpp : implementation file
//
#include "stdafx.h"
#include "RoomRent.h"
#include "LoginDLG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoginDLG dialog
CLoginDLG::CLoginDLG(CWnd* pParent /*=NULL*/)
: CDialog(CLoginDLG::IDD, pParent)
{
//{{AFX_DATA_INIT(CLoginDLG)
m_sPWD = _T("");
m_sUSER = _T("張德金");
//}}AFX_DATA_INIT
}
void CLoginDLG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDLG)
DDX_Text(pDX, IDC_LOGIN_PWD, m_sPWD);
DDX_Text(pDX, IDC_LOGIN_USER, m_sUSER);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDLG, CDialog)
//{{AFX_MSG_MAP(CLoginDLG)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDLG message handlers
BOOL CLoginDLG::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
((CEdit*)GetDlgItem(IDC_LOGIN_USER))->SetLimitText(15);
((CEdit*)GetDlgItem(IDC_LOGIN_PWD))->SetLimitText(10);
// Set Caption Font
//CFont m_Font;
m_fMyFont.CreatePointFont(180,"華文彩云",NULL);
((CStatic *)GetDlgItem(IDC_LOGIN_CAPTION))->SetFont(&m_fMyFont, true);;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLoginDLG::OnOK()
{
// TODO: Add extra validation here
// Check UserName Vadilaty
UpdateData(true);
m_sUSER.TrimRight(" ");
if ( ""==m_sUSER )
{
AfxMessageBox(_T("請填寫用戶名"), MB_ICONEXCLAMATION);
return;
}
_variant_t Holder, strQuery;
strQuery = "select user_ID, user_PWD from user_Info where user_ID='"+m_sUSER+"'";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
int iCount = theApp.m_pADOSet->GetRecordCount();
if ( 0==iCount )
{
theApp.m_iLoginCount++;
if ( theApp.m_iLoginCount>2 )
{
AfxMessageBox("沒有這個用戶\n三次輸入均不正確,請核對后再來", MB_ICONEXCLAMATION);
CDialog::OnCancel();
return;
}
AfxMessageBox("沒有這個用戶,請重新輸入用戶名", MB_ICONEXCLAMATION);
return;
}
CString sPWD;
theApp.m_pADOSet->MoveFirst();
Holder = theApp.m_pADOSet->GetCollect("user_PWD");
sPWD = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
if ( 0!=sPWD.Compare(m_sPWD) )
{
theApp.m_iLoginCount++;
if ( theApp.m_iLoginCount>2 )
{
AfxMessageBox("輸入密碼不正確\n三次輸入均不正確,請核對后再來", MB_ICONEXCLAMATION);
CDialog::OnCancel();
return;
}
AfxMessageBox("輸入密碼不正確,請重新輸入", MB_ICONEXCLAMATION);
return;
}
// Get Login User
theApp.m_sCurrentUser = m_sUSER;
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -