?? logindlg.cpp
字號:
// LoginDlg.cpp : implementation file
//
#include "stdafx.h"
#include "school.h"
#include "LoginDlg.h"
#include "userset.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_strUser = _T("");
m_strPass = _T("");
//}}AFX_DATA_INIT
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Control(pDX, IDC_EDIT1, m_ctrPass);
DDX_Control(pDX, IDC_COMBO1, m_ctrUser);
DDX_CBString(pDX, IDC_COMBO1, m_strUser);
DDX_Text(pDX, IDC_EDIT1, m_strPass);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
CUserSet recordset;
CString strSQL;
UpdateData(TRUE);
CSchoolApp* ptheApp = (CSchoolApp *) AfxGetApp();
strSQL.Format("select * from user where user='%s' AND passwd='%s'",m_strUser,m_strPass);
if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打開數據庫失敗!","數據庫錯誤",MB_OK);
return ;
}
if(recordset.GetRecordCount()==0)
{
recordset.Close();
MessageBox("密碼錯誤,請重新輸入!");
m_strPass="";
m_ctrPass.SetFocus();
UpdateData(FALSE);
}
else
{
ptheApp->m_bIsAdmin = recordset.m_isadmin;
recordset.Close();
CDialog::OnOK();
}
}
BOOL CLoginDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CUserSet recordset ;
CString strSQL;
UpdateData(TRUE);
//strSQL.Format("select * from password where user='%s' AND passwd='%s'",m_strUser,m_strPass);
strSQL="select * from user";
if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打開數據庫失敗!","數據庫錯誤",MB_OK);
return FALSE;
}
while(!recordset.IsEOF())
{
m_ctrUser.AddString(recordset.m_user);
recordset.MoveNext();
}
recordset.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLoginDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -