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

📄 enterdlg.cpp

📁 小型超市管理系统是方便超市管理员管理超市的一个小软件
💻 CPP
字号:
// EnterDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SuperMarket.h"
#include "EnterDlg.h"
#include "afxdb.h"
#include "MainFrm.h"
#include "SecretChangeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEnterDlg dialog


CEnterDlg::CEnterDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CEnterDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CEnterDlg)
	m_admin = _T("");
	m_secret = _T("");
	manager = false;
	employee = false;
	//}}AFX_DATA_INIT
}


void CEnterDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEnterDlg)
	DDX_Text(pDX, IDC_ADMIN, m_admin);
	DDX_Text(pDX, IDC_SECRET, m_secret);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CEnterDlg, CDialog)
	//{{AFX_MSG_MAP(CEnterDlg)
	ON_BN_CLICKED(IDC_CHANGE_SECRET, OnChangeSecret)
	ON_BN_CLICKED(IDC_Manager, OnManager)
	ON_BN_CLICKED(IDC_Employee, OnEmployee)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEnterDlg message handlers

void CEnterDlg::OnOK() 
{
	// TODO: Add extra validation here
     CDatabase dbTemp;
	CString adminstrator; 
    UpdateData();
	dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;"); 
	CRecordset  rs( &dbTemp); 
	if(manager == true)
	{
		rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 用户表 where username='"+m_admin+"' and password='"+m_secret+"'");
        if(!rs.IsEOF()) 
		{
			 rs.GetFieldValue((short)3,adminstrator);
			 if(adminstrator == "经理")
			 {
                 
				 a=true;
			 }
			 else
                 MessageBox("用户名或密码错误 !");
		}
		else
		{
			 MessageBox("用户名或密码错误 !");
			 return;
		}
		rs.Close();
	}
	else if(employee == true)
	{
	
		rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 用户表 where username='"+m_admin+"' and password='"+m_secret+"'");
        if(!rs.IsEOF()) 
		{
			 rs.GetFieldValue((short)3,adminstrator);
			 if(adminstrator == "营业员")
			 {
                 
				 a=true;
			 }
			 else
			 {
				 MessageBox("用户名或密码错误 !");
               
			 }

		}
		else
		{
			 MessageBox("用户名或密码错误 !");
			 return;
		}
		rs.Close();
	}
	else 
	{
		MessageBox("请选择身份");
		 return;
	}
	
		UpdateData(false);
	dbTemp.Close();

	// The one and only window has been initialized, so show and update it.
    if(a==true)
	
	CDialog::OnOK();
	
}

void CEnterDlg::OnChangeSecret() 
{
	// TODO: Add your control notification handler code here
	CSecretChangeDlg dlg;
	dlg.DoModal();
}

void CEnterDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}


void CEnterDlg::OnManager() 
{
	// TODO: Add your control notification handler code here
		manager = true;
	employee = false;
}

void CEnterDlg::OnEmployee() 
{
	// TODO: Add your control notification handler code here
	manager = false;
	employee = true;
}

⌨️ 快捷键说明

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