DlgDanganBase.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:12k
- // DlgDanganBase.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ncshop.h"
- #include "DlgDanganBase.h"
- #include "ADOConn.h"
- #include "DlgAll.h"
- #include "MyChiToLetter.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgDanganBase dialog
- CDlgDanganBase::CDlgDanganBase(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgDanganBase::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgDanganBase)
- m_str1 = _T("");
- m_str2 = _T("");
- m_str3 = _T("");
- m_str4 = _T("");
- m_str5 = _T("");
- m_str6 = _T("");
- m_str7 = _T("");
- m_str8 = _T("");
- m_dbl10 = 0.0;
- m_dbl9 = 0.0;
- m_dbl11 = 0.0;
- m_dbl12 = 0.0;
- m_dbl13 = 0.0;
- m_dbl14 = 0.0;
- m_dbl15 = 0.0;
- m_str16 = _T("");
- //}}AFX_DATA_INIT
- }
- void CDlgDanganBase::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgDanganBase)
- DDX_Control(pDX, IDC_LIST1, m_listMain);
- DDX_Control(pDX, IDC_BUTTON1, m_Btn5);
- DDX_Control(pDX, IDMODIFY, m_Btn2);
- DDX_Control(pDX, IDDEL2, m_Btn3);
- DDX_Control(pDX, IDC_BTNFIND, m_Btn4);
- DDX_Control(pDX, IDADD2, m_Btn1);
- DDX_Text(pDX, IDC_EDIT1, m_str1);
- DDV_MaxChars(pDX, m_str1, 255);
- DDX_Text(pDX, IDC_EDIT2, m_str2);
- DDV_MaxChars(pDX, m_str2, 50);
- DDX_Text(pDX, IDC_EDIT3, m_str3);
- DDV_MaxChars(pDX, m_str3, 50);
- DDX_Text(pDX, IDC_EDIT4, m_str4);
- DDV_MaxChars(pDX, m_str4, 50);
- DDX_Text(pDX, IDC_EDIT5, m_str5);
- DDV_MaxChars(pDX, m_str5, 50);
- DDX_Text(pDX, IDC_EDIT6, m_str6);
- DDV_MaxChars(pDX, m_str6, 50);
- DDX_Text(pDX, IDC_EDIT7, m_str7);
- DDV_MaxChars(pDX, m_str7, 50);
- DDX_Text(pDX, IDC_EDIT8, m_str8);
- DDV_MaxChars(pDX, m_str8, 5);
- DDX_Text(pDX, IDC_EDIT10, m_dbl10);
- DDX_Text(pDX, IDC_EDIT9, m_dbl9);
- DDX_Text(pDX, IDC_EDIT11, m_dbl11);
- DDX_Text(pDX, IDC_EDIT12, m_dbl12);
- DDX_Text(pDX, IDC_EDIT13, m_dbl13);
- DDX_Text(pDX, IDC_EDIT14, m_dbl14);
- DDX_Text(pDX, IDC_EDIT15, m_dbl15);
- DDX_Text(pDX, IDC_EDIT16, m_str16);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgDanganBase, CDialog)
- //{{AFX_MSG_MAP(CDlgDanganBase)
- ON_BN_CLICKED(IDC_BTNFIND, OnBtnfind)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
- ON_BN_CLICKED(IDADD2, OnAdd2)
- ON_BN_CLICKED(IDMODIFY, OnModify)
- ON_BN_CLICKED(IDDEL2, OnDel2)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_EN_KILLFOCUS(IDC_EDIT6, OnKillfocusEdit6)
- ON_EN_CHANGE(IDC_EDIT6, OnChangeEdit6)
- ON_EN_UPDATE(IDC_EDIT6, OnUpdateEdit6)
- ON_EN_CHANGE(IDC_EDIT11, OnChangeEdit11)
- ON_EN_KILLFOCUS(IDC_EDIT11, OnKillfocusEdit11)
- ON_EN_UPDATE(IDC_EDIT11, OnUpdateEdit11)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgDanganBase message handlers
- void CDlgDanganBase::OnBtnfind()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- CADOConn adoMain;
- CString strSql;
- strSql="SELECT 商品档案基本信息表.*, 商品库存数量统计表.进货价, 商品库存数量统计表.零售价,";
- strSql=strSql+"商品库存数量统计表.会员价, 商品库存数量统计表.业务提成, " ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码 where 商品档案基本信息表.条形码='";
- strSql=strSql+m_str16+"' or 商品档案基本信息表.商品编码='";
- strSql=strSql+m_str16+"' or 商品档案基本信息表.助记码='";
- strSql=strSql+m_str16+"' or 商品档案基本信息表.拼音码='";
- strSql=strSql+m_str16+"'";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,15);
- adoMain.ExitConnect();
- m_listMain.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_str7="";
- m_str8="";
- m_dbl9=0;
- m_dbl10=0;
- m_dbl11=0;
- m_dbl12=0;
- m_dbl13=0;
- m_dbl14=0;
- m_dbl15=0;
- UpdateData(FALSE);
- }
- BOOL CDlgDanganBase::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CADOConn adoMain;
- CString strSql;
- strSql="SELECT 商品档案基本信息表.*, 商品库存数量统计表.进货价, 商品库存数量统计表.零售价,";
- strSql=strSql+"商品库存数量统计表.会员价, 商品库存数量统计表.业务提成, " ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码";
- adoMain.Open(strSql);
- adoMain.InitList(&m_listMain,15);
- adoMain.FillList(&m_listMain,2);
- m_Btn1.SetXIcon(IDI_ICONBUTTON);
- m_Btn2.SetXIcon(IDI_ICONBUTTON);
- m_Btn3.SetXIcon(IDI_ICONBUTTON);
- m_Btn4.SetXIcon(IDI_ICONFIND);
- m_Btn5.SetXIcon(IDI_ICONALL);
- GetDlgItem(IDC_STATIC2)->SetFont(&ftHeader,TRUE);
- adoMain.ExitConnect();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgDanganBase::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- int i;
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- m_str1=m_listMain.GetItemText(i,0);
- m_str2=m_listMain.GetItemText(i,1);
- m_str3=m_listMain.GetItemText(i,2);
- m_str4=m_listMain.GetItemText(i,3);
- m_str5=m_listMain.GetItemText(i,4);
- m_str6=m_listMain.GetItemText(i,5);
- m_str7=m_listMain.GetItemText(i,6);
- m_str8=m_listMain.GetItemText(i,7);
- m_dbl9=atof(m_listMain.GetItemText(i,8));
- m_dbl10=atof(m_listMain.GetItemText(i,9));
- m_dbl11=atof(m_listMain.GetItemText(i,10));
- m_dbl12=atof(m_listMain.GetItemText(i,11));
- m_dbl13=atof(m_listMain.GetItemText(i,12));
- m_dbl14=atof(m_listMain.GetItemText(i,13));
- m_dbl15=atof(m_listMain.GetItemText(i,14));
- UpdateData(FALSE);
- }
- *pResult = 0;
- }
- void CDlgDanganBase::OnAdd2()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain;
- CString strSql;
- int i=0;
- UpdateData(TRUE);
- strSql="insert into 商品档案基本信息表(条形码) values('')";
- adoMain.ExecuteSQL(strSql);
- strSql="insert into 商品库存数量统计表(条形码) values('')";
- adoMain.ExecuteSQL(strSql);
- strSql="SELECT 商品档案基本信息表.*, 商品库存数量统计表.进货价, 商品库存数量统计表.零售价,";
- strSql=strSql+"商品库存数量统计表.会员价, 商品库存数量统计表.业务提成, " ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,15);
- m_listMain.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_str7="";
- m_str8="";
- m_dbl9=0;
- m_dbl10=0;
- m_dbl11=0;
- m_dbl12=0;
- m_dbl13=0;
- m_dbl14=0;
- m_dbl15=0;
- UpdateData(FALSE);
- adoMain.ExitConnect();
- }
- void CDlgDanganBase::OnModify()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain;
- CString strSql,str;
- POSITION pos;
- int i;
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- str=m_listMain.GetItemText(i,1);
- }
- UpdateData(TRUE);
- strSql="update 商品档案基本信息表 set 分类编号='";
- strSql=strSql+m_str1+"',条形码='";
- strSql=strSql+m_str2+"',商品编码='";
- strSql=strSql+m_str3+"',助记码='";
- strSql=strSql+m_str4+"',拼音码='";
- strSql=strSql+m_str5+"',名称='";
- strSql=strSql+m_str6+"',规格='";
- strSql=strSql+m_str7+"',单位='";
- strSql=strSql+m_str8+"',库存上限=";
- str.Format("%f",m_dbl9);
- strSql=strSql+str+",库存下限=";
- str.Format("%f",m_dbl10);
- strSql=strSql+str+" ";
- str=m_listMain.GetItemText(i,1);
- strSql=strSql+" where 条形码='"+str+"'";
- adoMain.ExecuteSQL(strSql);
- strSql="update 商品库存数量统计表 set 条形码='";
- strSql=strSql+m_str2+"',进货价=";
- str.Format("%f",m_dbl11);
- strSql=strSql+str+",零售价=";
- str.Format("%f",m_dbl12);
- strSql=strSql+str+",会员价=";
- str.Format("%f",m_dbl13);
- strSql=strSql+str+",业务提成=";
- str.Format("%f",m_dbl14);
- strSql=strSql+str+",库存=";
- str.Format("%f",m_dbl15);
- strSql=strSql+str;
- str=m_listMain.GetItemText(i,1);
- strSql=strSql+" where 条形码='"+str+"'";
- adoMain.ExecuteSQL(strSql);
- strSql="SELECT 商品档案基本信息表.*, 商品库存数量统计表.进货价, 商品库存数量统计表.零售价,";
- strSql=strSql+"商品库存数量统计表.会员价, 商品库存数量统计表.业务提成, " ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,15);
- while(m_listMain.GetItemText(i,1)!=m_str2&&i<m_listMain.GetItemCount())
- {
- i++;
- }
- if(m_listMain.GetItemCount()>0)
- m_listMain.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- adoMain.ExitConnect();
- }
- void CDlgDanganBase::OnDel2()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain,adoFile;
- CString strSql;
- POSITION pos;
- int i;
- UINT j=0;
- pos=m_listMain.GetFirstSelectedItemPosition();
- i=m_listMain.GetNextSelectedItem(pos);
- if (i>=0)
- {
- if(MessageBox("确信删除这些信息吗?","提示",MB_YESNO|MB_ICONQUESTION)==IDNO) return;
- while(j<m_listMain.GetSelectedCount()&&i<m_listMain.GetItemCount())
- {
- if(m_listMain.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
- {
- strSql="delete * from 商品档案基本信息表 where 条形码='"+m_listMain.GetItemText(i,1)+"'";
- adoMain.ExecuteSQL(strSql);
- strSql="delete * from 商品库存数量统计表 where 条形码='"+m_listMain.GetItemText(i,1)+"'";
- adoMain.ExecuteSQL(strSql);
- j=j+1;
- }
- i=i+1;
- }
- }
- adoMain.ExitConnect();
- strSql="SELECT 商品档案基本信息表.*, 商品库存数量统计表.进货价, 商品库存数量统计表.零售价,";
- strSql=strSql+"商品库存数量统计表.会员价, 商品库存数量统计表.业务提成, " ;
- strSql=strSql+"商品库存数量统计表.库存 FROM 商品档案基本信息表 INNER JOIN 商品库存数量统计表 ON ";
- strSql=strSql+"商品档案基本信息表.条形码 = 商品库存数量统计表.条形码";
- adoFile.Open(strSql);
- adoFile.FillList(&m_listMain,2);
- adoFile.ExitConnect();
- m_listMain.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_str7="";
- m_str8="";
- m_dbl9=0;
- m_dbl10=0;
- m_dbl11=0;
- m_dbl12=0;
- m_dbl13=0;
- m_dbl14=0;
- m_dbl15=0;
- UpdateData(FALSE);
- }
- void CDlgDanganBase::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_str1=dlg.strKey;
- UpdateData(FALSE);
- }
- }
- void CDlgDanganBase::OnKillfocusEdit6()
- {
- // TODO: Add your control notification handler code here
- CMyChiToLetter ch1;
- UpdateData(TRUE);
- ch1.m_blnAllBiG=TRUE;
- ch1.m_blnSimaple=TRUE;
- m_str5=ch1.GetLetter(m_str6);
- UpdateData(FALSE);
- }
- void CDlgDanganBase::OnChangeEdit6()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
-
- // TODO: Add your control notification handler code here
- OnKillfocusEdit6();
- }
- void CDlgDanganBase::OnUpdateEdit6()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function to send the EM_SETEVENTMASK message to the control
- // with the ENM_UPDATE flag ORed into the lParam mask.
-
- // TODO: Add your control notification handler code here
- OnKillfocusEdit6();
- }
- void CDlgDanganBase::OnChangeEdit11()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
-
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- m_dbl12=m_dbl11;
- m_dbl13=m_dbl11;
- m_dbl14=m_dbl11;
- UpdateData(FALSE);
- }
- void CDlgDanganBase::OnKillfocusEdit11()
- {
- // TODO: Add your control notification handler code here
- OnChangeEdit11();
- }
- void CDlgDanganBase::OnUpdateEdit11()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function to send the EM_SETEVENTMASK message to the control
- // with the ENM_UPDATE flag ORed into the lParam mask.
-
- // TODO: Add your control notification handler code here
- OnChangeEdit11();
- }