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

来源:互联网 发布:linux下oracle创建实例 编辑:程序博客网 时间:2024/04/30 20:35

// SalesManagementSystemDlg.h : header file//#if !defined(AFX_SALESMANAGEMENTSYSTEMDLG_H__105B9A75_F845_4C7E_8FEF_84A37882625E__INCLUDED_)#define AFX_SALESMANAGEMENTSYSTEMDLG_H__105B9A75_F845_4C7E_8FEF_84A37882625E__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000#include "MyButton.h"//#define ID_BTNTIME WM_USER+100/////////////////////////////////////////////////////////////////////////////// CSalesManagementSystemDlg dialogclass CSalesManagementSystemDlg : public CDialog{// Constructionpublic:CSalesManagementSystemDlg(CWnd* pParent = NULL);// standard constructorCString strCode, strName;// Dialog Data//{{AFX_DATA(CSalesManagementSystemDlg)enum { IDD = IDD_SALESMANAGEMENTSYSTEM_DIALOG };CMyButtonm_btnUserName;CMyButtonm_btnAdmin;CMyButtonm_ctrlTime;//}}AFX_DATA// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CSalesManagementSystemDlg)protected:virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support//}}AFX_VIRTUAL// Implementationprotected:HICON m_hIcon;// Generated message map functions//{{AFX_MSG(CSalesManagementSystemDlg)virtual BOOL OnInitDialog();afx_msg void OnSysCommand(UINT nID, LPARAM lParam);afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnTimer(UINT nIDEvent);afx_msg void OnCommodityclassify();afx_msg void OnCommodityinfo();afx_msg void OnClientinfo();afx_msg void OnProviderinfo();afx_msg void OnImport();afx_msg void OnStockcheck();afx_msg void OnSalebill();afx_msg void OnAlarm();afx_msg void OnDailyincomereport();afx_msg void OnCommodityinforeport();afx_msg void OnCopy();afx_msg void OnDelete();afx_msg void OnRestore();afx_msg void OnBillamount();afx_msg void OnCommoditysaleamount();afx_msg void OnMonthaccount();afx_msg void OnExcessalarm();afx_msg void OnIncomereport();afx_msg void OnLittlealarm();afx_msg void OnUser();afx_msg void OnPassword();afx_msg void OnClose();afx_msg void OnEsc();afx_msg void OnClientintegral();//}}AFX_MSGDECLARE_MESSAGE_MAP()};//{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_SALESMANAGEMENTSYSTEMDLG_H__105B9A75_F845_4C7E_8FEF_84A37882625E__INCLUDED_)// SalesManagementSystemDlg.cpp : implementation file//#include "stdafx.h"#include "SalesManagementSystem.h"#include "SalesManagementSystemDlg.h"#include "DiagLog.h"#include "MyTime.h"#include "MyButton.h"#include "CommodityClassify.h"#include "CommodityInfo.h"#include "DlgClient.h"#include "DlgProvider.h"#include "DlgImport.h"#include "DlgReport.h"#include "SalesBill.h"#include "DlgReport.h"#include "DlgPasswd.h"#include "DlgUser.h"#include "DlgQuit.h"#include "DlgIntegral.h"#include "ADOConn.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CAboutDlg dialog used for App Aboutclass 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// Implementationprotected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_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_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CSalesManagementSystemDlg dialogCSalesManagementSystemDlg::CSalesManagementSystemDlg(CWnd* pParent /*=NULL*/): CDialog(CSalesManagementSystemDlg::IDD, pParent){//{{AFX_DATA_INIT(CSalesManagementSystemDlg)// NOTE: the ClassWizard will add member initialization here//}}AFX_DATA_INIT// Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);}void CSalesManagementSystemDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CSalesManagementSystemDlg)DDX_Control(pDX, IDC_USERNAME, m_btnUserName);DDX_Control(pDX, IDC_ADMIN, m_btnAdmin);DDX_Control(pDX, IDC_TIME, m_ctrlTime);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CSalesManagementSystemDlg, CDialog)//{{AFX_MSG_MAP(CSalesManagementSystemDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_WM_TIMER()ON_BN_CLICKED(IDC_COMMODITYCLASSIFY, OnCommodityclassify)ON_BN_CLICKED(IDC_COMMODITYINFO, OnCommodityinfo)ON_BN_CLICKED(IDC_CLIENTINFO, OnClientinfo)ON_BN_CLICKED(IDC_PROVIDERINFO, OnProviderinfo)ON_BN_CLICKED(IDC_IMPORT, OnImport)ON_BN_CLICKED(IDC_STOCKCHECK, OnStockcheck)ON_BN_CLICKED(IDC_SALEBILL, OnSalebill)ON_BN_CLICKED(IDC_ALARM, OnAlarm)ON_COMMAND(IDM_DAILYINCOMEREPORT, OnDailyincomereport)ON_COMMAND(IDM_COMMODITYINFOREPORT, OnCommodityinforeport)ON_COMMAND(IDM_COPY, OnCopy)ON_COMMAND(IDM_DELETE, OnDelete)ON_COMMAND(IDM_RESTORE, OnRestore)ON_COMMAND(IDM_BILLAMOUNT, OnBillamount)ON_COMMAND(IDM_COMMODITYSALEAMOUNT, OnCommoditysaleamount)ON_COMMAND(IDM_MONTHACCOUNT, OnMonthaccount)ON_COMMAND(IDM_EXCESSALARM, OnExcessalarm)ON_COMMAND(IDM_INCOMEREPORT, OnIncomereport)ON_COMMAND(IDM_LITTLEALARM, OnLittlealarm)ON_COMMAND(IDM_USER, OnUser)ON_COMMAND(IDM_PASSWORD, OnPassword)ON_WM_CLOSE()ON_COMMAND(IDM_ESC, OnEsc)ON_COMMAND(IDM_CLIENTINTEGRAL, OnClientintegral)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CSalesManagementSystemDlg message handlersBOOL CSalesManagementSystemDlg::OnInitDialog(){CDialog::OnInitDialog();// 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 dialogSetIcon(m_hIcon, TRUE);// Set big iconSetIcon(m_hIcon, FALSE);// Set small icon// TODO: Add extra initialization hereCString strTime;CMyTime myTime;strTime = myTime.GetDateString(FALSE) + "  " + myTime.GetWeekDay() + "  " + myTime.GetTimeString(FALSE);m_ctrlTime.SetXAlign(0);m_ctrlTime.SetWindowText(strTime);m_btnAdmin.SetXAlign(0);m_btnUserName.SetXAlign(0);m_btnAdmin.SetWindowText("管理员:");m_btnUserName.SetWindowText(strName);SetTimer(1, 1000, NULL);return TRUE;  // return TRUE  unless you set the focus to a control}void CSalesManagementSystemDlg::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 CSalesManagementSystemDlg::OnPaint() {if (IsIconic()){CPaintDC dc(this); // device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);// Center icon in client rectangleint 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 icondc.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 CSalesManagementSystemDlg::OnQueryDragIcon(){return (HCURSOR) m_hIcon;}void CSalesManagementSystemDlg::OnTimer(UINT nIDEvent) {// TODO: Add your message handler code here and/or call defaultCString strTime;CMyTime myTime;strTime = myTime.GetDateString(FALSE) + "  " + myTime.GetWeekDay() + "  " + myTime.GetTimeString(FALSE);switch(nIDEvent){case 1:m_ctrlTime.SetXAlign(0);m_ctrlTime.SetWindowText(strTime);break;default:break;}CDialog::OnTimer(nIDEvent);}void CSalesManagementSystemDlg::OnCommodityclassify() {// TODO: Add your control notification handler code hereCCommodityClassify classifyDlg;classifyDlg.DoModal();}void CSalesManagementSystemDlg::OnCommodityinfo() {// TODO: Add your control notification handler code hereCCommodityInfo infoDlg;infoDlg.DoModal();}void CSalesManagementSystemDlg::OnClientinfo() {// TODO: Add your control notification handler code hereCDlgClient dlgClient;dlgClient.DoModal();}void CSalesManagementSystemDlg::OnProviderinfo() {// TODO: Add your control notification handler code hereCDlgProvider dlgProvider;dlgProvider.DoModal();}void CSalesManagementSystemDlg::OnImport() {// TODO: Add your control notification handler code hereCDlgImport dlgImport;dlgImport.m_strBiller = strName;dlgImport.m_strProvider = "";dlgImport.DoModal();}void CSalesManagementSystemDlg::OnStockcheck() {// TODO: Add your control notification handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT CommodityInfo.*, StoreInfo.stockprice, StoreInfo.saleprice, StoreInfo.num ";strSQL = strSQL + "FROM CommodityInfo INNER JOIN StoreInfo ON CommodityInfo.barcode = StoreInfo.barcode";dlgReport.strTitle = "商品库存统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnSalebill() {// TODO: Add your control notification handler code hereCSalesBill dlgSaleBill;dlgSaleBill.m_strBiller = strName;dlgSaleBill.DoModal();}void CSalesManagementSystemDlg::OnAlarm() {// TODO: Add your control notification handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT CommodityInfo.*, StoreInfo.stockprice, StoreInfo.saleprice, StoreInfo.num ";strSQL = strSQL + "FROM CommodityInfo INNER JOIN StoreInfo ON CommodityInfo.barcode = StoreInfo.barcode ";strSQL = strSQL + "WHERE StoreInfo.num < CommodityInfo.minnum";dlgReport.strTitle = "商品过少统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnDailyincomereport() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT * FROM SaleBill";dlgReport.strTitle = "营业收入日报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnCommodityinforeport() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT * FROM CommodityInfo";dlgReport.strTitle = "商品信息明细报表";dlgReport.strSQL =strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnCopy() {// TODO: Add your command handler code hereCADOConn adoMain;CString strDataPath;CString strBackupPath;CMyTime myTime;strDataPath = adoMain.GetAppPath() + "\\data\\ShopSale.mdb";strBackupPath = adoMain.GetAppPath() + "\\data\\BackUp\\" + myTime.GetSimpleString() + ".mdb";if (CopyFile(strDataPath, strBackupPath, FALSE)){MessageBox("备份成功", "提示", MB_OK | MB_ICONINFORMATION);}else{MessageBox("备份失败", "提示", MB_OK | MB_ICONWARNING);}}void CSalesManagementSystemDlg::OnDelete() {// TODO: Add your command handler code hereCADOConn adoMain;CString strSql;CString str[6]={"StockBill", "StockCommodity", "SaleBill", "SaleCommodity"};if (MessageBox("确定数据清理吗?此操作将删除进货/销售有关记录!", "提示", MB_OKCANCEL | MB_ICONQUESTION) != IDOK){return;}OnCopy();for(int i = 0; i < 4; i++){strSql = "DELETE FROM " + str[i];adoMain.ExecuteSQL(strSql);}MessageBox("数据清理完毕!", "提示", MB_OK | MB_ICONINFORMATION);adoMain.ExitConnect();}void CSalesManagementSystemDlg::OnRestore() {// TODO: Add your command handler code hereCString strDataPath;CADOConn adoMain;CFileDialog fileDlg(TRUE, "mdb", adoMain.GetAppPath() + "\\data\\BackUp\\*.mdb", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "数据库文件(*.mdb)|*.mdb||");strDataPath = adoMain.GetAppPath() + "\\data\\ShopSale.mdb";if (fileDlg.DoModal() == IDOK){if(MessageBox("确定恢复吗?", "", MB_OKCANCEL | MB_ICONQUESTION) != IDOK){return;}DeleteFile(strDataPath);CopyFile(fileDlg.GetPathName(), strDataPath, FALSE);}}void CSalesManagementSystemDlg::OnBillamount() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT * FROM SaleBill";dlgReport.strTitle = "销售单统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnCommoditysaleamount() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT * FROM SaleCommodity";dlgReport.strTitle = "销售商品统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnMonthaccount() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT * FROM SaleBill";dlgReport.strTitle = "销售月度结算";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnExcessalarm() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT CommodityInfo.*, StoreInfo.stockprice, StoreInfo.saleprice, StoreInfo.num ";strSQL = strSQL + "FROM CommodityInfo INNER JOIN StoreInfo ON CommodityInfo.barcode = StoreInfo.barcode ";strSQL = strSQL + "WHERE StoreInfo.num > CommodityInfo.maxnum";dlgReport.strTitle = "商品过多统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnIncomereport() {// TODO: Add your command handler code here}void CSalesManagementSystemDlg::OnLittlealarm() {// TODO: Add your command handler code hereCDlgReport dlgReport;CString strSQL;strSQL = "SELECT CommodityInfo.*, StoreInfo.stockprice, StoreInfo.saleprice, StoreInfo.num ";strSQL = strSQL + "FROM CommodityInfo INNER JOIN StoreInfo ON CommodityInfo.barcode = StoreInfo.barcode ";strSQL = strSQL + "WHERE StoreInfo.num < CommodityInfo.minnum";dlgReport.strTitle = "商品过少统计报表";dlgReport.strSQL = strSQL;dlgReport.DoModal();}void CSalesManagementSystemDlg::OnUser() {// TODO: Add your command handler code hereCDlgUser dlgUser;dlgUser.DoModal();}void CSalesManagementSystemDlg::OnPassword() {// TODO: Add your command handler code hereCDlgPasswd dlgPasswd;dlgPasswd.strCode = strCode;dlgPasswd.DoModal();}void CSalesManagementSystemDlg::OnClose() {// TODO: Add your message handler code here and/or call defaultOnEsc();}void CSalesManagementSystemDlg::OnEsc() {// TODO: Add your command handler code hereCDlgQuit dlgQuit;if (dlgQuit.DoModal() == IDOK){if (dlgQuit.iBackup == 1){CSalesManagementSystemDlg::OnCopy();}CDialog::OnOK();}}void CSalesManagementSystemDlg::OnClientintegral() {// TODO: Add your command handler code hereCDlgIntegral dlgIntegral;dlgIntegral.DoModal();}


原创粉丝点击