#if !defined(AFX_DLGPROVIDER_H__C77F0241_D7F1_4840_A135_85CEC854C1B8__INCLUDED_)
#define AFX_DLGPROVIDER_H__C77F0241_D7F1_4840_A135_85CEC854C1B8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgProvider.h : header file
//
/
// CDlgProvider dialog
class CDlgProvider : public CDialog
{
// Construction
public:
CDlgProvider(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlgProvider)
enum { IDD = IDD_PROVIDER };
CListCtrl m_ctrlListMain;
CString m_strCompany;
CString m_strAddress;
CString m_strCode;
CString m_strName;
CString m_strPhone;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgProvider)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgProvider)
virtual BOOL OnInitDialog();
afx_msg void OnAddprovider();
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_DLGPROVIDER_H__C77F0241_D7F1_4840_A135_85CEC854C1B8__INCLUDED_)
// DlgProvider.cpp : implementation file
//
#include "stdafx.h"
#include "SalesManagementSystem.h"
#include "DlgProvider.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CDlgProvider dialog
CDlgProvider::CDlgProvider(CWnd* pParent /*=NULL*/)
: CDialog(CDlgProvider::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgProvider)
m_strCompany = _T("");
m_strAddress = _T("");
m_strCode = _T("");
m_strName = _T("");
m_strPhone = _T("");
//}}AFX_DATA_INIT
}
void CDlgProvider::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgProvider)
DDX_Control(pDX, IDC_LISTMAIN, m_ctrlListMain);
DDX_Text(pDX, IDC_COMPANY, m_strCompany);
DDX_Text(pDX, IDC_PROVIDERADDRESS, m_strAddress);
DDX_Text(pDX, IDC_PROVIDERCODE, m_strCode);
DDX_Text(pDX, IDC_PROVIDERNAME, m_strName);
DDX_Text(pDX, IDC_PROVIDERPHONE, m_strPhone);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgProvider, CDialog)
//{{AFX_MSG_MAP(CDlgProvider)
ON_BN_CLICKED(IDC_ADDPROVIDER, OnAddprovider)
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()
/
// CDlgProvider message handlers
BOOL CDlgProvider::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CADOConn adoProvider;
CString strSQL;
strSQL = "SELECT * FROM ProviderInfo";
adoProvider.Open(strSQL);
adoProvider.InitList(&m_ctrlListMain);
adoProvider.FillList(&m_ctrlListMain);
m_ctrlListMain.SetColumnWidth(0, 60);
m_ctrlListMain.SetColumnWidth(1, 90);
m_ctrlListMain.SetColumnWidth(2, 100);
m_ctrlListMain.SetColumnWidth(3, 150);
m_ctrlListMain.SetColumnWidth(4, 200);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgProvider::OnAddprovider()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_ctrlListMain.InsertItem(0, m_strCode);
m_ctrlListMain.SetItemText(0, 1, m_strName);
m_ctrlListMain.SetItemText(0, 2, m_strPhone);
m_ctrlListMain.SetItemText(0, 3, m_strCompany);
m_ctrlListMain.SetItemText(0, 4, m_strAddress);
m_strCode = "";
m_strName = "";
m_strPhone = "";
m_strCompany = "";
m_strAddress = "";
UpdateData(FALSE);
}
void CDlgProvider::OnUpdate()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CString strSQL;
CADOConn adoProvider;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "SELECT * FROM ProviderInfo WHERE ProviderInfo.code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoProvider.Open(strSQL);
if (adoProvider.adoEOF())
{
strSQL = "INSERT INTO ProviderInfo 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) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 4) + "')";
adoProvider.ExitConnect();
adoProvider.ExecuteSQL(strSQL);
}
else
{
strSQL = "UPDATE ProviderInfo SET code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', name = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 1) + "', telephone = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 2) + "', company = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 3) + "', address = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 4) + "' WHERE code = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoProvider.ExitConnect();
adoProvider.ExecuteSQL(strSQL);
}
m_strCode = "";
m_strName = "";
m_strPhone = "";
m_strCompany = "";
m_strAddress = "";
UpdateData(FALSE);
}
void CDlgProvider::OnDel()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
CADOConn adoProvider;
CString strSQL;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
strSQL = "DELETE * FROM ProviderInfo WHERE ProviderInfo.code ='";
strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "'";
adoProvider.ExecuteSQL(strSQL);
m_ctrlListMain.DeleteItem(index);
m_strCode = "";
m_strName = "";
m_strPhone = "";
m_strCompany = "";
m_strAddress = "";
UpdateData(FALSE);
}
void CDlgProvider::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_strPhone = m_ctrlListMain.GetItemText(index, 2);
m_strCompany = m_ctrlListMain.GetItemText(index, 3);
m_strAddress = m_ctrlListMain.GetItemText(index, 4);
UpdateData(FALSE);
*pResult = 0;
}
商店管理系统源代码(八)
最新推荐文章于 2018-01-14 19:32:06 发布