www.pudn.com > shangdianguanlixitong.rar > shopDlg.cpp, change:2005-06-23,size:37016b


// shopDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "shop.h" 
#include "shopDlg.h" 
#include "deptment.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
extern CShopApp theApp; 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CShopDlg dialog 
 
CShopDlg::CShopDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CShopDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CShopDlg) 
	m_address = _T(""); 
	m_deptname = _T(""); 
	m_deptno = _T(""); 
	m_duty = _T(""); 
	m_empname = _T(""); 
	m_empno = _T(""); 
	m_managername = _T(""); 
	m_remark = _T(""); 
	m_salary = _T(""); 
	m_sex = _T(""); 
	m_telephone = _T(""); 
	m_birthday = _T(""); 
	m_mode1 = _T(""); 
	m_mode2 = _T(""); 
	m_condition1 = _T(""); 
	m_condition2 = _T(""); 
	m_count = _T(""); 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON8); 
} 
 
void CShopDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CShopDlg) 
	DDX_Control(pDX, IDC_modify, m_modify); 
	DDX_Control(pDX, IDC_inquiry, m_inquiry); 
	DDX_Control(pDX, IDC_delete, m_delete); 
	DDX_Control(pDX, IDC_close, m_close); 
	DDX_Control(pDX, IDC_add, m_add); 
	DDX_Control(pDX, IDC_USERLIST, m_userlist); 
	DDX_Text(pDX, IDC_address, m_address); 
	DDX_Text(pDX, IDC_deptname, m_deptname); 
	DDX_Text(pDX, IDC_deptno, m_deptno); 
	DDX_Text(pDX, IDC_duty, m_duty); 
	DDX_Text(pDX, IDC_empname, m_empname); 
	DDX_Text(pDX, IDC_empno, m_empno); 
	DDX_Text(pDX, IDC_managername, m_managername); 
	DDX_Text(pDX, IDC_remark, m_remark); 
	DDX_Text(pDX, IDC_salary, m_salary); 
	DDX_CBString(pDX, IDC_sex, m_sex); 
	DDX_Text(pDX, IDC_telephone, m_telephone); 
	DDX_Text(pDX, IDC_birthday, m_birthday); 
	DDX_CBString(pDX, IDC_mode1, m_mode1); 
	DDX_CBString(pDX, IDC_mode2, m_mode2); 
	DDX_Text(pDX, IDC_condition1, m_condition1); 
	DDX_Text(pDX, IDC_condition2, m_condition2); 
	DDX_Text(pDX, IDC_count, m_count); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CShopDlg, CDialog) 
	//{{AFX_MSG_MAP(CShopDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_USERLIST, OnItemchangedUserlist) 
	ON_BN_CLICKED(IDC_add, Onadd) 
	ON_CBN_EDITCHANGE(IDC_mode1, OnEditchangemode1) 
	ON_CBN_EDITCHANGE(IDC_mode2, OnEditchangemode2) 
	ON_BN_CLICKED(IDC_lessthan1, Onlessthan1) 
	ON_BN_CLICKED(IDC_equal1, Onequal1) 
	ON_BN_CLICKED(IDC_morethan1, Onmorethan1) 
	ON_BN_CLICKED(IDC_or, Onor) 
	ON_BN_CLICKED(IDC_and, Onand) 
	ON_BN_CLICKED(IDC_lessthan2, Onlessthan2) 
	ON_BN_CLICKED(IDC_equal2, Onequal2) 
	ON_BN_CLICKED(IDC_morethan2, Onmorethan2) 
	ON_BN_CLICKED(IDC_inquiry, Oninquiry) 
	ON_BN_CLICKED(IDC_delete, Ondelete) 
	ON_BN_CLICKED(IDC_modify, Onmodify) 
	ON_BN_CLICKED(IDC_close, Onclose) 
	ON_BN_CLICKED(IDC_countnumber, Oncountnumber) 
	ON_COMMAND(ID_personmanage, Onpersonmanage) 
	ON_COMMAND(ID_MENUITEM32773, OnMenuitem32773) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CShopDlg message handlers 
 
BOOL CShopDlg::OnInitDialog() 
{ 
	//AfxMessageBox("欢迎使用本商店管理系统!"); 
	mode1 = ""; 
	mode2 = ""; 
	option1 = ""; 
	option2 = ""; 
	andor = ""; 
 
	option11 = false; 
	option22 = false; 
	andor00 = false; 
 
	CDialog::OnInitDialog(); 
	//this->GetDlgItem(IDC_BUTTON7)->EnableWindow(FALSE); 
         
      
	//m_cdelitem.EnableWindow(FALSE);//删除按钮不能用 
    
	::SendMessage(m_userlist.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);//当被选中时,所有子项都处于选中状态 
	//////////为列表控件添加列////////// 
 
	m_userlist.InsertColumn(0,"职工编号",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(1,"姓名",LVCFMT_LEFT,100); 
    m_userlist.InsertColumn (2,"性别",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(3,"工资",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(4,"职务",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(5,"部门编号",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(6,"部门名称",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(7,"部门经理",LVCFMT_LEFT,100); 
    m_userlist.InsertColumn (8,"出生日期",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(9,"家庭住址",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(10,"联系电话",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(11,"备注",LVCFMT_LEFT,100); 
	  
	//////////读取数据库中的信息添加到列表控件/////////// 
	//int nItem; 
	//_variant_t vempno,vempname,vsex,vsalary,vduty,vdeptno,vdeptname,vmanagername,vbirthday,vaddress,vtelephone,vremark; 
      displayintheuserlist(); 
	/*	try 
	{ 
		m_pRecordset.CreateInstance("ADODB.Recordset"); 
		m_pRecordset->Open("select  *  from employeeview order by empno",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	     
		 
	 
		//m_bSuccess = TRUE; 
		while(!m_pRecordset->adoEOF) 
		{ 
			vempno= m_pRecordset->GetCollect("empno"); 
			vempname = m_pRecordset->GetCollect("empname"); 
            vsex=m_pRecordset->GetCollect("sex"); 
			vsalary = m_pRecordset->GetCollect("salary"); 
			vduty = m_pRecordset->GetCollect("duty"); 
			vdeptno= m_pRecordset->GetCollect("deptno"); 
			vdeptname= m_pRecordset->GetCollect("deptname"); 
			vmanagername = m_pRecordset->GetCollect("managername"); 
			vbirthday = m_pRecordset->GetCollect("birthday"); 
			vaddress= m_pRecordset->GetCollect("address"); 
			vtelephone= m_pRecordset->GetCollect("telephone"); 
			vremark= m_pRecordset->GetCollect("remark"); 
			 
			//this->AbleFalse(); 
	     	//this->LoadData(); 
			//this->GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); 
			//this->GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE); 
			nItem=m_userlist.InsertItem(0xffff,(_bstr_t)vempno);//先插第一个项 
			m_userlist.SetItem(nItem,1,1,(_bstr_t)vempname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,2,1,(_bstr_t)vsex ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,3,1,(_bstr_t)vsalary ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,4,1,(_bstr_t)vduty,NULL,0,0,0); 
			m_userlist.SetItem(nItem,5,1,(_bstr_t)vdeptno,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,6,1,(_bstr_t)vdeptname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,7,1,(_bstr_t)vmanagername ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,8,1,(_bstr_t)vbirthday ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,9,1,(_bstr_t)vaddress,NULL,0,0,0); 
			m_userlist.SetItem(nItem,10,1,(_bstr_t)vtelephone,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,11,1,(_bstr_t)vremark,NULL,0,0,0); 
			 
 
			m_pRecordset->MoveNext(); 
		} 
	} 
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
     */ 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
	 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CShopDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CShopDlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CShopDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
 
//////将记录集中的数据加载到编辑框///// 
void CShopDlg::displayintheuserlist() 
{ 
	try 
	{ 
		m_userlist.DeleteAllItems(); 
		m_pRecordset.CreateInstance("ADODB.Recordset"); 
		m_pRecordset->Open("select  *  from employeeview order by empno",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	     
		 
	 
		//m_bSuccess = TRUE; 
		while(!m_pRecordset->adoEOF) 
		{ 
			vempno= m_pRecordset->GetCollect("empno"); 
			vempname = m_pRecordset->GetCollect("empname"); 
            vsex=m_pRecordset->GetCollect("sex"); 
			vsalary = m_pRecordset->GetCollect("salary"); 
			vduty = m_pRecordset->GetCollect("duty"); 
			vdeptno= m_pRecordset->GetCollect("deptno"); 
			vdeptname= m_pRecordset->GetCollect("deptname"); 
			vmanagername = m_pRecordset->GetCollect("managername"); 
			vbirthday = m_pRecordset->GetCollect("birthday"); 
			vaddress= m_pRecordset->GetCollect("address"); 
			vtelephone= m_pRecordset->GetCollect("telephone"); 
			vremark= m_pRecordset->GetCollect("remark"); 
			 
			//this->AbleFalse(); 
	     	//this->LoadData(); 
			//this->GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); 
			//this->GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE); 
			nItem=m_userlist.InsertItem(0xffff,(_bstr_t)vempno);//先插第一个项 
			m_userlist.SetItem(nItem,1,1,(_bstr_t)vempname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,2,1,(_bstr_t)vsex ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,3,1,(_bstr_t)vsalary ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,4,1,(_bstr_t)vduty,NULL,0,0,0); 
			m_userlist.SetItem(nItem,5,1,(_bstr_t)vdeptno,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,6,1,(_bstr_t)vdeptname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,7,1,(_bstr_t)vmanagername ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,8,1,(_bstr_t)vbirthday ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,9,1,(_bstr_t)vaddress,NULL,0,0,0); 
			m_userlist.SetItem(nItem,10,1,(_bstr_t)vtelephone,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,11,1,(_bstr_t)vremark,NULL,0,0,0); 
			 
 
			m_pRecordset->MoveNext(); 
		} 
 
 
	} 
	     
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
	     //m_pRecordset->Close(); 
		// m_pRecordset = NULL; 
 
 
 
} 
void CShopDlg::LoadData() 
{ 
 
     
	//m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	vempno = m_pRecordset->GetCollect("empno"); 
	vempname = m_pRecordset->GetCollect("empname"); 
	vsex = m_pRecordset->GetCollect("sex"); 
	vsalary = m_pRecordset->GetCollect("salary "); 
	vduty = m_pRecordset->GetCollect("duty"); 
	vdeptno = m_pRecordset->GetCollect("deptno"); 
	vdeptname = m_pRecordset->GetCollect("deptname"); 
	vmanagername = m_pRecordset->GetCollect("managername"); 
	vbirthday = m_pRecordset->GetCollect("birthday"); 
	vaddress = m_pRecordset->GetCollect("address"); 
	vtelephone = m_pRecordset->GetCollect("telephone"); 
	vremark = m_pRecordset->GetCollect("remark"); 
    UpdateData(true);//使得控件显示值 
	//m_num = vNum.lVal; 
//	m_name = (LPCTSTR)(_bstr_t)vName; 
	//m_sex = vSex.lVal; 
///	m_brithday = vBrithday.lVal; 
	//m_tel=vTel.lVal; 
	//m_addr=vAddr.lVal; 
 
 
	m_empno = (LPCTSTR)(_bstr_t)vempno; 
	m_empname = (LPCTSTR)(_bstr_t)vempname; 
	m_sex = (LPCTSTR)(_bstr_t)vsex; 
	m_salary = (LPCTSTR)(_bstr_t)vsalary; 
	m_duty= (LPCTSTR)(_bstr_t)vduty; 
	m_deptno= (LPCTSTR)(_bstr_t)vdeptno; 
	m_deptname = (LPCTSTR)(_bstr_t)vdeptname; 
	m_managername = (LPCTSTR)(_bstr_t)vmanagername; 
	m_birthday =  (LPCTSTR)(_bstr_t)vbirthday ; 
	m_address = (LPCTSTR)(_bstr_t)vaddress; 
	m_telephone= (LPCTSTR)(_bstr_t)vtelephone; 
	m_remark= (LPCTSTR)(_bstr_t)vremark; 
    //m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	UpdateData(FALSE);//使得控件显示值 
} 
 
 
void CShopDlg::LoadData0() 
{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select  *  from employeeview order by empno",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	    
 
     
	m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	vempno = m_pRecordset->GetCollect("empno"); 
	vempname = m_pRecordset->GetCollect("empname"); 
	vsex = m_pRecordset->GetCollect("sex"); 
	vsalary = m_pRecordset->GetCollect("salary"); 
	vduty = m_pRecordset->GetCollect("duty"); 
	vdeptno = m_pRecordset->GetCollect("deptno"); 
	vdeptname = m_pRecordset->GetCollect("deptname"); 
	vmanagername = m_pRecordset->GetCollect("managername"); 
	vbirthday = m_pRecordset->GetCollect("birthday"); 
	vaddress = m_pRecordset->GetCollect("address"); 
	vtelephone = m_pRecordset->GetCollect("telephone"); 
	vremark = m_pRecordset->GetCollect("remark"); 
    UpdateData(true);//使得控件显示值 
	//m_num = vNum.lVal; 
//	m_name = (LPCTSTR)(_bstr_t)vName; 
	//m_sex = vSex.lVal; 
///	m_brithday = vBrithday.lVal; 
	//m_tel=vTel.lVal; 
	//m_addr=vAddr.lVal; 
 
 
	m_empno = (LPCTSTR)(_bstr_t)vempno; 
	m_empname = (LPCTSTR)(_bstr_t)vempname; 
	m_sex = (LPCTSTR)(_bstr_t)vsex; 
	m_salary = (LPCTSTR)(_bstr_t)vsalary; 
	m_duty= (LPCTSTR)(_bstr_t)vduty; 
	m_deptno= (LPCTSTR)(_bstr_t)vdeptno; 
	m_deptname = (LPCTSTR)(_bstr_t)vdeptname; 
	m_managername = (LPCTSTR)(_bstr_t)vmanagername; 
	m_birthday=    (LPCTSTR)(_bstr_t)vbirthday  ; 
	m_address = (LPCTSTR)(_bstr_t)vaddress; 
	m_telephone= (LPCTSTR)(_bstr_t)vtelephone; 
	m_remark = (LPCTSTR)(_bstr_t)vremark; 
    //m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	UpdateData(FALSE);//使得控件显示值 
    // m_pRecordset->Close(); 
    // m_pRecordset = NULL; 
	//UpdateData(true); 
} 
 
 
void CShopDlg::OnItemchangedUserlist(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 
	// TODO: Add your control notification handler code here 
	if(pNMListView->uNewState&LVIS_SELECTED) 
	{ 
	//UpdateData(true); 
	//SaveData();///保存旧数据 
	m_nCurrentSel = pNMListView->iItem; 
	LoadData0();///加载新数据 
	//m_cdelitem.EnableWindow(); 
	 
	} 
	 
	*pResult = 0; 
} 
 
/////将编辑框的数据保存到记录集与列表框 
void CShopDlg::SaveData() 
{ 
	//m_pRecordset->AddNew(); 
	if(m_nCurrentSel>=0)//!m_pRecordset->adoEOF && && m_bAutoSave 
	{ 
		  
	vempno = m_empno; 
	vempname = m_empname; 
	vsex = m_sex; 
	vsalary = m_salary; 
	vduty = m_duty; 
	vdeptno = m_deptno; 
	vdeptname = m_deptname; 
	vmanagername = m_managername; 
	vbirthday = m_birthday; 
	vaddress = m_address; 
	vtelephone = m_telephone; 
	vremark = m_remark; 
		//m_pRecordset->AddNew(); 
		UpdateData(); 
		m_pRecordset->PutCollect("empno",vempno); 
		m_pRecordset->PutCollect("empname",vempname); 
		m_pRecordset->PutCollect("sex",vsex); 
		m_pRecordset->PutCollect("salary",vsalary); 
		m_pRecordset->PutCollect("duty",vduty); 
		m_pRecordset->PutCollect("deptno",vdeptno); 
		m_pRecordset->PutCollect("deptname",vdeptname); 
		m_pRecordset->PutCollect("managername",vmanagername); 
		m_pRecordset->PutCollect("birthday",vbirthday); 
		m_pRecordset->PutCollect("address",vaddress); 
		m_pRecordset->PutCollect("telephone",vtelephone); 
		m_pRecordset->PutCollect("remark",vremark); 
        m_pRecordset->Update(); 
	 
 
		/*m_userlist.SetItem(m_nCurrentSel,0,LVIF_TEXT,(_bstr_t)vempno,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,1,LVIF_TEXT,(_bstr_t)vempname,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,2,LVIF_TEXT,(_bstr_t)vsex,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,3,LVIF_TEXT,(_bstr_t)vsalary,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,4,LVIF_TEXT,(_bstr_t)vduty,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,5,LVIF_TEXT,(_bstr_t)vdeptno,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,6,LVIF_TEXT,(_bstr_t)vdeptname,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,7,LVIF_TEXT,(_bstr_t)vmanagername,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,8,LVIF_TEXT,(_bstr_t)vbirthday,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,9,LVIF_TEXT,(_bstr_t)vaddress,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,10,LVIF_TEXT,(_bstr_t)vtelephone,NULL,0,0,0); 
		m_userlist.SetItem(m_nCurrentSel,11,LVIF_TEXT,(_bstr_t)vremark,NULL,0,0,0); 
            */ 
	} 
} 
 
  
 
 
 
void CShopDlg::Onadd()  
{ 
	bool judge; 
	judge = false; 
 
	UpdateData(true);//把控件的值传给相应的变量 
	     if (m_empno == "" || m_empname == "" || m_deptno == "") 
		 { 
	   		 AfxMessageBox("职工编号或职工姓名或部门编号不能为空!!"); 
             goto tiaozhuan; 
		 } 
         m_pRecordset.CreateInstance("ADODB.Recordset"); 
		 m_pRecordset->Open("select  deptno  from deptment",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	     if (!m_pRecordset->adoEOF) 
		 { 
		 vdeptno= m_pRecordset->GetCollect("deptno"); 
		 //vdeptname= m_pRecordset->GetCollect("deptname"); 
		 while(_variant_t(m_deptno) != vdeptno && !m_pRecordset->adoEOF) 
		 { 
			 m_pRecordset->MoveNext(); 
			 if(!m_pRecordset->adoEOF) 
			 { 
			 vdeptno= m_pRecordset->GetCollect("deptno"); 
			 } 
		 } 
		 } 
 
         //AfxMessageBox("无此部门编号,请输入正确的部门编号!"); 
		 if (m_pRecordset->adoEOF) 
		 { 
			 AfxMessageBox("无此部门编号,请输入正确的部门编号!"); 
			 goto tiaozhuan; 
		 } 
		  
 
		 m_pRecordset->Close(); 
		 m_pRecordset = NULL; 
		 //UpdateData(true);//把控件的值传给相应的变量 
        //m_pRecordset1->Close(); 
		 //m_pRecordset1 = NULL; 
 
		   m_pRecordset1.CreateInstance(_uuidof(Recordset));// 
	       m_pRecordset1->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
           
		  
	try 
	   { 
		 
		    
	   	m_pRecordset1->AddNew(); 
		 
		vempno = m_empno; 
	    vempname = m_empname; 
	    vsex = m_sex; 
	    vsalary = m_salary; 
	    vduty = m_duty; 
	    vdeptno = m_deptno; 
	    //vdeptname = m_deptname; 
	    //vmanagername = m_managername; 
	    vbirthday = m_birthday; 
	    vaddress = m_address; 
      	vtelephone = m_telephone; 
    	vremark = m_remark; 
        //UpdateData(true); 
 
		m_pRecordset1->PutCollect("empno",vempno); 
		m_pRecordset1->PutCollect("empname",vempname); 
	    m_pRecordset1->PutCollect("sex",vsex); 
		m_pRecordset1->PutCollect("salary",vsalary); 
		m_pRecordset1->PutCollect("duty",vduty); 
		m_pRecordset1->PutCollect("deptno",vdeptno); 
		//m_pRecordset->PutCollect("deptname",vdeptname); 
		//m_pRecordset->PutCollect("managername",vmanagername); 
		m_pRecordset1->PutCollect("birthday",vbirthday); 
		m_pRecordset1->PutCollect("address",vaddress); 
		m_pRecordset1->PutCollect("telephone",vtelephone); 
		m_pRecordset1->PutCollect("remark",vremark); 
		 
 
		//UpdateData(true); 
                   
		 //m_pRecordset.CreateInstance("ADODB.Recordset"); 
		 //m_pRecordset->Open("insert into employee values(empno,empname,sex,salary,duty,deptno,birthday,address,telephone,remark)  ",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	      
        //AfxMessageBox("添加记录成功!"); 
 
		 m_pRecordset1->Update(); 
		  
		 m_pRecordset1->Close(); 
		 m_pRecordset1 = NULL; 
		 AfxMessageBox("添加记录成功!"); 
		 //重建指针,以备下次添加记录时使用      
         //m_pRecordset1.CreateInstance(_uuidof(Recordset));// 
	     //m_pRecordset1->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
          
         displayintheuserlist(); 
		  
 
		  
          
		  
 
 
	 
	} 
	 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
		  AfxMessageBox("此员工已存在!");///显示错误信息 
		    
	   } 
	   goto tiaozhuan1; 
 
	 
 
 
	/*if(m_empno.GetLength()>0 && m_empname.GetLength()>0) 
	{ 
		m_pRecordset->AddNew(); 
		m_nCurrentSel = m_userlist.InsertItem(0xffff,""); 
		SaveData();///保存数据到记录集和列表框 
		m_userlist.SetItemState(m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED); 
		m_userlist.SetHotItem(m_nCurrentSel); 
		m_userlist.SetFocus(); 
	}  */ 
     tiaozhuan:  
	   m_deptno = ""; 
	   UpdateData(false); 
 
tiaozhuan1: 
	   try {} 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
		  //AfxMessageBox("存储数据失败!");///显示错误信息 
		    
	   } 
 
 
 
	   //else 
		//AfxMessageBox("职工编号和职工姓名不能为空!!"); 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::OnEditchangemode1()  
{ 
 
	 
	if (m_mode1=="出生日期") 
		mode1="birthday"; 
	if (m_mode1=="所在部门名称") 
		mode1="deptname"; 
    if (m_mode1=="所在部门编号") 
		mode1="deptno"; 
	if (m_mode1=="工资") 
		mode1="salary"; 
	if (m_mode1=="姓名") 
		mode1="empname"; 
	if (m_mode1=="职工编号") 
		mode1="empno"; 
    AfxMessageBox("请选择查询方式!"); 
	//Update;  
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::OnEditchangemode2()  
{ 
	if (m_mode2 == "出生日期") 
		mode2 = "birthday"; 
	if (m_mode2 == "所在部门名称") 
		mode2 = "deptname"; 
    if (m_mode2 == "所在部门编号") 
		mode2 = "deptno"; 
	if (m_mode2 == "工资") 
		mode2 = "salary"; 
	if (m_mode2=="姓名") 
		mode2 = "empname"; 
	if (m_mode2 == "职工编号") 
		mode2 = "empno"; 
	  
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onlessthan1()  
{ 
	option1 = "<"; 
	option11 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onequal1()  
{ 
	option1 = "="; 
	option11 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onmorethan1()  
{ 
	option1 = ">"; 
	option11 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onor()  
{ 
	andor = "or"; 
	andor00 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onand()  
{ 
	andor = "and"; 
	andor00 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onlessthan2()  
{ 
	option2 = "<"; 
	option22 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onequal2()  
{ 
	option2 = "="; 
	option22 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onmorethan2()  
{ 
	//AfxMessageBox("请选择查询方式!"); 
	option2 = ">"; 
	option22 = true; 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Oninquiry()  
{ 
	UpdateData(true); 
    /////////////////////////////////// 
	if (m_mode1=="出生日期") 
		mode1="birthday"; 
	if (m_mode1=="所在部门名称") 
		mode1="deptname"; 
    if (m_mode1=="所在部门编号") 
		mode1="deptno"; 
	if (m_mode1=="工资") 
		mode1="salary"; 
	if (m_mode1=="姓名") 
		mode1="empname"; 
	if (m_mode1=="职工编号") 
		mode1="empno"; 
	////////////////////////////////// 
	if (m_mode2 == "出生日期") 
		mode2 = "birthday"; 
	if (m_mode2 == "所在部门名称") 
		mode2 = "deptname"; 
    if (m_mode2 == "所在部门编号") 
		mode2 = "deptno"; 
	if (m_mode2 == "工资") 
		mode2 = "salary"; 
	if (m_mode2=="姓名") 
		mode2 = "empname"; 
	if (m_mode2 == "职工编号") 
		mode2 = "empno";  
 
	condition1 = m_condition1; 
	condition2 = m_condition2; 
	//if (mode1 == "" && mode2 == "") 
		//AfxMessageBox("请选择查询方式!"); 
	//else 
	if(mode1 == "" && mode2 == "") 
		AfxMessageBox("请选择查询方式!"); 
	 
	if(option11 == true && option22 == true && andor00 == true) 
	{ 
	 sql = "select * from employeeview where " + mode1 +" "+ option1 +" " + "'"+ condition1 + "'" + " " + andor + " " + mode2 + " "+ option2 +" " + "'" + condition2 + "'"; 
	   
	} 
	 else if(option11 == true && andor00 == false) 
	 { 
		 sql = "select * from employeeview where " + mode1 + " " + option1 + " " + "'" + condition1+"'"; 
	       
	 } 
	 else if(option22 == true && andor == false) 
	 { 
		 sql = "select * from employeeview where " + mode2 + " " + option2 + " " + "'" + condition2 + "'"; 
	       
	 } 
	 
	 else 
		goto label; 
	 
 
	//sql = (mode1 + option1 + condition1) + (andor + mode2 + option2 + condition2); 
	try 
	{ 
		//AfxMessageBox("请选择查询方式!"); 
		m_pRecordset->Close(); 
		m_pRecordset = NULL; 
		 
	    m_userlist.DeleteAllItems(); 
 
		m_pRecordset.CreateInstance("ADODB.Recordset"); 
 
		//m_pRecordset->MoveFirst(); 
		//m_pRecordset.CreateInstance(_uuidof(Recordset));// 
		//m_pRecordset->Open("select  *  from employeeview",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
        m_pRecordset->Open( (_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	    //AfxMessageBox("请选择查询方式!"); 
		//m_pRecordset->Close(); 
		 
	     
		//m_pRecordset->Open("select  *  from employeeview where sql",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	     
		//m_bSuccess = TRUE; 
		 
		while(!m_pRecordset->adoEOF) 
		{ 
			 
			//AfxMessageBox("请选择查询方式!"); 
			vempno= m_pRecordset->GetCollect("empno"); 
			vempname = m_pRecordset->GetCollect("empname"); 
            vsex=m_pRecordset->GetCollect("sex"); 
			vsalary = m_pRecordset->GetCollect("salary"); 
			vduty = m_pRecordset->GetCollect("duty"); 
			vdeptno= m_pRecordset->GetCollect("deptno"); 
			vdeptname= m_pRecordset->GetCollect("deptname"); 
			vmanagername = m_pRecordset->GetCollect("managername"); 
			vbirthday = m_pRecordset->GetCollect("birthday"); 
			vaddress= m_pRecordset->GetCollect("address"); 
			vtelephone= m_pRecordset->GetCollect("telephone"); 
			vremark= m_pRecordset->GetCollect("remark"); 
			 
			//this->AbleFalse(); 
	     	//this->LoadData(); 
			//this->GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); 
			//this->GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE); 
			nItem=m_userlist.InsertItem(0xffff,(_bstr_t)vempno);//先插第一个项 
			m_userlist.SetItem(nItem,1,1,(_bstr_t)vempname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,2,1,(_bstr_t)vsex ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,3,1,(_bstr_t)vsalary ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,4,1,(_bstr_t)vduty,NULL,0,0,0); 
			m_userlist.SetItem(nItem,5,1,(_bstr_t)vdeptno,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,6,1,(_bstr_t)vdeptname,NULL,0,0,0); 
			m_userlist.SetItem(nItem,7,1,(_bstr_t)vmanagername ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,8,1,(_bstr_t)vbirthday ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,9,1,(_bstr_t)vaddress,NULL,0,0,0); 
			m_userlist.SetItem(nItem,10,1,(_bstr_t)vtelephone,NULL,0,0,0); 
		    m_userlist.SetItem(nItem,11,1,(_bstr_t)vremark,NULL,0,0,0); 
			 
 
			m_pRecordset->MoveNext(); 
		} 
	} 
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
     
	//对逻辑运算的符号的恢复,以供下一次的查询 。 
 label:	 //AfxMessageBox("请选择查询方式!"); 
	//option11 = false; 
	    //option22 = false; 
	    //andor00 = false; 
	//////////////////////////////////////////////////////////////////// 
                 
	 
	//mode1 = ""; 
	//mode2 = ""; 
	//option1 = ""; 
	//option2 = ""; 
	//andor = ""; 
     
   UpdateData(false); 
   //UpdateData(true); 
   //AfxMessageBox("请选择查询方式!"); 
 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Ondelete()  
{ 
	UpdateData(true); 
 
   //_variant_t vclassnumber; 
   //int panduan = 1; 
   //CString sql,sql2,classnumber; 
    //m_insertstudentnum = "'"+m_insertstudentnum + "'";  
    //sql = "select * from student where  studentnum = "+m_insertstudentnum ; 
	if(MessageBox("确定要删除吗?",0, 
			MB_OKCANCEL|MB_DEFBUTTON2|MB_ICONWARNING)==IDOK) 
	{ 
	m_empno = "'"+m_empno + "'";  
	sql = "select * from employee where  empno = "+m_empno ; 
	 
 
	////////////////////////////////////////////////////////////////////////////// 
	try 
	 { 
       m_pRecordset->Close(); 
       m_pRecordset = NULL; 
         m_pRecordset.CreateInstance(_uuidof(Recordset));// 
 
          
         m_pRecordset->Open( (_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
         m_pRecordset->Delete(adAffectCurrent); 
		  
		 //AfxMessageBox("删除记录成功!!"); 
 
		 displayintheuserlist(); 
 
       
 
		 //m_pRecordset->Close(); 
         //m_pRecordset = NULL; 
     //  m_pRecordset.CreateInstance(_uuidof(Recordset));// 
     //  m_pRecordset->Open("select * from student",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
                
	 } 
	 catch(_com_error e)///捕捉异常 
	   { 
		  AfxMessageBox("删除记录失败!");///显示错误信息 
		 // panduan = 0; 
	   } 
	} 
	 
     
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onmodify()  
{ 
	//先删除,再添加 
	//下面是删除 
	UpdateData(true); 
 
   //_variant_t vclassnumber; 
   //int panduan = 1; 
   //CString sql,sql2,classnumber; 
    //m_insertstudentnum = "'"+m_insertstudentnum + "'";  
    //sql = "select * from student where  studentnum = "+m_insertstudentnum ; 
	if(MessageBox("确定要修改吗吗?",0, 
			MB_OKCANCEL|MB_DEFBUTTON2|MB_ICONWARNING)==IDOK) 
	{ 
	m_empno = "'"+m_empno + "'";  
	sql = "select * from employee where  empno = "+m_empno ; 
	 
 
	////////////////////////////////////////////////////////////////////////////// 
	try 
	 { 
       m_pRecordset->Close(); 
       m_pRecordset = NULL; 
         m_pRecordset.CreateInstance(_uuidof(Recordset));// 
 
          
         m_pRecordset->Open( (_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
         m_pRecordset->Delete(adAffectCurrent); 
		  
		 //AfxMessageBox("删除记录成功!!"); 
 
		// displayintheuserlist(); 
 
       
 
		 //m_pRecordset->Close(); 
         //m_pRecordset = NULL; 
     //  m_pRecordset.CreateInstance(_uuidof(Recordset));// 
     //  m_pRecordset->Open("select * from student",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
                
	 } 
	 catch(_com_error e)///捕捉异常 
	   { 
		  //AfxMessageBox("删除记录失败!");///显示错误信息 
		 // panduan = 0; 
	   } 
	 
	 
 
     
	// TODO: Add your control notification handler code here 
 
	////////////////////////////////////////////////////////// 
	//********************下面是添加********************************* 
	//bool judge; 
//	judge = false; 
 
	UpdateData(true);//把控件的值传给相应的变量 
	     if (m_empno == "" || m_empname == "" || m_deptno == "") 
		 { 
	   		 AfxMessageBox("职工编号或职工姓名或部门编号不能为空!!"); 
             goto tiaozhuan; 
		 } 
         m_pRecordset.CreateInstance("ADODB.Recordset"); 
		 m_pRecordset->Open("select  deptno  from deptment",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	     if (!m_pRecordset->adoEOF) 
		 { 
		 vdeptno= m_pRecordset->GetCollect("deptno"); 
		 //vdeptname= m_pRecordset->GetCollect("deptname"); 
		 while(_variant_t(m_deptno) != vdeptno && !m_pRecordset->adoEOF) 
		 { 
			 m_pRecordset->MoveNext(); 
			 if(!m_pRecordset->adoEOF) 
			 { 
			 vdeptno= m_pRecordset->GetCollect("deptno"); 
			 } 
		 } 
		 } 
 
         //AfxMessageBox("无此部门编号,请输入正确的部门编号!"); 
		 if (m_pRecordset->adoEOF) 
		 { 
			 AfxMessageBox("无此部门编号,请输入正确的部门编号!"); 
			 goto tiaozhuan; 
		 } 
		  
 
		 m_pRecordset->Close(); 
		 m_pRecordset = NULL; 
		 //UpdateData(true);//把控件的值传给相应的变量 
        //m_pRecordset1->Close(); 
		 //m_pRecordset1 = NULL; 
 
		   m_pRecordset1.CreateInstance(_uuidof(Recordset));// 
	       m_pRecordset1->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
           
		  
	try 
	   { 
		 
		    
	   	m_pRecordset1->AddNew(); 
		 
		vempno = m_empno; 
	    vempname = m_empname; 
	    vsex = m_sex; 
	    vsalary = m_salary; 
	    vduty = m_duty; 
	    vdeptno = m_deptno; 
	    //vdeptname = m_deptname; 
	    //vmanagername = m_managername; 
	    vbirthday = m_birthday; 
	    vaddress = m_address; 
      	vtelephone = m_telephone; 
    	vremark = m_remark; 
        //UpdateData(true); 
 
		m_pRecordset1->PutCollect("empno",vempno); 
		m_pRecordset1->PutCollect("empname",vempname); 
	    m_pRecordset1->PutCollect("sex",vsex); 
		m_pRecordset1->PutCollect("salary",vsalary); 
		m_pRecordset1->PutCollect("duty",vduty); 
		m_pRecordset1->PutCollect("deptno",vdeptno); 
		//m_pRecordset->PutCollect("deptname",vdeptname); 
		//m_pRecordset->PutCollect("managername",vmanagername); 
		m_pRecordset1->PutCollect("birthday",vbirthday); 
		m_pRecordset1->PutCollect("address",vaddress); 
		m_pRecordset1->PutCollect("telephone",vtelephone); 
		m_pRecordset1->PutCollect("remark",vremark); 
		 
 
		//UpdateData(true); 
                   
		 //m_pRecordset.CreateInstance("ADODB.Recordset"); 
		 //m_pRecordset->Open("insert into employee values(empno,empname,sex,salary,duty,deptno,birthday,address,telephone,remark)  ",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	      
        //AfxMessageBox("添加记录成功!"); 
 
		 m_pRecordset1->Update(); 
		  
		 m_pRecordset1->Close(); 
		 m_pRecordset1 = NULL; 
		 //AfxMessageBox("添加记录成功!"); 
		 //重建指针,以备下次添加记录时使用      
         //m_pRecordset1.CreateInstance(_uuidof(Recordset));// 
	     //m_pRecordset1->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
          
          
		  
 
		  
          
		  
 
 
	 
	} 
	 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
		  AfxMessageBox("此员工已存在!");///显示错误信息 
		    
	   } 
	   goto tiaozhuan1; 
 
	 
 
 
	/*if(m_empno.GetLength()>0 && m_empname.GetLength()>0) 
	{ 
		m_pRecordset->AddNew(); 
		m_nCurrentSel = m_userlist.InsertItem(0xffff,""); 
		SaveData();///保存数据到记录集和列表框 
		m_userlist.SetItemState(m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED); 
		m_userlist.SetHotItem(m_nCurrentSel); 
		m_userlist.SetFocus(); 
	}  */ 
     tiaozhuan:  
	   m_deptno = ""; 
	   UpdateData(false); 
 
tiaozhuan1: 
	   try {} 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
		  //AfxMessageBox("存储数据失败!");///显示错误信息 
		    
	   } 
 
	   displayintheuserlist(); 
	   } 
	    
	   AfxMessageBox("修改成功!!!!!"); 
 
 
	 
} 
 
void CShopDlg::Onclose()  
{ 
	CDialog::OnOK(); 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Oncountnumber()  
{ 
	   
	  
	     int count = 0; 
		 CString vcount; 
		   
	     //m_pRecordset->Close(); 
		 //m_pRecordset = NULL; 
		 //UpdateData(true);//把控件的值传给相应的变量 
        //m_pRecordset1->Close(); 
		 //m_pRecordset1 = NULL; 
 
		   m_pRecordset.CreateInstance(_uuidof(Recordset));// 
	       m_pRecordset->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
          while (!m_pRecordset->adoEOF) 
		  { 
			  count = count + 1; 
			  m_pRecordset->MoveNext(); 
 
		  } 
		    
		  m_count.Format("%d",count); 
		  vcount = "当前职工人数为  " + m_count + "  人"; 
		  m_count = vcount; 
        
	   UpdateData(false); 
	    
	     
	//catch(_com_error e)///捕捉异常 
	  
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	  
	// TODO: Add your control notification handler code here 
	 
} 
 
void CShopDlg::Onpersonmanage()  
{ 
	CShopDlg::OnOK(); 
	CShopDlg dl; 
	dl.DoModal(); 
	  
	 
	// TODO: Add your command handler code here 
	 
} 
 
void CShopDlg::OnMenuitem32773()  
{ 
	//CShopDlg::OnOK(); 
	Cdeptment dl; 
	dl.DoModal(); 
 
	// TODO: Add your command handler code here 
	 
}