⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clientlogin.cpp

📁 h fghgklfgoh gfdklgh fd bfgh tfd h dfh gdflgh, fjghklg ldffdlgm dsfohglfj
💻 CPP
字号:
// ClientLogin.cpp : implementation file
//

#include "stdafx.h"
#include "SuperMarket.h"
#include "ClientLogin.h"
#include "MemberManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClientLogin dialog


CClientLogin::CClientLogin(CWnd* pParent /*=NULL*/)
	: CDialog(CClientLogin::IDD, pParent)
{
	//{{AFX_DATA_INIT(CClientLogin)
	m_strPwd = _T("");
	m_strID = _T("");
	//}}AFX_DATA_INIT
}


void CClientLogin::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClientLogin)
	DDX_Text(pDX, IDC_EDIT2, m_strPwd);
	DDX_Text(pDX, IDC_EDIT1, m_strID);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClientLogin, CDialog)
	//{{AFX_MSG_MAP(CClientLogin)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClientLogin message handlers

void CClientLogin::OnOK() 
{
	// TODO: Add extra validation here

	m_pRecordset.CreateInstance(__uuidof(Recordset));


	CString source,str;
	_variant_t var;

	_variant_t RecordsAffected;

	UpdateData(true);

	if(m_strID!="")
	{	
		source="SELECT *FROM Client WHERE Cid= ";
	    source+=m_strID;
		//MessageBox(source);
		
	}
	try
	{
	 
	
		m_pRecordset=theApp.m_pConnection->Execute(source.AllocSysString(),
		                                        	&RecordsAffected,
		                                           	adCmdText);
         
	 

	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	if(m_pRecordset->adoEOF)
	{
		AfxMessageBox("没有该ID号的客户!");
	
		return;	
	}
	if(m_strPwd=="")
	{
		MessageBox("你输入的密码不能为空!");
		return;
	}
	m_pRecordset->MoveFirst();
	while(!m_pRecordset->adoEOF&&m_strPwd!="")
	{
	
		var=m_pRecordset->GetCollect("Cpwd");
        
		str=(LPCSTR)_bstr_t(var);
		int n=m_strPwd.GetLength();
	    	
	    if(m_strPwd==str.Left(n))
		{   
			CDialog::OnOK();
		    CMemberManager mymember;
            mymember.strID=m_strID;
			mymember.strPwd=m_strPwd;
			//mymember.m_strShow="用户ID:"+m_strID+"用户密码:"+m_strPwd;
            mymember.DoModal();
           	break;
		}
    	m_pRecordset->MoveNext();
	}
  if(m_pRecordset->adoEOF)
    	MessageBox("你输入的密码不对!");
   
  // CDialog::OnOK();
 //  CMemberManager mymember;
 //  mymember.DoModal();

}

void CClientLogin::OpenClient()
{
      try
     {
            //从SQL数据库中打开Users表
	
	//	 AfxMessageBox((theApp.m_pConnection.GetInterfacePtr()));
		    m_pRecordset->Open("SELECT*FROM Client",
							   theApp.m_pConnection.GetInterfacePtr(),
							   adOpenDynamic,
							   adLockOptimistic,
							   adCmdText);
			
	   }
	   catch(_com_error*e)
	   {
		   AfxMessageBox(e->ErrorMessage());
	   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -