?? logindlg.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 + -