📄 dlogin.cpp
字号:
// Dlogin.cpp : implementation file
//
#include "stdafx.h"
#include "商品库存管理系统.h"
#include "Dlogin.h"
#include "MainDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
extern CMyApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDlogin dialog
CDlogin::CDlogin(CWnd* pParent /*=NULL*/)
: CDialog(CDlogin::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlogin)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlogin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlogin)
DDX_Control(pDX, IDC_EDTPassward, m_EdtPassWard);
DDX_Control(pDX, IDC_COMName, m_ComName);
DDX_Control(pDX, IDC_BUTlogin, m_ButLogin);
DDX_Control(pDX, IDC_BUTExit, m_ButExit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlogin, CDialog)
//{{AFX_MSG_MAP(CDlogin)
ON_BN_CLICKED(IDC_BUTlogin, OnBUTlogin)
ON_BN_CLICKED(IDC_BUTExit, OnBUTExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlogin message handlers
void CDlogin::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
BOOL CDlogin::OnInitDialog()
{
CDialog::OnInitDialog();
Degree=1;
rst.CreateInstance(__uuidof(Recordset));
rst=cnn->Execute("用户信息表",NULL,adCmdTable);
if(theApp.GetRecordCount(rst)>0)
{
this->m_ComName.SetRecordset(rst,"用户名");
}
else
{
MessageBox("非常感谢您使用商品库存管理系统!请您在登录后添加一个新用户!","系统提示",MB_OK|MB_ICONINFORMATION);
this->OnCancel();
CMainDlg dlg;
dlg.UserName="系统管理员";
dlg.DoModal();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlogin::OnBUTlogin()
{
CString cName,sSQL,cPassWard,cPsd;
m_ComName.GetWindowText(cName);
sSQL.Format("Select * from 用户信息表 where 用户名='%s'",cName);
rst=cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
if(Degree>=3)
{
MessageBox("对不起!您无权登录!","系统提示",MB_OK|MB_ICONSTOP);
this->OnCancel();
return;
}
if(theApp.GetRecordCount(rst)>0)
{
rst->MoveFirst();
cPassWard=(char*)(_bstr_t)rst->GetCollect("密码");
m_EdtPassWard.GetWindowText(cPsd);
rst->Close();
if(cPsd==cPassWard)
{
CMainDlg dlg;
this->OnCancel();
dlg.UserName=cName;
dlg.DoModal();
}
else
{
MessageBox("您输入的密码不正确!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
Degree=Degree+1;
m_EdtPassWard.SetWindowText("");
m_EdtPassWard.SetFocus();
}
}
else
{
MessageBox("您选择了无效的用户名!","系统提示",MB_OK|MB_ICONSTOP);
Degree=Degree+1;
m_ComName.SetFocus();
}
}
void CDlogin::OnBUTExit()
{
this->OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -