DeleteDlg.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:2k
- // DeleteDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "DeleteDlg.h"
- #include "afxdb.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDeleteDlg dialog
- CDeleteDlg::CDeleteDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDeleteDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDeleteDlg)
- m_number = _T("");
- m_name = _T("");
- m_age = _T("");
- m_sex = _T("");
- m_department = _T("");
- //}}AFX_DATA_INIT
- }
- void CDeleteDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDeleteDlg)
- DDX_Text(pDX, IDC_EDIT1, m_number);
- DDX_Text(pDX, IDC_EDIT2, m_name);
- DDX_Text(pDX, IDC_EDIT4, m_age);
- DDX_Text(pDX, IDC_EDIT3, m_sex);
- DDX_Text(pDX, IDC_EDIT5, m_department);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDeleteDlg, CDialog)
- //{{AFX_MSG_MAP(CDeleteDlg)
- ON_BN_CLICKED(IDC_DELETE_SEARCH, OnDeleteSearch)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDeleteDlg message handlers
- void CDeleteDlg::OnOK() //删减人员操作
- {
- // TODO: Add extra validation here
- CDatabase dbTemp;
- CString strSQL;
- UpdateData();
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- if (m_flag == true)
- {
- strSQL="delete from 员工信息 where number='"+m_number+"'";
- dbTemp.ExecuteSQL(strSQL);
- MessageBox("删除成功!");
- }
- else
- MessageBox("没有这个编号的员工!n删除失败!");
- m_number="";
- m_name="";
- m_age="";
- m_sex="";
- m_department="";
- UpdateData(false);
- dbTemp.Close();
- // CDialog::OnOK();
- }
- void CDeleteDlg::OnDeleteSearch()
- {
- // TODO: Add your control notification handler code here
- CDatabase dbTemp;
- CRecordset rs( &dbTemp);
- UpdateData();
- dbTemp.OpenEx("Driver={Microsoft Access Driver (*.mdb)};DBQ=超市管理数据库.mdb;");
- rs.Open(AFX_DB_USE_DEFAULT_TYPE,"select * From 员工信息 where number='"+m_number+"'");
- if (!rs.IsEOF())
- {
- rs.GetFieldValue((short)1,m_name);
- rs.GetFieldValue((short)2,m_age);
- rs.GetFieldValue((short)3,m_sex);
- rs.GetFieldValue((short)4,m_department);
- m_flag=true;
- }
- else
- {
- MessageBox("没有这个员工!");
- m_flag=false;
- }
- UpdateData(false);
- rs.Close();
- dbTemp.Close();
- }