DlgXiaoShouKanDan.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:11k
源码类别:
百货/超市行业
开发平台:
Visual C++
- // DlgXiaoShouKanDan.cpp : implementation file
- // Download by http://www.codefans.net
- #include "stdafx.h"
- #include "ncshop.h"
- #include "DlgXiaoShouKanDan.h"
- #include "ADOConn.h"
- #include "MyTime.h"
- #include "DlgAll.h"
- #include "DlgPrint.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgXiaoShouKanDan dialog
- CDlgXiaoShouKanDan::CDlgXiaoShouKanDan(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgXiaoShouKanDan::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgXiaoShouKanDan)
- // NOTE: the ClassWizard will add member initialization here
- m_str1 = _T("");
- m_str2 = _T("");
- m_str8 = _T("");
- m_str3 = _T("");
- m_str4 = _T("");
- m_str5 = _T("");
- m_flt6 = 0.0f;
- m_flt7 = 0.0f;
- //}}AFX_DATA_INIT
- }
- void CDlgXiaoShouKanDan::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgXiaoShouKanDan)
- DDX_Control(pDX, IDC_BUTTON8, m_Btn10);
- DDX_Control(pDX, IDC_BUTTON5, m_Btn9);
- DDX_Control(pDX, IDC_BUTTON2, m_Btn2);
- DDX_Control(pDX, IDC_BUTTON4, m_Btn8);
- DDX_Control(pDX, IDC_LIST1, m_listMain);
- DDX_Control(pDX, IDFIND, m_Btn6);
- DDX_Control(pDX, IDDEL, m_Btn5);
- DDX_Control(pDX, IDCANCEL, m_Btn4);
- DDX_Control(pDX, IDC_BUTTON3, m_Btn3);
- DDX_Control(pDX, IDC_BUTTON1, m_Btn1);
- DDX_Text(pDX, IDC_EDIT1, m_str1);
- DDX_Text(pDX, IDC_EDIT2, m_str2);
- DDX_Text(pDX, IDC_EDIT20, m_str8);
- DDX_Text(pDX, IDC_EDIT3, m_str3);
- DDX_Text(pDX, IDC_EDIT4, m_str4);
- DDX_Text(pDX, IDC_EDIT5, m_str5);
- DDX_Text(pDX, IDC_EDIT16, m_flt6);
- DDX_Text(pDX, IDC_EDIT18, m_flt7);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgXiaoShouKanDan, CDialog)
- //{{AFX_MSG_MAP(CDlgXiaoShouKanDan)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDFIND, OnFind)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDDEL, OnDel)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
- ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgXiaoShouKanDan message handlers
- BOOL CDlgXiaoShouKanDan::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CString strSql;
- m_Btn1.SetXIcon(IDI_ICONALL);
- m_Btn2.SetXIcon(IDI_ICONALL);
- m_Btn3.SetXIcon(IDI_ICONBUTTON);
- m_Btn4.SetXIcon(IDI_ICONBUTTON);
- m_Btn5.SetXIcon(IDI_ICONBUTTON);
- m_Btn6.SetXIcon(IDI_ICONFIND);
- m_Btn8.SetXIcon(IDI_ICONBUTTON);
- m_Btn9.SetXIcon(IDI_ICONBUTTON);
- m_Btn10.SetXIcon(IDI_ICONBUTTON);
- m_listMain.InsertColumn(0,"条形码",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(1,"名称",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(2,"库存上限",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(3,"库存下限",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(4,"销售价",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(5,"库存",LVCFMT_CENTER,100);
- m_listMain.InsertColumn(6,"数量",LVCFMT_CENTER,100);
- m_listMain.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
- GetDlgItem(IDC_STATIC1)->SetFont(&ftHeader,TRUE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgXiaoShouKanDan::OnButton4()
- {
- // TODO: Add your control notification handler code here
- int i;
- CString strSql,str;
- CADOConn adoMain;
- CMyTime time1;
- if(m_str1!="")
- {
- for(i=0;i<m_listMain.GetItemCount();i++)
- {
- strSql="update 商品库存数量统计表 set 库存=";
- str.Format("%0.2f",atof(m_listMain.GetItemText(i,5))-atof(m_listMain.GetItemText(i,6)));
- strSql=strSql+str+" where 条形码='";
- strSql=strSql+m_listMain.GetItemText(i,0)+"'";
- adoMain.ExecuteSQL(strSql);
- }
- }
- time1.SetNow();
- m_str1=time1.GetSimpleString();
- m_str2=time1.GetDateString(FALSE);
- m_str3="";
- m_str4="";
- m_str5="";
- m_flt6=0;
- m_flt7=0;
- UpdateData(FALSE);
- strSql="insert into 销售单统计表(单编号,开票日期) values('";
- strSql=strSql+m_str1+"','";
- strSql=strSql+m_str2+"')";
- adoMain.ExecuteSQL(strSql);
- adoMain.ExitConnect();
- m_listMain.DeleteAllItems();
- }
- void CDlgXiaoShouKanDan::OnButton2()
- {
- // TODO: Add your control notification handler code here
- CDlgAll dlg;
- UpdateData(TRUE);
- dlg.strTitle="管理员基本信息表";
- dlg.strSql="select 编号,姓名 from 管理员基本信息表";
- dlg.intOpen=2;
- if(dlg.DoModal()==IDOK)
- {
- m_str3=dlg.strKey;
- UpdateData(FALSE);
- }
- }
- void CDlgXiaoShouKanDan::OnFind()
- {
- // TODO: Add your control notification handler code heres
- UpdateData(TRUE);
- if(m_str1=="")
- {
- MessageBox("请先开单,后加载商品!","提示",MB_OK|MB_ICONWARNING);
- return;
- }
- CADOConn adoMain;
- CString strSql,str;
- CDlgAll dlg;
- int i=0;
- strSql="SELECT 商品档案基本信息表.条形码, 商品档案基本信息表.名称,";
- strSql=strSql+"商品档案基本信息表.库存上限, 商品档案基本信息表.库存下限";
- strSql=strSql+",商品库存数量统计表.进货价," ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码 where 商品档案基本信息表.条形码='";
- strSql=strSql+m_str8+"' or 商品档案基本信息表.商品编码='";
- strSql=strSql+m_str8+"' or 商品档案基本信息表.助记码='";
- strSql=strSql+m_str8+"' or 商品档案基本信息表.拼音码='";
- strSql=strSql+m_str8+"'";
- dlg.strTitle="商品档案基本信息";
- dlg.strSql=strSql;
- dlg.intOpen=6;
- dlg.intKey=0;
- if(dlg.DoModal()==IDOK)
- {
- while(i<m_listMain.GetItemCount()&&m_listMain.GetItemText(i,0)!=dlg.strKey)
- {
- i=i+1;
- }
- if(i<m_listMain.GetItemCount())
- {
- MessageBox("表中已经存在此商品!","提示",MB_OK|MB_ICONWARNING);
- return;
- }
- if(i==m_listMain.GetItemCount())
- {
- if(m_listMain.GetItemText(i,0)==dlg.strKey)
- {
- MessageBox("表中已经存在此商品!","提示",MB_OK|MB_ICONWARNING);
- return;
- }
- }
- strSql="SELECT 商品档案基本信息表.条形码, 商品档案基本信息表.名称,";
- strSql=strSql+"商品档案基本信息表.库存上限, 商品档案基本信息表.库存下限";
- strSql=strSql+",商品库存数量统计表.零售价," ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码 where 商品档案基本信息表.条形码='";
- strSql=strSql+dlg.strKey+"'";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain);
- strSql="insert into 销售商品管理表(单编号,条形码,销售单价,数量) values('";
- strSql=strSql+m_str1+"','";
- strSql=strSql+dlg.strKey+"',";
- strSql=strSql+m_listMain.GetItemText(0,4)+",1)";
- adoMain.ExecuteSQL(strSql);
- m_listMain.SetItemText(0,6,"1");
- }
- adoMain.ExitConnect();
- }
- void CDlgXiaoShouKanDan::OnButton1()
- {
- // TODO: Add your control notification handler code here
- CDlgAll dlg;
- UpdateData(TRUE);
- dlg.strTitle="分机基本信息表";
- dlg.strSql="select * from 分机基本信息表";;
- dlg.intOpen=3;
- if(dlg.DoModal()==IDOK)
- {
- m_str4=dlg.strKey;
- UpdateData(FALSE);
- }
- }
- void CDlgXiaoShouKanDan::OnDel()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain,adoFile;
- CString strSql;
- POSITION pos;
- int i;
- UINT j=0;
- UpdateData(TRUE);
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- if(MessageBox("确信删除这些信息吗?","提示",MB_YESNO|MB_ICONQUESTION)==IDNO) return;
- i=m_listMain.GetItemCount();
- while(j<m_listMain.GetSelectedCount()&&i>=0)
- {
- if(m_listMain.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
- {
- strSql="delete * from 销售商品管理表 where 单编号='";
- strSql=strSql+m_str1+"' and 条形码='";
- strSql=strSql+m_listMain.GetItemText(i,0)+"'";
- adoMain.ExecuteSQL(strSql);
- m_listMain.DeleteItem(i);
- j=j+1;
- }
- i=i-1;
- }
- }
- adoMain.ExitConnect();
- m_flt6=0;
- m_flt7=0;
- UpdateData(FALSE);
- }
- void CDlgXiaoShouKanDan::OnButton3()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- if(m_str1=="")
- {
- MessageBox("请先开单,后加载商品!","提示",MB_OK|MB_ICONWARNING);
- return;
- }
- POSITION pos;
- CString str;
- int i;
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- str.Format("%0.2f",m_flt6);
- m_listMain.SetItemText(i,4,str);
- str.Format("%0.2f",m_flt7);
- m_listMain.SetItemText(i,6,str);
- UpdateData(FALSE);
- }
- CString strSql;
- CADOConn adoMain;
- double dbl=0;
- strSql="update 销售单统计表 set 开票日期='";
- strSql=strSql+m_str2+"',经办人='";
- strSql=strSql+m_str3+"',分机号='";
- strSql=strSql+m_str4+"',备注='";
- strSql=strSql+m_str5+"' where 单编号='";
- strSql=strSql+m_str1+"'";
- adoMain.ExecuteSQL(strSql);
- for(i=0;i<m_listMain.GetItemCount();i++)
- {
- strSql="update 销售商品管理表 set 销售单价=";
- strSql=strSql+m_listMain.GetItemText(i,4)+",数量=";
- strSql=strSql+m_listMain.GetItemText(i,6)+" where 单编号='";
- strSql=strSql+m_str1+"' and 条形码='";
- strSql=strSql+m_listMain.GetItemText(i,0)+"'";
- adoMain.ExecuteSQL(strSql);
- }
- for(i=0;i<m_listMain.GetItemCount();i++)
- {
- dbl=dbl+atof(m_listMain.GetItemText(i,4))*atof(m_listMain.GetItemText(i,6));
- }
- str.Format("%0.2f",dbl);
- GetDlgItem(IDC_EDIT19)->SetWindowText(str);
- adoMain.ExitConnect();
- }
- void CDlgXiaoShouKanDan::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- POSITION pos;
- int i;
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- m_flt6=atof(m_listMain.GetItemText(i,4));
- m_flt7=atof(m_listMain.GetItemText(i,6));
- UpdateData(FALSE);
- }
- *pResult = 0;
- }
- void CDlgXiaoShouKanDan::OnButton5()
- {
- // TODO: Add your control notification handler code here
- int i;
- CString strSql,str;
- CADOConn adoMain;
- if(m_str1!="")
- {
- for(i=0;i<m_listMain.GetItemCount();i++)
- {
- strSql="update 商品库存数量统计表 set 库存=";
- str.Format("%0.2f",atof(m_listMain.GetItemText(i,5))-atof(m_listMain.GetItemText(i,6)));
- strSql=strSql+str+" where 条形码='";
- strSql=strSql+m_listMain.GetItemText(i,0)+"'";
- adoMain.ExecuteSQL(strSql);
- }
- }
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_flt6=0;
- m_flt7=0;
- UpdateData(FALSE);
- m_listMain.DeleteAllItems();
- }
- void CDlgXiaoShouKanDan::OnButton8()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- CDlgPrint dlg;
- dlg.strTitle=m_str1;
- dlg.strSql="SELECT '' as 条形码,'' as 名称,'' as 库存上限,'' as 库存下限,'' as 销售价,'' as 库存,'' as 数量";
- dlg.strSql=dlg.strSql+" from 商品库存数量统计表";
- dlg.m_ListMain=&m_listMain;
- dlg.DoModal();
- }