EnrolDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:3k
- // EnrolDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "EnrolDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEnrolDlg dialog
- CEnrolDlg::CEnrolDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CEnrolDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CEnrolDlg)
- m_admin = _T("");
- m_secret = _T("");
- m_affirm_secret = _T("");
- //}}AFX_DATA_INIT
- }
- void CEnrolDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CEnrolDlg)
- DDX_Control(pDX, IDC_COMBO1, m_department);
- DDX_Text(pDX, IDC_EDIT1, m_admin);
- DDX_Text(pDX, IDC_EDIT2, m_secret);
- DDX_Text(pDX, IDC_EDIT3, m_affirm_secret);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CEnrolDlg, CDialog)
- //{{AFX_MSG_MAP(CEnrolDlg)
- ON_BN_CLICKED(IDC_ADMIN_INSPECT, OnAdminInspect)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CEnrolDlg message handlers
- void CEnrolDlg::OnOK() //用户录入
- {
- // TODO: Add extra validation here
- UpdateData();
- CString strSQL;
- CString department;
- CDatabase dbTemp; //打开数据库
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- CRecordset rs( &dbTemp);
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 登录信息 where usename = '"+m_admin+"' " );
- if(!rs.IsEOF())
- {
- MessageBox("此用户名已经被注册!");
- m_admin = "";
- UpdateData(false);
- }
- else
- {
- m_department.GetWindowText(department);
- if(m_secret != m_affirm_secret)
- {
- MessageBox("两次密码设定不同!");
-
- }
- else
- {
- strSQL = "insert into 登录信息([usename],[password],[depart]) values ('"+m_admin+"','"+m_secret+"','"+department+"')";
- dbTemp.ExecuteSQL(strSQL);
- MessageBox("用户注册成功!");
- }
-
- }
-
- rs.Close();
- dbTemp.Close();
-
- // CDialog::OnOK();
- }
- void CEnrolDlg::OnAdminInspect() //检测用户名
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- CString strSQL;
- CDatabase dbTemp; //打开数据库
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- CRecordset rs( &dbTemp);
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 登录信息 where usename = '"+m_admin+"' " );
- if(!rs.IsEOF())
- {
- MessageBox("此用户名已经被注册!");
- }
- else
- {
- MessageBox("此用户名可以被使用!");
- }
-
- rs.Close();
- dbTemp.Close();
- }