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

📄 logindlg.cpp

📁 本程序使用Visual C++6.0编写
💻 CPP
字号:
// LoginDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Sjsys.h"
#include "MyCrypt.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_sPass = _T("");
	m_sUser = _T("");
	//}}AFX_DATA_INIT
	pUserRecordset=NULL;
}


void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLoginDlg)
	DDX_Control(pDX, IDOK, m_okbtn);
	DDX_Control(pDX, IDCANCEL, m_exitbtn);
	DDX_Text(pDX, IDC_PASSW_EDIT, m_sPass);
	DDX_Text(pDX, IDC_USER_EDIT, m_sUser);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
	//{{AFX_MSG_MAP(CLoginDlg)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
BOOL CLoginDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//bitmap1.LoadBitmap(IDB_COVERPIC);
	m_okbtn.SetIcon(IDI_ICON9);
    m_okbtn.DrawTransparent(TRUE);	
	m_exitbtn.SetIcon(IDI_ICON8);
    m_exitbtn.DrawTransparent(TRUE);
	m_okbtn.SetFlat(FALSE);
	m_exitbtn.SetFlat(FALSE);
	m_okbtn.SetAlign(CButtonST::ST_ALIGN_HORIZ_RIGHT);
	m_exitbtn.SetAlign(CButtonST::ST_ALIGN_HORIZ_RIGHT);
	// TODO: Add extra initialization her
     pUserRecordset.CreateInstance(__uuidof(Recordset));
    //AfxMessageBox("ffff!");
	try
	{
	   CString SQLStr;
       SQLStr="select * from user1 where Memorizable=1";
       //打开数据集
	   
	   pUserRecordset->Open(_bstr_t(SQLStr),
                             ((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
							 adOpenDynamic,
							 adLockOptimistic,
							 adCmdText);
       if(!pUserRecordset->adoEOF)
	   {
		m_sUser= (LPCSTR)_bstr_t(pUserRecordset->GetCollect("Name"));
		m_sPass= (LPCSTR)_bstr_t(pUserRecordset->GetCollect("Password"));
		m_sPass=CMyCrypt::MyDecrypt(m_sPass,123);
	   }
	   UpdateData(false);
   	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	
    pUserRecordset->Close();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLoginDlg::OnCheck1() 
{
	// TODO: Add your control notification handler code here
	
	UpdateData(true);   //更新数据
	
	if((m_sPass!="") && (m_sUser!=""))
	{
	 //MessageBox("here!");
	 CString SQLStr;
     SQLStr.Format("select * from user1 where Memorizable=1");
	 try
	 {
		 
		pUserRecordset->Open(_bstr_t(SQLStr),
                             ((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
							 adOpenDynamic,
							 adLockOptimistic,
							 adCmdText);
		//
       if(!pUserRecordset->adoEOF)
	   {
		
	    CString sr;
		sr.Format("0");
		pUserRecordset->PutCollect("Memorizable",_variant_t(sr));   //存入所属关系
		pUserRecordset->Update();
		
       //m_sUser= (LPCSTR)_bstr_t(pUserRecordset->PutCollect("Name"));
	   }
	   
       pUserRecordset->Close();
	   
	   m_sPass=CMyCrypt::MyEncrypt(m_sPass,123);
	   
       SQLStr.Format("select * from user1 where Password='%s' and Name='%s'",m_sPass,m_sUser);
	   pUserRecordset->Open(_bstr_t(SQLStr),
                             ((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
							 adOpenDynamic,
							 adLockOptimistic,
							 adCmdText);
	   
	   if(!pUserRecordset->adoEOF)  //如果查找到该用户,则置Memorizable为真
	   {
		  
		  CString sr;
		  sr.Format("1");
		  pUserRecordset->PutCollect("Memorizable",_variant_t(sr));
		  pUserRecordset->Update();
		  //MessageBox(m_sPass);
	   }
	 }
	 catch(_com_error *e)
	 {
		AfxMessageBox(e->ErrorMessage());
	 }
     pUserRecordset->Close();
	}
}

⌨️ 快捷键说明

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