📄 login.cpp
字号:
// Login.cpp : implementation file
//
#include "stdafx.h"
#include "SuperMarket.h"
#include "Login.h"
#include "ProTypeManDlg.h"
#include "Manager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogin dialog
CLogin::CLogin(CWnd* pParent /*=NULL*/)
: CDialog(CLogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CLogin)
m_strName = _T("");
m_strPwd = _T("");
//}}AFX_DATA_INIT
}
void CLogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogin)
DDX_Text(pDX, IDC_EDIT1, m_strName);
DDX_Text(pDX, IDC_EDIT2, m_strPwd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogin, CDialog)
//{{AFX_MSG_MAP(CLogin)
ON_BN_CLICKED(IDC_BTNOK, OnBtnok)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogin message handlers
BOOL CLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
strPassword=_T("");
strUsername=_T("");
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
//从SQL数据库中打开Users表
m_pRecordset->Open("SELECT*FROM Users",
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
// MessageBox("BBBBBBBBBBBBBBBBBBBBBB");
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLogin::OnBtnok()
{
// TODO: Add your control notification handler code here
_variant_t var;
CString str1,str2;
UpdateData(true);
try
{
m_pRecordset->MoveFirst();
var=m_pRecordset->GetCollect("UserName");
str1=(LPCSTR)_bstr_t(var);
strUsername=str1;
if(m_strName!=strUsername)
{
AfxMessageBox("你输入的用户名有误!");
}
else
{
var=m_pRecordset->GetCollect("Pwd");
str2=(LPCSTR)_bstr_t(var);
strPassword=str2;
if(m_strPwd!=strPassword)AfxMessageBox("你输入的密码有误!");
else
{
CDialog::OnOK();
CManager mymanager;
CString str="您是本超市管理系统的管理员\n\n";
str+="您的用户名是: ";
str+=str1;
str+="\n\n您的密码是: ";
str+=str2;
mymanager.m_strLabel=str;
mymanager.DoModal();
}
}
UpdateData(false);
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -