EnterDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:3k
- // EnterDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "EnterDlg.h"
- #include "afxdb.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_Control(pDX, IDC_COMBO1, m_department);
- DDX_Text(pDX, IDC_EDIT1, m_admin);
- DDX_Text(pDX, IDC_EDIT2, m_secret);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CEnterDlg, CDialog)
- //{{AFX_MSG_MAP(CEnterDlg)
- ON_BN_CLICKED(IDC_Manager, OnManager)
- ON_BN_CLICKED(IDC_Employee, OnEmployee)
- ON_BN_CLICKED(IDC_CHANGE_SECRET, OnChangeSecret)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEnterDlg message handlers
- void CEnterDlg::OnManager()
- {
- // TODO: Add your control notification handler code here
- manager = true;
- employee = false;
- m_department.SetCurSel(0);
- }
- void CEnterDlg::OnEmployee()
- {
- // TODO: Add your control notification handler code here
- manager = false;
- employee = true;
- m_department.SetCurSel(1);
- }
- 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 usename='"+m_admin+"' and password='"+m_secret+"'");
- if(!rs.IsEOF())
- {
- rs.GetFieldValue((short)2,adminstrator);
- if(adminstrator == "经理")
- MessageBox("登录成功!");
- else
- MessageBox("你不是经理!n登录失败!");
- }
- else
- {
- MessageBox("用户名或密码错误 !");
- return;
- }
- rs.Close();
- }
- else if(employee == true)
- {
- m_department.GetWindowText(department);
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 登录信息 where usename='"+m_admin+"' and password='"+m_secret+"' and depart='"+department+"'");
- if(!rs.IsEOF())
- {
- MessageBox("登录成功!");
- }
- else
- {
- MessageBox("用户名或密码错误!n或者职位部门选错!");
- return;
- }
- rs.Close();
- }
- else
- {
- MessageBox("选择身份");
- return;
- }
-
- UpdateData(false);
- dbTemp.Close();
-
- CDialog::OnOK();
- }
- void CEnterDlg::OnChangeSecret() //修改密码
- {
- // TODO: Add your control notification handler code here
- CSecretChangeDlg S_Dlg;
- S_Dlg.DoModal();
-
- }