📄 dlogin.cpp
字号:
// DLogin.cpp : implementation file
//
#include "stdafx.h"
#include "商品销售管理系统.h"
#include "DLogin.h"
#include "商品销售管理系统Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "ExternDllHeader.h"
/////////////////////////////////////////////////////////////////////////////
CDLogin::CDLogin(CWnd* pParent /*=NULL*/)
: CDialog(CDLogin::IDD, pParent)
{
time=1;
//{{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_List, m_List);
DDX_Control(pDX, IDC_EDTPassWard, m_EdtPassWard);
DDX_Control(pDX, IDC_EDTName, m_EdtName);
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_NOTIFY(NM_DBLCLK, IDC_List, OnDblclkList)
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();
//将图标添加到ImageList中
CString cName,cImage;
m_ImageList.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
for(int i=IDI_ICON8;i<=IDI_ICON13;i++)
{
m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(i)));
}
m_List.ImageList(&m_ImageList);
m_List.SetTextField("名称");
m_List.SetImageField("头像");
m_List.SetDataBase("操作员信息表");
if(m_List.GetItemCount()<1)
{
CString sSQL;
sSQL.Format("INSERT INTO 操作员信息表 VALUES(1,9999,'超级管理员','',1,'CJGLY')");
rst.Open(sSQL,adCmdText);
sSQL.Format("INSERT INTO 权限表 VALUES(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)");
rst.Open(sSQL,adCmdText);
OP="超级管理员";
CMyDlg dlg;
this->OnCancel();
dlg.DoModal();
sSQL.Format("DELETE FROM 操作员信息表 WHERE 编号=1");
rst.Open(sSQL,adCmdText);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDLogin::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->hwnd==m_List.GetSafeHwnd()&&pMsg->message==WM_KEYDOWN&&pMsg->wParam==13)
{
CString sName;
sName=m_List.GetItemText(m_List.GetSelectionMark(),0);
if(sName.IsEmpty())
return false;
m_EdtName.SetWindowText(sName);
m_EdtPassWard.SetFocus();
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDLogin::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
CString sName;
sName=m_List.GetItemText(m_List.GetSelectionMark(),0);
if(sName.IsEmpty())
return;
m_EdtName.SetWindowText(sName);
m_EdtPassWard.SetFocus();
*pResult = 0;
}
void CDLogin::OnBUTLogin()
{
CString sName,sPassWard,sSavePassWard;
if(time>=3)
{
MessageBox("对不起,您不要以登录系统!请与管理员联系!","系统提示",MB_OK|MB_ICONSTOP);
this->OnCancel();
return;
}
m_EdtName.GetWindowText(sName);
m_EdtPassWard.GetWindowText(sPassWard);
if(sName.IsEmpty())
{
MessageBox("请选择一个用户!","系统提示",MB_OK|MB_ICONSTOP);
return;
}
sSavePassWard=ado.FieldToOtherField("操作员信息表","名称",sName,"密码",1);
if(sSavePassWard==sPassWard)
{
OP=sName;
CMyDlg dlg;
this->OnCancel();
dlg.DoModal();
}
else
{
MessageBox("您输入的密码不正确,请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
time++;
m_EdtPassWard.SetWindowText("");
m_EdtPassWard.SetFocus();
}
}
void CDLogin::OnBUTExit()
{
this->OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -