www.pudn.com > ExMIS.rar > LoginDlg.cpp, change:2007-05-12,size:2376b


// LoginDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ExMIS.h" 
#include "LoginDlg.h" 
#include "MyRecordSet.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_strDataType = _T(""); 
	m_strPassword = _T(""); 
	m_strUsername = _T(""); 
	//}}AFX_DATA_INIT 
 
	//初始权限为0 
	m_nPower=0; 
} 
 
 
void CLoginDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CLoginDlg) 
	DDX_CBString(pDX, IDC_COMBO_TYPE, m_strDataType); 
	DDX_Text(pDX, IDC_EDIT_PASSWORD, m_strPassword); 
	DDX_Text(pDX, IDC_EDIT_USERNAME, m_strUsername); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog) 
	//{{AFX_MSG_MAP(CLoginDlg) 
	ON_BN_CLICKED(IDC_BTN_LOGIN, OnBtnLogin) 
	ON_WM_CLOSE() 
	ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CLoginDlg message handlers 
 
void CLoginDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	 
	CDialog::OnOK(); 
} 
 
void CLoginDlg::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	CDialog::OnCancel(); 
} 
 
void CLoginDlg::OnBtnLogin()  
{ 
 
	// TODO: Add your control notification handler code here 
	//检查用户名是否输入 
	UpdateData(true); 
	if(m_strUsername.IsEmpty()||m_strPassword.IsEmpty()||m_strDataType.IsEmpty()) 
	{ 
		AfxMessageBox("请将资料填写完整再登录!"); 
		return; 
	} 
 
	m_pRS.ADOOpen(m_strDataType); 
	m_strSQL="SELECT password,power FROM UserTab WHERE [username]='"+m_strUsername+"' "; 
	m_pRS.ADOExcute(m_strSQL); 
 
	if(m_pRS.nFieldRows==1) 
	{ 
		if(m_pRS.GetFieldString(0)==m_strPassword) 
		{ 
			m_pRS.nPower=m_pRS.GetFieldNumber(1); 
 
			CDialog::OnOK(); 
		}else{ 
			AfxMessageBox("错误的密码!"); 
		} 
	}else{ 
		AfxMessageBox("错误的用户名!"); 
	} 
 
} 
 
void CLoginDlg::OnClose()  
{ 
	// TODO: Add your message handler code here and/or call default 
	//屏蔽此事件, 即关闭窗口的事件; 
	//CDialog::OnClose(); 
} 
 
void CLoginDlg::OnBtnCancel()  
{ 
	// TODO: Add your control notification handler code here 
	CDialog::OnCancel(); 
}