zoukankan      html  css  js  c++  java
  • 商店管理系统源代码(一)

    // 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 dialog
    
    
    class CSalesManagementSystemDlg : public CDialog
    {
    // Construction
    public:
    	CSalesManagementSystemDlg(CWnd* pParent = NULL);	// standard constructor
    	CString strCode, strName;
    
    
    // Dialog Data
    	//{{AFX_DATA(CSalesManagementSystemDlg)
    	enum { IDD = IDD_SALESMANAGEMENTSYSTEM_DIALOG };
    	CMyButton	m_btnUserName;
    	CMyButton	m_btnAdmin;
    	CMyButton	m_ctrlTime;
    	//}}AFX_DATA
    
    
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CSalesManagementSystemDlg)
    	protected:
    	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
    	//}}AFX_VIRTUAL
    
    
    // Implementation
    protected:
    	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_MSG
    	DECLARE_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_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    
    /////////////////////////////////////////////////////////////////////////////
    // CAboutDlg dialog used for App About
    
    
    class 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
    
    
    // Implementation
    protected:
    	//{{AFX_MSG(CAboutDlg)
    	//}}AFX_MSG
    	DECLARE_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_MAP
    END_MESSAGE_MAP()
    
    
    /////////////////////////////////////////////////////////////////////////////
    // CSalesManagementSystemDlg dialog
    
    
    CSalesManagementSystemDlg::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 Win32
    	m_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_MAP
    END_MESSAGE_MAP()
    
    
    /////////////////////////////////////////////////////////////////////////////
    // CSalesManagementSystemDlg message handlers
    
    
    BOOL 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 dialog
    	SetIcon(m_hIcon, TRUE);			// Set big icon
    	SetIcon(m_hIcon, FALSE);		// Set small icon
    	
    	// TODO: Add extra initialization here
    
    
    
    
    
    
    
    
    
    
    
    
    	CString 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 painting
    
    
    		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
    
    
    		// Center icon in client rectangle
    		int 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 icon
    		dc.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 default
    	CString 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 here
    	CCommodityClassify classifyDlg;
    	classifyDlg.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnCommodityinfo() 
    {
    	// TODO: Add your control notification handler code here
    	CCommodityInfo infoDlg;
    	infoDlg.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnClientinfo() 
    {
    	// TODO: Add your control notification handler code here
    	CDlgClient dlgClient;
    	dlgClient.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnProviderinfo() 
    {
    	// TODO: Add your control notification handler code here
    	CDlgProvider dlgProvider;
    	dlgProvider.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnImport() 
    {
    	// TODO: Add your control notification handler code here
    	CDlgImport dlgImport;
    	dlgImport.m_strBiller = strName;
    	dlgImport.m_strProvider = "";
    	dlgImport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnStockcheck() 
    {
    	// TODO: Add your control notification handler code here
    	CDlgReport 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 here
    	CSalesBill dlgSaleBill;
    	dlgSaleBill.m_strBiller = strName;
    	dlgSaleBill.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnAlarm() 
    {
    	// TODO: Add your control notification handler code here
    	CDlgReport 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 here
    	CDlgReport dlgReport;
    	CString strSQL;
    	
    	strSQL = "SELECT * FROM SaleBill";
    	dlgReport.strTitle = "营业收入日报表";
    	dlgReport.strSQL = strSQL;
    	dlgReport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnCommodityinforeport() 
    {
    	// TODO: Add your command handler code here
    	CDlgReport dlgReport;
    	CString strSQL;
    
    
    	strSQL = "SELECT * FROM CommodityInfo";
    	dlgReport.strTitle = "商品信息明细报表";
    	dlgReport.strSQL =strSQL;
    	dlgReport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnCopy() 
    {
    	// TODO: Add your command handler code here
    	CADOConn 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 here
    	CADOConn 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 here
    	CString 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 here
    	CDlgReport dlgReport;
    	CString strSQL;
    
    
    	strSQL = "SELECT * FROM SaleBill";
    	dlgReport.strTitle = "销售单统计报表";
    	dlgReport.strSQL = strSQL;
    	dlgReport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnCommoditysaleamount() 
    {
    	// TODO: Add your command handler code here
    	CDlgReport dlgReport;
    	CString strSQL;
    
    
    	strSQL = "SELECT * FROM SaleCommodity";
    	dlgReport.strTitle = "销售商品统计报表";
    	dlgReport.strSQL = strSQL;
    	dlgReport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnMonthaccount() 
    {
    	// TODO: Add your command handler code here
    	CDlgReport dlgReport;
    	CString strSQL;
    
    
    	strSQL = "SELECT * FROM SaleBill";
    	dlgReport.strTitle = "销售月度结算";
    	dlgReport.strSQL = strSQL;
    	dlgReport.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnExcessalarm() 
    {
    	// TODO: Add your command handler code here
    	CDlgReport 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 here
    	CDlgReport 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 here
    	CDlgUser dlgUser;
    	dlgUser.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnPassword() 
    {
    	// TODO: Add your command handler code here
    	CDlgPasswd dlgPasswd;
    	dlgPasswd.strCode = strCode;
    	dlgPasswd.DoModal();
    }
    
    
    void CSalesManagementSystemDlg::OnClose() 
    {
    	// TODO: Add your message handler code here and/or call default
    	OnEsc();
    }
    
    
    void CSalesManagementSystemDlg::OnEsc() 
    {
    	// TODO: Add your command handler code here
    	CDlgQuit dlgQuit;
    	
    	if (dlgQuit.DoModal() == IDOK)
    	{
    		if (dlgQuit.iBackup == 1)
    		{
    			CSalesManagementSystemDlg::OnCopy();
    		}
    		CDialog::OnOK();
    	}
    }
    
    
    void CSalesManagementSystemDlg::OnClientintegral() 
    {
    	// TODO: Add your command handler code here
    	CDlgIntegral dlgIntegral;
    	dlgIntegral.DoModal();
    }


  • 相关阅读:
    Ubuntu11.04中如何将pycharm添加到系统的“应用程序”菜单里 (pycharm已成功安装)
    Office 365 离线安装
    关于wxpy,使用Python玩转微信的问题
    python3安装scrapy问题解决
    python打包exe文件-ImportError: No module named 'queue'
    Linux TOP命令按内存占用排序和按CPU占用排序
    设置iptables允许ssh、http、ftp服务
    重置linux mysql root密码
    linux.go
    return_fun.go 源码阅读
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3017500.html
Copyright © 2011-2022 走看看