#if !defined(AFX_COMMODITYCLASSIFY_H__8513787F_04D5_48B7_9554_913BA20B876B__INCLUDED_)
#define AFX_COMMODITYCLASSIFY_H__8513787F_04D5_48B7_9554_913BA20B876B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CommodityClassify.h : header file
//
/
// CCommodityClassify dialog
class CCommodityClassify : public CDialog
{
// Construction
public:
CCommodityClassify(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCommodityClassify)
enum { IDD = IDD_COMMODITYCLASSIFY };
CListCtrl m_ctrlListMain;
CString m_strClassifyCode;
CString m_strClassifyName;
CString m_strClassifyNotes;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCommodityClassify)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCommodityClassify)
virtual BOOL OnInitDialog();
afx_msg void OnAdd();
afx_msg void OnUpdate();
afx_msg void OnDel();
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_COMMODITYCLASSIFY_H__8513787F_04D5_48B7_9554_913BA20B876B__INCLUDED_)
// CommodityClassify.cpp : implementation file
//
#include "stdafx.h"
#include "SalesManagementSystem.h"
#include "CommodityClassify.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CCommodityClassify dialog
CCommodityClassify::CCommodityClassify(CWnd* pParent /*=NULL*/)
: CDialog(CCommodityClassify::IDD, pParent)
{
//{{AFX_DATA_INIT(CCommodityClassify)
m_strClassifyCode = _T("");
m_strClassifyName = _T("");
m_strClassifyNotes = _T("");
//}}AFX_DATA_INIT
}
void CCommodityClassify::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCommodityClassify)
DDX_Control(pDX, IDC_LISTMAIN, m_ctrlListMain);
DDX_Text(pDX, IDC_CLASSIFYCODE, m_strClassifyCode);
DDX_Text(pDX, IDC_CLASSIFYNAME, m_strClassifyName);
DDX_Text(pDX, IDC_CLASSIFYNOTES, m_strClassifyNotes);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCommodityClassify, CDialog)
//{{AFX_MSG_MAP(CCommodityClassify)
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()
/
// CCommodityClassify message handlers
BOOL CCommodityClassify::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CADOConn adoClassify;
CString strSQL;
strSQL = "SELECT * FROM CommodityType";
adoClassify.Open(strSQL);
adoClassify.InitList(&m_ctrlListMain);
adoClassify.FillList(&m_ctrlListMain);
m_ctrlListMain.SetColumnWidth(0, 70);
m_ctrlListMain.SetColumnWidth(1, 100);
adoClassify.ExitConnect();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCommodityClassify::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_ctrlListMain.InsertItem(0, m_strClassifyCode);
m_ctrlListMain.SetItemText(0, 1, m_strClassifyName);
m_ctrlListMain.SetItemText(0, 2, m_strClassifyNotes);
}
void CCommodityClassify::OnUpdate()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CString strSQL;
CADOConn adoCommodityType;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "SELECT * FROM CommodityType WHERE CommodityType.code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoCommodityType.Open(strSQL);
if (adoCommodityType.adoEOF())
{
strSQL = "INSERT INTO CommodityType VALUES ('";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 1) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 2) + "')";
}
else
{
strSQL = "UPDATE CommodityType SET code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', name = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 1) + "', information = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 2) + "' WHERE code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
}
adoCommodityType.ExitConnect();
adoCommodityType.ExecuteSQL(strSQL);
}
void CCommodityClassify::OnDel()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CString strSQL;
CADOConn adoCommodityType;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "DELETE * FROM CommodityType WHERE CommodityType.code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoCommodityType.ExecuteSQL(strSQL);
m_ctrlListMain.DeleteItem(index);
}
void CCommodityClassify::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_strClassifyCode = m_ctrlListMain.GetItemText(index, 0);
m_strClassifyName = m_ctrlListMain.GetItemText(index, 1);
m_strClassifyNotes = m_ctrlListMain.GetItemText(index, 2);
UpdateData(FALSE);
*pResult = 0;
}
商店管理系统源代码(十六)
最新推荐文章于 2024-04-20 23:58:08 发布