#if !defined(AFX_DLGIMPORT_H__F9771D9D_678B_4EE9_B9EE_BE85023C3C2A__INCLUDED_)
#define AFX_DLGIMPORT_H__F9771D9D_678B_4EE9_B9EE_BE85023C3C2A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgImport.h : header file
//
/
// CDlgImport dialog
class CDlgImport : public CDialog
{
// Construction
public:
CDlgImport(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlgImport)
enum { IDD = IDD_IMPORT };
CListCtrl m_ctrlListMain;
CString m_strCode;
CString m_strBillDate;
CString m_strBiller;
CString m_strNote;
int m_iNum;
float m_fltPrice;
CString m_strProvider;
float m_fltAmount;
CString m_strSearchCode;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgImport)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgImport)
virtual BOOL OnInitDialog();
afx_msg void OnProviderfind();
afx_msg void OnCommodityfind();
afx_msg void OnDeletecommodity();
afx_msg void OnClickListmain(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnStockbill();
afx_msg void OnStocksave();
afx_msg void OnUpdate();
afx_msg void OnStockaccount();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGIMPORT_H__F9771D9D_678B_4EE9_B9EE_BE85023C3C2A__INCLUDED_)
// DlgImport.cpp : implementation file
//
#include "stdafx.h"
#include "SalesManagementSystem.h"
#include "DlgImport.h"
#include "ADOConn.h"
#include "DlgAll.h"
#include "MyTime.h"
#include "DiagLog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CDlgImport dialog
CDlgImport::CDlgImport(CWnd* pParent /*=NULL*/)
: CDialog(CDlgImport::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgImport)
m_strCode = _T("");
m_strBillDate = _T("");
m_strBiller = _T("");
m_strNote = _T("");
m_iNum = 0;
m_fltPrice = 0.0f;
m_strProvider = _T("");
m_fltAmount = 0.0f;
m_strSearchCode = _T("");
//}}AFX_DATA_INIT
}
void CDlgImport::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgImport)
DDX_Control(pDX, IDC_LISTMAIN, m_ctrlListMain);
DDX_Text(pDX, IDC_STOCKCODE, m_strCode);
DDX_Text(pDX, IDC_STOCKBILLDATE, m_strBillDate);
DDX_Text(pDX, IDC_STOCKBILLER, m_strBiller);
DDX_Text(pDX, IDC_STOCKNOTE, m_strNote);
DDX_Text(pDX, IDC_STOCKNUM, m_iNum);
DDX_Text(pDX, IDC_STOCKPRICE, m_fltPrice);
DDX_Text(pDX, IDC_STOCKPROVIDER, m_strProvider);
DDX_Text(pDX, IDC_STOCKAMOUNT, m_fltAmount);
DDX_Text(pDX, IDC_FINDCODE, m_strSearchCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgImport, CDialog)
//{{AFX_MSG_MAP(CDlgImport)
ON_BN_CLICKED(IDC_PROVIDERFIND, OnProviderfind)
ON_BN_CLICKED(IDC_COMMODITYFIND, OnCommodityfind)
ON_BN_CLICKED(IDC_DELETECOMMODITY, OnDeletecommodity)
ON_NOTIFY(NM_CLICK, IDC_LISTMAIN, OnClickListmain)
ON_BN_CLICKED(IDC_STOCKBILL, OnStockbill)
ON_BN_CLICKED(IDC_STOCKSAVE, OnStocksave)
ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
ON_BN_CLICKED(IDC_STOCKACCOUNT, OnStockaccount)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CDlgImport message handlers
BOOL CDlgImport::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ctrlListMain.InsertColumn(0, "条形码", LVCFMT_CENTER, 100);
m_ctrlListMain.InsertColumn(1, "名称", LVCFMT_CENTER, 100);
m_ctrlListMain.InsertColumn(2, "库存上限", LVCFMT_CENTER, 80);
m_ctrlListMain.InsertColumn(3, "库存下限", LVCFMT_CENTER, 80);
m_ctrlListMain.InsertColumn(4, "进货价", LVCFMT_CENTER, 70);
m_ctrlListMain.InsertColumn(5, "库存", LVCFMT_CENTER, 50);
m_ctrlListMain.InsertColumn(6, "数量", 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 CDlgImport::OnProviderfind()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CDlgAll dlgAll;
dlgAll.strTitle = "供应商";
dlgAll.strSQL = "SELECT * FROM ProviderInfo";
dlgAll.intKey = 3;
if (m_strCode == "")
{
MessageBox("请先开单!", "提示", MB_OK | MB_ICONINFORMATION);
return;
}
if (dlgAll.DoModal() == IDOK)
{
m_strProvider = dlgAll.strKey;
UpdateData(FALSE);
}
}
void CDlgImport::OnCommodityfind()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CADOConn adoFind;
CDlgAll dlgAll;
CString strSQL;
if (m_strCode == "")
{
MessageBox("请先开单!", "提示", MB_OK | MB_ICONINFORMATION);
return;
}
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_strSearchCode + "' OR CommodityInfo.commoditycode = '";
strSQL = strSQL + m_strSearchCode + "' OR CommodityInfo.spellcode = '";
strSQL = strSQL + m_strSearchCode + "'";
dlgAll.strTitle = "商品基本信息";
dlgAll.strSQL = strSQL;
dlgAll.intKey = 0;
if (dlgAll.DoModal() == IDOK)
{
strSQL = "SELECT CommodityInfo.barcode, CommodityInfo.name, CommodityInfo.maxnum, ";
strSQL = strSQL + "CommodityInfo.minnum, StoreInfo.stockprice, StoreInfo.num FROM CommodityInfo INNER JOIN StoreInfo ON ";
strSQL = strSQL + "CommodityInfo.barcode = StoreInfo.barcode WHERE CommodityInfo.barcode = '";
strSQL = strSQL + dlgAll.strKey + "'";
adoFind.Open(strSQL);
//adoFind.InitList(&m_ctrlListMain);
adoFind.FillList(&m_ctrlListMain);
m_ctrlListMain.SetItemText(0, 6, "1");
m_fltPrice = atof(m_ctrlListMain.GetItemText(0, 4));
m_iNum = atoi(m_ctrlListMain.GetItemText(0, 6));
m_fltAmount = m_fltAmount + m_fltPrice * m_iNum;
UpdateData(FALSE);
}
}
void CDlgImport::OnDeletecommodity()
{
// TODO: Add your control notification handler code here
POSITION pos;
int index;
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
m_fltAmount = m_fltAmount - atof(m_ctrlListMain.GetItemText(index, 4)) * atoi(m_ctrlListMain.GetItemText(index, 6));
m_ctrlListMain.DeleteItem(index);
}
void CDlgImport::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);
UpdateData(FALSE);
*pResult = 0;
}
void CDlgImport::OnStockbill()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CMyTime myTime;
m_strCode = myTime.GetSimpleString();
m_strBillDate = myTime.GetDateString(FALSE);
m_fltPrice = 0;
m_fltAmount = 0;
m_iNum = 0;
UpdateData(FALSE);
}
void CDlgImport::OnStocksave()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
POSITION pos;
int index;
CString strNum, strPrice;
strNum.Format(_T("%d"), m_iNum);
strPrice.Format(_T("%0.2f"), m_fltPrice);
pos = m_ctrlListMain.GetFirstSelectedItemPosition();
index = m_ctrlListMain.GetNextSelectedItem(pos);
m_fltAmount = m_fltAmount - atof(m_ctrlListMain.GetItemText(index, 4)) * atoi(m_ctrlListMain.GetItemText(index, 6));
m_ctrlListMain.SetItemText(index, 6, strNum);
m_ctrlListMain.SetItemText(index, 4, strPrice);
m_fltAmount = m_fltAmount + atof(m_ctrlListMain.GetItemText(index, 4)) * atoi(m_ctrlListMain.GetItemText(index, 6));
UpdateData(FALSE);
}
void CDlgImport::OnUpdate()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString strSQL, strTemp;
CADOConn adoStockBill, adoStockCommodity, adoStoreInfo;
strSQL = "INSERT INTO StockBill VALUES ('";
strSQL = strSQL + m_strCode + "', '";
strSQL = strSQL + m_strBillDate + "', '";
strSQL = strSQL + m_strBiller + "', '";
strSQL = strSQL + m_strProvider + "', '";
strSQL = strSQL + m_strNote + "')";
adoStockBill.ExecuteSQL(strSQL);
for(int i = 0; i < m_ctrlListMain.GetItemCount(); i++)
{
strSQL = "INSERT INTO StockCommodity VALUES ('";
strSQL = strSQL + m_strCode + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(i, 0) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(i, 4) + "', '";
strSQL = strSQL + m_ctrlListMain.GetItemText(i, 6) + "')";
adoStockCommodity.ExecuteSQL(strSQL);
int num = atoi(m_ctrlListMain.GetItemText(i, 5)) + atoi(m_ctrlListMain.GetItemText(i, 6));
strSQL = "UPDATE StoreInfo SET num = '";
strTemp.Format(_T("%d"), num);
strSQL = strSQL + strTemp + "' WHERE barcode = '";
strSQL = strSQL + m_ctrlListMain.GetItemText(i, 0) + "'";
adoStoreInfo.ExecuteSQL(strSQL);
}
}
void CDlgImport::OnStockaccount()
{
// TODO: Add your control notification handler code here
m_strCode = "";
m_strBillDate = "";
m_strBiller = "";
m_fltPrice = 0;
m_iNum = 0;
m_ctrlListMain.DeleteAllItems();
UpdateData(FALSE);
}
商店管理系统源代码(十一)
最新推荐文章于 2018-12-10 12:13:14 发布