www.pudn.com > shangdianguanlixitong.rar > login.cpp, change:2005-07-03,size:3133b


// login.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "shop.h" 
#include "login.h" 
#include "shopmanage.h" 
#include "list.h" 
#include "provide.h" 
#include "ShopDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
extern CShopApp theApp; 
///////////////////////////////////////////////////////////////////////////// 
// Clogin dialog 
 
 
Clogin::Clogin(CWnd* pParent /*=NULL*/) 
	: CDialog(Clogin::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(Clogin) 
	m_password = _T("z"); 
	m_username = _T("总经理"); 
	//}}AFX_DATA_INIT 
} 
 
 
void Clogin::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(Clogin) 
	DDX_Text(pDX, IDC_password, m_password); 
	DDX_CBString(pDX, IDC_username, m_username); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(Clogin, CDialog) 
	//{{AFX_MSG_MAP(Clogin) 
	ON_CBN_SELCHANGE(IDC_username, OnSelchangeusername) 
	ON_CBN_EDITCHANGE(IDC_username, OnEditchangeusername) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// Clogin message handlers 
 
void Clogin::OnOK()  
{ 
	// TODO: Add extra validation here 
 
	UpdateData(true); 
	  
 
         
	if(m_username==""||m_password=="") 
	{ 
		AfxMessageBox("用户名或密码不能为空!"); 
	} 
	else 
	{ 
		 
		 
		m_pRecordset.CreateInstance("ADODB.Recordset"); 
		m_pRecordset->Open(_variant_t("SELECT * FROM login WHERE username='"+m_username+"' AND password='"+m_password+"'"),_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
		if(m_pRecordset->adoEOF) 
		{ 
			AfxMessageBox("用户名或密码不正确,请重新输入!"); 
			m_password=""; 
			UpdateData(FALSE); 
		} 
		else 
		{ 
			m_pRecordset->Close(); 
			if(m_username=="总经理" && m_password == "z")  
            {			  
			CDialog::OnOK(); 
            Cshopmanage dlg; 
            dlg.DoModal(); 
			} 
			if(m_username=="人事经理" && m_password == "r")  
            {			  
			CDialog::OnOK(); 
            CShopDlg dlg; 
            dlg.DoModal(); 
			} 
			if(m_username=="业务经理" && m_password == "y")  
            {			  
			CDialog::OnOK(); 
            Cshopmanage dlg; 
            dlg.DoModal(); 
			} 
			if(m_username=="售货员" && m_password == "s")  
            {			  
			CDialog::OnOK(); 
            Clist dlg; 
            dlg.DoModal(); 
			} 
			if(m_username=="进货员" && m_password == "j")  
            {			  
			CDialog::OnOK(); 
            Cprovide dlg; 
            dlg.DoModal(); 
			} 
		} 
	} 
 
	//CDialog::OnOK(); 
	//Cshopmanage dlg; 
//	dlg.DoModal(); 
} 
 
void Clogin::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	CDialog::OnCancel(); 
} 
 
BOOL Clogin::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
//	if(m_username == "总经理") 
//		m_password ==  
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void Clogin::OnSelchangeusername()  
{ 
	     
} 
 
void Clogin::OnEditchangeusername()  
{ 
 
}