#if !defined(AFX_DLGUSER_H__AB210C70_3B52_4972_A839_0D58276824C2__INCLUDED_)
#define AFX_DLGUSER_H__AB210C70_3B52_4972_A839_0D58276824C2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgUser.h : header file
//
/
// CDlgUser dialog
class CDlgUser : public CDialog
{
// Construction
public:
CDlgUser(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlgUser)
enum { IDD = IDD_USERINFO };
CListCtrl m_ctrlListMain;
CComboBox m_ctrlAuthority;
CString m_strCode;
CString m_strName;
CString m_strPasswd;
CString m_strAuthority;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgUser)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgUser)
virtual BOOL OnInitDialog();
afx_msg void OnAdd();
afx_msg void OnUpdate();
afx_msg void OnDel();
afx_msg void OnSelchangeList();
afx_msg void OnClickListmain(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGUSER_H__AB210C70_3B52_4972_A839_0D58276824C2__INCLUDED_)
// DlgUser.cpp : implementation file
//
#include "stdafx.h"
#include "SalesManagementSystem.h"
#include "DlgUser.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CDlgUser dialog
CDlgUser::CDlgUser(CWnd* pParent /*=NULL*/)
: CDialog(CDlgUser::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgUser)
m_strCode = _T("");
m_strName = _T("");
m_strPasswd = _T("");
m_strAuthority = _T("");
//}}AFX_DATA_INIT
}
void CDlgUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgUser)
DDX_Control(pDX, IDC_LISTMAIN, m_ctrlListMain);
DDX_Control(pDX, IDC_QUTHORITY, m_ctrlAuthority);
DDX_Text(pDX, IDC_CODE, m_strCode);
DDX_Text(pDX, IDC_NAME, m_strName);
DDX_Text(pDX, IDC_PASSWD, m_strPasswd);
DDX_CBString(pDX, IDC_QUTHORITY, m_strAuthority);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgUser, CDialog)
//{{AFX_MSG_MAP(CDlgUser)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_NOTIFY(NM_CLICK, IDC_LISTMAIN, OnClickListmain)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CDlgUser message handlers
BOOL CDlgUser::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ctrlAuthority.InsertString(0, "超级管理员");
m_ctrlAuthority.InsertString(1, "营业员");
m_ctrlAuthority.SetCurSel(0);
CADOConn adoUser;
CString strSQL;
strSQL = "SELECT * FROM UserInfo";
adoUser.Open(strSQL);
adoUser.InitList(&m_ctrlListMain);
adoUser.FillList(&m_ctrlListMain);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgUser::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString str;
m_ctrlListMain.InsertItem(0, m_strCode);
m_ctrlListMain.SetItemText(0, 1, m_strName);
str.Format(_T("%d"), m_ctrlAuthority.GetCurSel());
m_ctrlListMain.SetItemText(0, 2, str);
m_ctrlListMain.SetItemText(0, 3, m_strPasswd);
m_strCode = "";
m_strName = "";
m_strPasswd = "";
UpdateData(FALSE);
}
void CDlgUser::OnUpdate()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CString strSQL;
CADOConn adoUser;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "SELECT * FROM UserInfo WHERE UserInfo.code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoUser.Open(strSQL);
if (adoUser.adoEOF())
{
strSQL = "INSERT INTO UserInfo VALUES ('";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 1) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 2) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 3) + "')";
adoUser.ExitConnect();
adoUser.ExecuteSQL(strSQL);
}
else
{
strSQL = "UPDATE UserInfo SET code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', name = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 1) + "', authority = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 2) + "', passwd = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 3) + "' WHERE code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoUser.ExitConnect();
adoUser.ExecuteSQL(strSQL);
}
}
void CDlgUser::OnDel()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CADOConn adoUser;
CString strSQL;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "DELETE * FROM UserInfo WHERE UserInfo.code ='";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoUser.ExecuteSQL(strSQL);
m_ctrlListMain.DeleteItem(index);
}
void CDlgUser::OnClickListmain(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
m_strCode = m_ctrlListMain.GetItemText(index, 0);
m_strName = m_ctrlListMain.GetItemText(index, 1);
m_strPasswd = m_ctrlListMain.GetItemText(index, 3);
UpdateData(FALSE);
m_ctrlAuthority.SetCurSel(atoi(m_ctrlListMain.GetItemText(index, 2)));
*pResult = 0;
}
商店管理系统源代码(六)
最新推荐文章于 2013-04-12 15:37:20 发布