商店管理系统源代码(十)

来源:互联网 发布:淘宝假货店铺名单2017 编辑:程序博客网 时间:2024/04/30 16:54
#if !defined(AFX_DLGINTEGRAL_H__B214685B_09EE_412A_8A55_5A1A425E836B__INCLUDED_)#define AFX_DLGINTEGRAL_H__B214685B_09EE_412A_8A55_5A1A425E836B__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000// DlgIntegral.h : header file///////////////////////////////////////////////////////////////////////////////// CDlgIntegral dialogclass CDlgIntegral : public CDialog{// Constructionpublic:CDlgIntegral(CWnd* pParent = NULL);   // standard constructorCString strBarcode;// Dialog Data//{{AFX_DATA(CDlgIntegral)enum { IDD = IDD_INTEGRAL };CListCtrlm_ctrlListMain;CStringm_strCardCode;CStringm_strCommodityName;CStringm_strCode;intm_iNum;//}}AFX_DATA// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CDlgIntegral)protected:virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support//}}AFX_VIRTUAL// Implementationprotected:// Generated message map functions//{{AFX_MSG(CDlgIntegral)virtual BOOL OnInitDialog();afx_msg void OnFinduser();afx_msg void OnFind();afx_msg void OnAdd();afx_msg void OnUpdate();afx_msg void OnDel();//}}AFX_MSGDECLARE_MESSAGE_MAP()};//{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_DLGINTEGRAL_H__B214685B_09EE_412A_8A55_5A1A425E836B__INCLUDED_)// DlgIntegral.cpp : implementation file//#include "stdafx.h"#include "SalesManagementSystem.h"#include "DlgIntegral.h"#include "DlgAll.h"#include "ADOConn.h"#include "MyTime.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CDlgIntegral dialogCDlgIntegral::CDlgIntegral(CWnd* pParent /*=NULL*/): CDialog(CDlgIntegral::IDD, pParent){//{{AFX_DATA_INIT(CDlgIntegral)m_strCardCode = _T("");m_strCommodityName = _T("");m_strCode = _T("");m_iNum = 0;//}}AFX_DATA_INIT}void CDlgIntegral::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CDlgIntegral)DDX_Control(pDX, IDC_LISTMAIN, m_ctrlListMain);DDX_Text(pDX, IDC_CARDCODE, m_strCardCode);DDX_Text(pDX, IDC_COMMODTIYNAME, m_strCommodityName);DDX_Text(pDX, IDC_CODE, m_strCode);DDX_Text(pDX, IDC_NUM, m_iNum);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CDlgIntegral, CDialog)//{{AFX_MSG_MAP(CDlgIntegral)ON_BN_CLICKED(IDC_FINDUSER, OnFinduser)ON_BN_CLICKED(IDC_FIND, OnFind)ON_BN_CLICKED(IDC_ADD, OnAdd)ON_BN_CLICKED(IDC_UPDATE, OnUpdate)ON_BN_CLICKED(IDC_DEL, OnDel)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CDlgIntegral message handlersBOOL CDlgIntegral::OnInitDialog() {CDialog::OnInitDialog();// TODO: Add extra initialization herem_iNum = 1;m_ctrlListMain.InsertColumn(0, "卡号", LVCFMT_CENTER, 100);m_ctrlListMain.InsertColumn(1, "名字", LVCFMT_CENTER, 50);m_ctrlListMain.InsertColumn(2, "总共积分", LVCFMT_CENTER, 100);m_ctrlListMain.InsertColumn(3, "已用积分", LVCFMT_CENTER, 100);m_ctrlListMain.InsertColumn(4, "剩余积分", LVCFMT_CENTER, 100);m_ctrlListMain.InsertColumn(5, "日期", LVCFMT_CENTER, 100);m_ctrlListMain.InsertColumn(6, "条形码", LVCFMT_CENTER, 50);m_ctrlListMain.InsertColumn(7, "名称", LVCFMT_CENTER, 70);m_ctrlListMain.InsertColumn(8, "价格", LVCFMT_CENTER, 50);m_ctrlListMain.InsertColumn(9, "数目", LVCFMT_CENTER, 50);m_ctrlListMain.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);UpdateData(FALSE);return TRUE;  // return TRUE unless you set the focus to a control              // EXCEPTION: OCX Property Pages should return FALSE}void CDlgIntegral::OnFinduser() {// TODO: Add your control notification handler code hereCDlgAll dlgAll;CString strSQL;strSQL = "SELECT * FROM ClientInfo";dlgAll.strTitle = "客户基本信息";dlgAll.strSQL = strSQL;dlgAll.intKey = 0;if (dlgAll.DoModal() == IDOK){m_strCardCode = dlgAll.strKey;UpdateData(FALSE);}}void CDlgIntegral::OnFind() {// TODO: Add your control notification handler code hereUpdateData(TRUE);CADOConn adoFind;CDlgAll dlgAll;CString strSQL;strSQL = "SELECT CommodityInfo.barcode, CommodityInfo.name, CommodityInfo.standard, ";strSQL = strSQL + "CommodityInfo.unit, StoreInfo.saleprice, StoreInfo.num FROM CommodityInfo INNER JOIN StoreInfo ON ";strSQL = strSQL + "CommodityInfo.barcode = StoreInfo.barcode WHERE CommodityInfo.barcode = '";strSQL = strSQL + m_strCode + "' OR CommodityInfo.commoditycode = '";strSQL = strSQL + m_strCode + "' OR CommodityInfo.spellcode = '";strSQL = strSQL + m_strCode + "'";dlgAll.strTitle = "商品基本信息";dlgAll.strSQL = strSQL;dlgAll.intKey = 0;if (dlgAll.DoModal() == IDOK){strSQL = "SELECT CommodityInfo.barcode, CommodityInfo.name FROM CommodityInfo ";strSQL = strSQL + "WHERE CommodityInfo.barcode = '";strSQL = strSQL + dlgAll.strKey + "'";adoFind.Open(strSQL);strBarcode = dlgAll.strKey;m_strCommodityName = adoFind.GetItemString(1);adoFind.ExitConnect();UpdateData(FALSE);}}void CDlgIntegral::OnAdd() {// TODO: Add your control notification handler code hereUpdateData(TRUE);CString strSQL, strTemp;CADOConn adoIntegral;CMyTime myTime;strSQL = "SELECT ClientInfo.cardcode, ClientInfo.username, Integral.totalintegral, Integral.usedintegral, ";strSQL = strSQL + "Integral.remainderintegral FROM ClientInfo INNER JOIN Integral ON ";strSQL = strSQL + "ClientInfo.cardcode = Integral.cardcode WHERE ClientInfo.cardcode = '";strSQL = strSQL + m_strCardCode + "'";adoIntegral.Open(strSQL);if (!adoIntegral.adoEOF()){m_ctrlListMain.InsertItem(0, adoIntegral.GetItemString(0));m_ctrlListMain.SetItemText(0, 1, adoIntegral.GetItemString(1));m_ctrlListMain.SetItemText(0, 2, adoIntegral.GetItemString(2));m_ctrlListMain.SetItemText(0, 3, adoIntegral.GetItemString(3));m_ctrlListMain.SetItemText(0, 4, adoIntegral.GetItemString(4));m_ctrlListMain.SetItemText(0, 5, myTime.GetDateString(FALSE));m_ctrlListMain.SetItemText(0, 6, strBarcode);strSQL = "SELECT CommodityInfo.barcode, CommodityInfo.name, StoreInfo.saleprice ";strSQL = strSQL + "FROM CommodityInfo INNER JOIN StoreInfo ON CommodityInfo.barcode = StoreInfo.barcode WHERE CommodityInfo.barcode = '";strSQL = strSQL + strBarcode + "'";adoIntegral.Open(strSQL);m_ctrlListMain.SetItemText(0, 7, adoIntegral.GetItemString(1));m_ctrlListMain.SetItemText(0, 8, adoIntegral.GetItemString(2));strTemp.Format(_T("%d"), m_iNum);m_ctrlListMain.SetItemText(0, 9, strTemp);adoIntegral.ExitConnect();}}void CDlgIntegral::OnUpdate() {// TODO: Add your control notification handler code hereUpdateData(TRUE);CString strSQL, strTemp;CADOConn adoIntegral, adoIntegralCommodity;POSITION pos;int index;pos = m_ctrlListMain.GetFirstSelectedItemPosition();index = m_ctrlListMain.GetNextSelectedItem(pos);strSQL = "UPDATE Integral SET usedintegral = '";strTemp.Format(_T("%d"), atoi(m_ctrlListMain.GetItemText(index, 3)) + atoi(m_ctrlListMain.GetItemText(index, 8)) * m_iNum);strSQL = strSQL + strTemp + "', remainderintegral = '";strTemp.Format(_T("%d"), atoi(m_ctrlListMain.GetItemText(index, 4)) - atoi(m_ctrlListMain.GetItemText(index, 8)) * m_iNum);strSQL = strSQL + strTemp + "' WHERE cardcode = '";strSQL = strSQL + m_strCardCode + "'";adoIntegral.ExecuteSQL(strSQL);strSQL = "INSERT INTO IntegralCommodity VALUES ('";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 0) + "', '";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 5) + "', '";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 6) + "', '";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 7) + "', '";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 8) + "', '";strSQL = strSQL + m_ctrlListMain.GetItemText(index, 9) + "')";adoIntegralCommodity.ExecuteSQL(strSQL);}void CDlgIntegral::OnDel() {// TODO: Add your control notification handler code herePOSITION pos;int index;CString strSQL, strTemp;CADOConn adoIntegral;pos = m_ctrlListMain.GetFirstSelectedItemPosition();index = m_ctrlListMain.GetNextSelectedItem(pos);strSQL = "UPDATE Integral SET usedintegral = '";strTemp.Format(_T("%d"), atoi(m_ctrlListMain.GetItemText(index, 3)) - atoi(m_ctrlListMain.GetItemText(index, 8)) * atoi(m_ctrlListMain.GetItemText(index, 9)));strSQL = strSQL + strTemp + "', remainderintegral = '";strTemp.Format(_T("%d"), atoi(m_ctrlListMain.GetItemText(index, 4)) + atoi(m_ctrlListMain.GetItemText(index, 8)) * atoi(m_ctrlListMain.GetItemText(index, 9)));strSQL = strSQL + strTemp + "' WHERE cardcode = '";strSQL = strSQL + m_strCardCode + "'";adoIntegral.ExecuteSQL(strSQL);m_ctrlListMain.DeleteItem(index);}

原创粉丝点击