![pos机管理系统软件源代码和pos机管理系统软件操作说明书_第1页](http://file4.renrendoc.com/view/edb1bf44b7ef2f4571b1ef7391070523/edb1bf44b7ef2f4571b1ef73910705231.gif)
![pos机管理系统软件源代码和pos机管理系统软件操作说明书_第2页](http://file4.renrendoc.com/view/edb1bf44b7ef2f4571b1ef7391070523/edb1bf44b7ef2f4571b1ef73910705232.gif)
![pos机管理系统软件源代码和pos机管理系统软件操作说明书_第3页](http://file4.renrendoc.com/view/edb1bf44b7ef2f4571b1ef7391070523/edb1bf44b7ef2f4571b1ef73910705233.gif)
![pos机管理系统软件源代码和pos机管理系统软件操作说明书_第4页](http://file4.renrendoc.com/view/edb1bf44b7ef2f4571b1ef7391070523/edb1bf44b7ef2f4571b1ef73910705234.gif)
![pos机管理系统软件源代码和pos机管理系统软件操作说明书_第5页](http://file4.renrendoc.com/view/edb1bf44b7ef2f4571b1ef7391070523/edb1bf44b7ef2f4571b1ef73910705235.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#if!defined(AFX_CLASSDLG_H__B6736001_C0BF_47D8_8A7A_A2540CC35379__INCLUDED_)#defineAFX_CLASSDLG_H__B6736001_C0BF_47D8_8A7A_A2540CC35379__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_VER>1000//ClassDlg.h:headerfile/////////////////////////////////////////////////////////////////////////////////CClassDlgdialogclassCClassDlg:publicCDialog{//Constructionpublic: intCountMateriel(CStringsclassid); CClassDlg(CWnd*pParent=NULL);//standardconstructor staticCStringVariantToCString(VARIANTvar); staticintTreeSumRecordCount(CStringstrFieldValue);//DialogData //{{AFX_DATA(CClassDlg) enum{IDD=IDD_DIALOG_CLASS}; CButton m_oRadiodiscount; CEdit m_oClassname; CTreeCtrl m_oTreeclass; CString m_classname; int m_radiodiscount; long m_tempid; //}}AFX_DATA//Overrides //ClassWizardgeneratedvirtualfunctionoverrides //{{AFX_VIRTUAL(CClassDlg) protected: virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport //}}AFX_VIRTUAL//Implementationprotected: //Generatedmessagemapfunctions //{{AFX_MSG(CClassDlg) afx_msgvoidOnSelchangedTreeClass(NMHDR*pNMHDR,LRESULT*pResult); virtualBOOLOnInitDialog(); afx_msgvoidOnButtonAddsame(); afx_msgvoidOnButtonAddsub(); afx_msgvoidOnButtonDel(); afx_msgvoidOnButtonSave(); //}}AFX_MSG DECLARE_MESSAGE_MAP()private: intGenNewID();//GenerateanewrecordID. voidAddSubTree(CStringParTree,HTREEITEMhPartItem); voidAddTree(); BOOLbRepeat(CStringstrFieldValue); HTREEITEMhCurrentItem,hParentItem; CStringCurpar;};//{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_CLASSDLG_H__B6736001_C0BF_47D8_8A7A_A2540CC35379__INCLUDED_)//ClassDlg.cpp:implementationfile//#include"stdafx.h"#include"MyPos.h"#include"ClassDlg.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CClassDlgdialogexternCMyPosApptheApp;CClassDlg::CClassDlg(CWnd*pParent/*=NULL*/) :CDialog(CClassDlg::IDD,pParent){ //{{AFX_DATA_INIT(CClassDlg) m_classname=_T(""); m_radiodiscount=-1; m_tempid=0; //}}AFX_DATA_INIT}voidCClassDlg::DoDataExchange(CDataExchange*pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CClassDlg) DDX_Control(pDX,IDC_RADIO1_DISCOUNT,m_oRadiodiscount); DDX_Control(pDX,IDC_EDIT_CLASSNAME,m_oClassname); DDX_Control(pDX,IDC_TREE_CLASS,m_oTreeclass); DDX_Text(pDX,IDC_EDIT_CLASSNAME,m_classname); DDX_Radio(pDX,IDC_RADIO1_DISCOUNT,m_radiodiscount); DDX_Text(pDX,IDC_TEMPID,m_tempid); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CClassDlg,CDialog) //{{AFX_MSG_MAP(CClassDlg) ON_NOTIFY(TVN_SELCHANGED,IDC_TREE_CLASS,OnSelchangedTreeClass) ON_BN_CLICKED(IDC_BUTTON_ADDSAME,OnButtonAddsame) ON_BN_CLICKED(IDC_BUTTON_ADDSUB,OnButtonAddsub) ON_BN_CLICKED(IDC_BUTTON_DEL,OnButtonDel) ON_BN_CLICKED(IDC_BUTTON_SAVE,OnButtonSave) //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CClassDlgmessagehandlersvoidCClassDlg::OnSelchangedTreeClass(NMHDR*pNMHDR,LRESULT*pResult){ NM_TREEVIEW*pNMTreeView=(NM_TREEVIEW*)pNMHDR; CStringsql; CStringcurtext; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!! HTREEITEMhCurItem; hCurItem=m_oTreeclass.GetSelectedItem();//GetCurrentitemanditssubitems. curtext=m_oTreeclass.GetItemText(hCurItem);//Readcurrentitemtextintoeditcontrol. m_classname=curtext; sql="SELECT*FROMMATERIELCLASSwhereNAME='"+curtext+"'"; try { m_tempid=0; m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText); if(!m_pRecordset->adoEOF) { m_tempid=(long)(m_pRecordset->GetCollect("ID")); Curpar=VariantToCString(m_pRecordset->GetCollect("PARENT")); if((float)(m_pRecordset->GetCollect("DISCOUNT"))==0) m_radiodiscount=0; if((float)(m_pRecordset->GetCollect("DISCOUNT"))==1) m_radiodiscount=1; } m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringerrormessage; MessageBox("读取单选按钮出错!",m_classname); } UpdateData(false); *pResult=0;}voidCClassDlg::AddSubTree(CStringParTree,HTREEITEMhPartItem){ HTREEITEMhCurrent; CStringsql; CStringcurID; _RecordsetPtrm_pTRecordset;//Mustdefineitinfunction!!!BecoursethisisaRECURSIONfunction. sql="SELECT*FROMMATERIELCLASSwherePARENT='"; sql=sql+ParTree+"'";//The1sttimePartree="1". try { m_pTRecordset.CreateInstance("ADODB.Recordset"); m_pTRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText); m_pTRecordset->MoveFirst(); if(!m_pTRecordset->adoEOF) { while(!m_pTRecordset->adoEOF) { hCurrent=m_oTreeclass.InsertItem((LPCTSTR)(_bstr_t)(m_pTRecordset->GetCollect("NAME")),hPartItem,NULL);//Insertanitemintocurrentparent. curID=VariantToCString(m_pTRecordset->GetCollect("ID")); if(TreeSumRecordCount(curID)>0) AddSubTree(VariantToCString(m_pTRecordset->GetCollect("ID")),hCurrent);//Recursion. if(!m_pTRecordset->adoEOF) m_pTRecordset->MoveNext(); } } m_pTRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringerrormessage; MessageBox("读取类别子树出错!",ParTree); }}voidCClassDlg::AddTree(){ TVINSERTSTRUCTtvInsert; HTREEITEMhParent; _RecordsetPtrm_pTRecordset;//Mustdefineitinfunction!!!BecoursethisisaRECURSIONfunction. CStringsroot,sql; tvInsert.hParent=NULL; tvInsert.hInsertAfter=NULL; tvInsert.item.mask=TVIF_TEXT; sql="SELECT*FROMMATERIELCLASSwhereID=1"; try { m_pTRecordset.CreateInstance("ADODB.Recordset"); m_pTRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText); if(!m_pTRecordset->adoEOF) sroot=(LPTSTR)(_bstr_t)m_pTRecordset->GetCollect("NAME");//Insertanitemintocurrentparent. m_pTRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringerrormessage; errormessage.Format("读取类别树出错:%s",e.ErrorMessage()); AfxMessageBox(errormessage); }// tvInsert.item.pszText=_T("root"); if(sroot!="") {// tvInsert.item.pszText=_T("");//Userthislinetogivethetreeasumroot. hParent=m_oTreeclass.InsertItem(&tvInsert);//HTREEITEMofroot.// AddSubTree("1",hParent);//HerestrChildTreejustmustnotequal"root",canbeanyotherstring. AddSubTree("RootClass",hParent);//HerestrChildTreejustmustnotequal"root",canbeanyotherstring. } m_oTreeclass.Expand(hParent,TVE_EXPAND);}intCClassDlg::TreeSumRecordCount(CStringstrFieldValue){ intSum=0; CStringsql; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! sql="SELECT*FROMMATERIELCLASSwherePARENT='"; sql=sql+strFieldValue+"'"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText); if(!m_pRecordset->BOF)//Ifcurrentrecordisnotthefirstrecord. { m_pRecordset->MoveFirst(); while(!m_pRecordset->adoEOF) { Sum+=1; m_pRecordset->MoveNext(); } } m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringstemp; stemp.Format("计算类别总数出错:%s",e.ErrorMessage()); AfxMessageBox(stemp); } returnSum;}CStringCClassDlg::VariantToCString(VARIANTvar){ CStringstrValue; _variant_tvar_t; _bstr_tbst_t; time_tcur_time; CTimetime_value; COleCurrencyvar_currency; switch(var.vt) { caseVT_EMPTY:strValue=_T("");break; caseVT_UI1:strValue.Format("%d",var.bVal);break; caseVT_I2:strValue.Format("%d",var.iVal);break; caseVT_I4:strValue.Format("%d",var.lVal);break; caseVT_R4:strValue.Format("%f",var.fltVal);break; caseVT_R8:strValue.Format("%f",var.dblVal);break; caseVT_CY: var_currency=var; strValue=var_currency.Format(0); break; caseVT_BSTR: var_t=var; bst_t=var_t; strValue.Format("%s",(constchar*)bst_t); break; caseVT_NULL:strValue=_T("");break; caseVT_DATE: cur_time=var.date; time_value=cur_time; strValue=time_value.Format("%A,%B%d,%Y"); break; caseVT_BOOL:strValue.Format("%d",var.boolVal);break; default:strValue=_T("");break; } returnstrValue;}BOOLCClassDlg::OnInitDialog(){ CDialog::OnInitDialog(); AddTree(); returnTRUE;//returnTRUEunlessyousetthefocustoacontrol //EXCEPTION:OCXPropertyPagesshouldreturnFALSE}voidCClassDlg::OnButtonAddsame(){ CStringsql; CStringnewclassname,Newpar,snewid; longlNewID;//Getnewrecordid. _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! hParentItem=m_oTreeclass.GetParentItem(m_oTreeclass.GetSelectedItem());//Getparentitemhandle. lNewID=GenNewID();//Callthe"GenNewID"functiontogetanewID. snewid.Format("%d",lNewID); Newpar=Curpar; newclassname.Format("新类别%d",lNewID); try { _variant_tRecordsAffected; sql="InsertintoMATERIELCLASS(ID,NAME,DISCOUNT,PARENT)VALUES('"+snewid+"','"+newclassname+"','0','"+Newpar+"')"; if(lNewID==1) sql="InsertintoMATERIELCLASS(ID,NAME,DISCOUNT,PARENT)VALUES(1,'"+newclassname+"','0','RootClass')"; theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText); } catch(_com_errore)///捕捉异常 { CStringerrormessage; errormessage.Format("增加同级分类出错:%s",e.ErrorMessage()); AfxMessageBox(errormessage); } m_oClassname.SetWindowText(newclassname); m_oTreeclass.InsertItem((LPCTSTR)(_bstr_t)(newclassname),hParentItem,NULL);//Insertanitemintocurrentparent.}voidCClassDlg::OnButtonAddsub(){ CStringsql; CStringnewclassname,Newpar,snewid; longlNewID; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! hCurrentItem=m_oTreeclass.GetSelectedItem();//Getcurrentitemhandleassub'sparent. lNewID=GenNewID(); snewid.Format("%d",lNewID); Newpar.Format("%d",m_tempid); newclassname.Format("新类别%d",lNewID); try { _variant_tRecordsAffected; sql="InsertintoMATERIELCLASS(ID,NAME,DISCOUNT,PARENT)VALUES('"+snewid+"','"+newclassname+"','0','"+Newpar+"')"; if(lNewID==1) sql="InsertintoMATERIELCLASS(ID,NAME,DISCOUNT,PARENT)VALUES(1,'"+newclassname+"','0','RootClass')"; theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText); } catch(_com_errore)///捕捉异常 { CStringerrormessage; errormessage.Format("增加下级分类出错:%s",e.ErrorMessage()); AfxMessageBox(errormessage); } m_oClassname.SetWindowText(newclassname); m_oTreeclass.InsertItem((LPCTSTR)(_bstr_t)(newclassname),hCurrentItem,NULL);//Insertanitemintocurrentparent.}voidCClassDlg::OnButtonDel(){ CStringsql,curID; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! HTREEITEMhCurItem; hCurItem=m_oTreeclass.GetSelectedItem();//GetCurrentitemanditssubitems. sql="SELECT*FROMMATERIELCLASSwhereNAME='"; sql=sql+m_classname+"'"; if(AfxMessageBox("确定删除此类别吗?",MB_YESNO)==IDYES) { try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText); if(!m_pRecordset->BOF)//Ifcurrentrecordisnotthefirstrecord. { curID=VariantToCString(m_pRecordset->GetCollect("ID")); if(atol(curID)==1) { MessageBox("不能删除ID为1的类别!",m_classname); return; } if(TreeSumRecordCount(curID)==0) { if(CountMateriel(curID)>0) MessageBox("此类别下已有商品,不能删除!"); else { m_pRecordset->Delete(adAffectCurrent);///删除当前记录 m_oTreeclass.DeleteItem(hCurItem); } } if(TreeSumRecordCount(curID)>0) MessageBox("不能删除结点类别!",m_classname); } m_pRecordset->Update(); m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringerrormessage; MessageBox("删除类别出错!",m_classname); } }}voidCClassDlg::OnButtonSave(){ CStringsql,parent,name,sdiscount;//,stempid longdiscount; UpdateData(); //检查数据完整性 if(m_classname.IsEmpty()) { AfxMessageBox("类别名称不能为空!"); return; } m_oClassname.GetWindowText(name);//Getthecurrenttextinedit. if(bRepeat(name)==TRUE) { AfxMessageBox("类别名称重复!请重新输入!"); return; } if(AfxMessageBox("确定要保存修改吗?",MB_YESNO)==IDYES) { intnDiscount=GetCheckedRadioButton(IDC_RADIO1_DISCOUNT,IDC_RADIO2_DISCOUNT); switch(nDiscount)//Getifitisdiscount. { caseIDC_RADIO1_DISCOUNT: discount=0; break; caseIDC_RADIO2_DISCOUNT: discount=1; break; default: break; } sdiscount.Format("%d",discount);// stempid.Format("%d",m_tempid); try { _variant_tRecordsAffected;// sql="UpdateMATERIELCLASSsetNAME='"+name+"',DISCOUNT='"+sdiscount+"'whereID='"+stempid+"'"; sql.Format("UpdateMATERIELCLASSsetNAME='%s',DISCOUNT=%dwhereID=%d",name,discount,m_tempid);//Mustadd''!!! theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText); hCurrentItem=m_oTreeclass.GetSelectedItem();//Getcurrentitemhandleassub'sparent. m_oTreeclass.SetItemText(hCurrentItem,(LPCTSTR)(_bstr_t)(name)); } catch(_com_errore)///捕捉异常 { CStringstemp; stemp.Format("修改类别出错:%s",e.ErrorMessage());// AfxMessageBox(stemp); return; } }}BOOLCClassDlg::bRepeat(CStringstrFieldValue){ CStringsql; BOOLbr; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! sql="SELECT*FROMMATERIELCLASSWHERENAME='"; sql=sql+strFieldValue+"'"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); if(m_pRecordset->adoEOF) br=FALSE; if(!m_pRecordset->adoEOF) br=TRUE; m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringstemp; stemp.Format("查找类别名称出错:%s",e.ErrorMessage()); AfxMessageBox(stemp); } returnbr;}intCClassDlg::GenNewID(){ CStringsql; intNewID; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! sql="SELECTMax(ID)FROMMATERIELCLASS"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); _variant_tvIndex=(long)0;//Howtogetfieldvalueinonly1recordand1fieldcondition. _variant_tvtemp=m_pRecordset->GetCollect(vIndex); if(vtemp.lVal>0) NewID=(long)(m_pRecordset->GetCollect(vIndex))+1;///取得第一个字段的值(MAXID)加1后放入id变量. else NewID=1; m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringstemp; stemp.Format("获取类别ID最大值出错:%s",e.ErrorMessage()); AfxMessageBox(stemp); } returnNewID;}intCClassDlg::CountMateriel(CStringsclassid){ CStringsql; intncount; _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! sql="SELECTcount(*)asXXXFROMMATERIELwhereclassid="+sclassid+""; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); ncount=(long)m_pRecordset->GetCollect("XXX"); m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringstemp; stemp.Format("计算类别下商品数量出错:%s",e.ErrorMessage()); AfxMessageBox(stemp); } returnncount;}#if!defined(AFX_CHECKDLG_H__308FEC04_0401_46B6_B7DB_78EB89ABB23A__INCLUDED_)#defineAFX_CHECKDLG_H__308FEC04_0401_46B6_B7DB_78EB89ABB23A__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_VER>1000//CheckDlg.h:headerfile/////////////////////////////////////////////////////////////////////////////////CCheckDlgdialogclassCCheckDlg:publicCDialog{//Constructionpublic: longGetPaymodeID(CStringpayname); CCheckDlg(CWnd*pParent=NULL);//standardconstructor//DialogData //{{AFX_DATA(CCheckDlg) enum{IDD=IDD_DIALOG_CHECK}; CEdit m_oConsume; CEdit m_oCdiscount; CEdit m_oReceive; CEdit m_oChange; CEdit m_oTotalm; CComboBox m_oCombopay; CListCtrl m_oChecklist; //}}AFX_DATA//Overrides //ClassWizardgeneratedvirtualfunctionoverrides //{{AFX_VIRTUAL(CCheckDlg) protected: virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport //}}AFX_VIRTUAL//Implementationprotected: //Generatedmessagemapfunctions //{{AFX_MSG(CCheckDlg) virtualBOOLOnInitDialog(); afx_msgvoidOnButtonCheckok(); afx_msgvoidOnChangeEditReceive(); afx_msgvoidOnClickListChecklist(NMHDR*pNMHDR,LRESULT*pResult); afx_msgvoidOnChangeEditCdiscount(); afx_msgvoidOnButtonRf(); afx_msgvoidOnButtonHang(); //}}AFX_MSG DECLARE_MESSAGE_MAP()private: CStringGetClassName(longlclassid); longVerifyDicsount(); voidReadtoList(CStringsbillid); floatfchange;};//{{AFX_INSERT_LOCATION}}//MicrosoftVisualC++willinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_CHECKDLG_H__308FEC04_0401_46B6_B7DB_78EB89ABB23A__INCLUDED_)//CheckDlg.cpp:implementationfile//#include"stdafx.h"#include"MyPos.h"#include"CheckDlg.h"#include"PosDlg.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CCheckDlgdialogexternCMyPosApptheApp;CCheckDlg::CCheckDlg(CWnd*pParent/*=NULL*/) :CDialog(CCheckDlg::IDD,pParent){ //{{AFX_DATA_INIT(CCheckDlg) //}}AFX_DATA_INIT}voidCCheckDlg::DoDataExchange(CDataExchange*pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCheckDlg) DDX_Control(pDX,IDC_EDIT_CONSUME,m_oConsume); DDX_Control(pDX,IDC_EDIT_CDISCOUNT,m_oCdiscount); DDX_Control(pDX,IDC_EDIT_RECEIVE,m_oReceive); DDX_Control(pDX,IDC_EDIT_CHANGE,m_oChange); DDX_Control(pDX,IDC_EDIT_TOTALM,m_oTotalm); DDX_Control(pDX,IDC_COMBO_PAYMODE,m_oCombopay); DDX_Control(pDX,IDC_LIST_CHECKLIST,m_oChecklist); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCheckDlg,CDialog) //{{AFX_MSG_MAP(CCheckDlg) ON_BN_CLICKED(IDC_BUTTON_CHECKOK,OnButtonCheckok) ON_EN_CHANGE(IDC_EDIT_RECEIVE,OnChangeEditReceive) ON_NOTIFY(NM_CLICK,IDC_LIST_CHECKLIST,OnClickListChecklist) ON_EN_CHANGE(IDC_EDIT_CDISCOUNT,OnChangeEditCdiscount) ON_BN_CLICKED(IDC_BUTTON_RF,OnButtonRf) ON_BN_CLICKED(IDC_BUTTON_HANG,OnButtonHang) //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CCheckDlgmessagehandlersBOOLCCheckDlg::OnInitDialog(){ CDialog::OnInitDialog(); //设置list控件的文字和背景颜色 m_oChecklist.SetBkColor(RGB(255,255,255)); m_oChecklist.SetTextBkColor(RGB(161,223,212)); //清空list控件的数据 for(intdelcolumn=100;delcolumn>=0;delcolumn--) m_oChecklist.DeleteColumn(delcolumn); //设置list对话框的列 DWORDdwStyle; RECTrect; LV_COLUMNlvc; dwStyle=m_oChecklist.GetStyle(); dwStyle|=LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS; m_oChecklist.SetExtendedStyle(dwStyle); m_oChecklist.GetClientRect(&rect); lvc.mask=LVCF_TEXT|LVCF_SUBITEM|LVCF_WIDTH|LVCF_FMT; lvc.fmt=LVCFMT_LEFT; lvc.iSubItem=0; lvc.pszText=_T("商品类别"); lvc.cx=110; m_oChecklist.InsertColumn(1,&lvc); lvc.iSubItem=1; lvc.pszText=_T("消费金额"); lvc.cx=90; m_oChecklist.InsertColumn(2,&lvc); lvc.iSubItem=2; lvc.pszText=_T("可折扣金额"); lvc.cx=90; m_oChecklist.InsertColumn(3,&lvc); lvc.iSubItem=3; lvc.pszText=_T("折扣%"); lvc.cx=60; m_oChecklist.InsertColumn(4,&lvc); lvc.iSubItem=4; lvc.pszText=_T("结帐金额"); lvc.cx=90; m_oChecklist.InsertColumn(5,&lvc); //Addpaymodetocombobox. _RecordsetPtrm_pRecordset; CStringsql="select*fromPAYMODE"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); while(!m_pRecordset->adoEOF) { m_oCombopay.AddString((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("NAME")); m_pRecordset->MoveNext(); } m_pRecordset->Close(); m_oCombopay.SetCurSel(0);//Selectthe1ststringofcombobox. } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]读取付款方式到组合框出错:%s",e.ErrorMessage()); AfxMessageBox(temp); } //Readclassconsumetolist. ReadtoList(theApp.scallid); //SumbillItemsmoneyfromdatabase. CStringstotal; floatftotal=0; sql="SelectSUM(ITEMTOTAL)asSSSfromSALEDETAILwhereBILLID='"+theApp.scallid+"'"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); _variant_tvtemp=m_pRecordset->GetCollect("SSS"); if(vtemp.dblVal>0) ftotal=(float)m_pRecordset->GetCollect("SSS"); else ftotal=0; stotal.Format("%.2f",ftotal); m_oTotalm.SetWindowText(stotal); m_oConsume.SetWindowText(stotal); } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]计算单据商品金额出错:%s",e.ErrorMessage()); AfxMessageBox(temp); } returnTRUE;//returnTRUEunlessyousetthefocustoacontrol //EXCEPTION:OCXPropertyPagesshouldreturnFALSE}voidCCheckDlg::OnButtonCheckok(){ CStringstotal,sbilltotal,spayID,sql,spaymode,snowtime; longlpayID; _RecordsetPtrm_pRecordset; m_oConsume.GetWindowText(stotal); m_oTotalm.GetWindowText(sbilltotal); intnselect=m_oCombopay.GetCurSel(); m_oCombopay.GetLBText(nselect,spaymode); lpayID=GetPaymodeID(spaymode); spayID.Format("%d",lpayID); if(fchange<0) return; //得到系统时间 CTimenow=CTime::GetCurrentTime(); snowtime=now.Format(_T("%Y-%m-%d%H:%M:%S")); sql="UpdateSALEBILLsetENDDATE='"+snowtime+"',SALES='"+theA+"',TOTAL=" +stotal+",ACTTOTAL="+sbilltotal+",STATUS='已结帐',PAYMODE="+spayID+"whereID='"+theApp.scallid+"'"; try { _variant_tRecordsAffected; theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText); } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]单据头更新数据库出错:%s",e.ErrorMessage()); AfxMessageBox(temp); return; } //outputthecheckouttimeandpaymodetotheprint. theApp.snowtimep=snowtime; theApp.spaymodep=spaymode; theApp.sconsume=stotal; theApp.sactsum=sbilltotal; //InsertdataintoPAYDETAIL. CStringsclass,scontotal,sdiscount,sacttotal,svaltotal; intnItemCount=m_oChecklist.GetItemCount();//表项总数 for(inti=0;i<nItemCount;i++) { sclass=m_oChecklist.GetItemText(i,0); scontotal=m_oChecklist.GetItemText(i,1); sdiscount=m_oChecklist.GetItemText(i,3); sacttotal=m_oChecklist.GetItemText(i,4); floatfvaltotal=atof(scontotal)-atof(sacttotal); svaltotal.Format("%.2f",fvaltotal); sql="InsertintoPAYDETAIL(BILLID,CLASS,TOTAL,DISCOUNT,ACTTOTAL,VALTOTAL)values('"+theApp.scallid+ "','"+sclass+"',"+scontotal+",'"+sdiscount+"',"+sacttotal+","+svaltotal+")"; try { _variant_tRecordsAffected; theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText); } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]付款明细(PAYDETAIL)插入数据出错:%s",e.ErrorMessage()); AfxMessageBox(temp); return; } } //Whenthecheckbuttonisclickdown,sendamessage(WM_CHECKOUT)totheCPosDlg. LRESULTRes=::SendMessage(theApp.pWnd,WM_CHECKOUT,0,0); CDialog::OnOK();}longCCheckDlg::GetPaymodeID(CStringpayname){ longpaymodeID; _RecordsetPtrm_pRecordset; CStringsql="Select*fromPAYMODEwhereNAME='"+payname+"'"; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); paymodeID=(long)m_pRecordset->GetCollect("ID"); } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]获取付款方式ID出错:%s",e.ErrorMessage()); AfxMessageBox(temp); } returnpaymodeID;}voidCCheckDlg::OnChangeEditReceive(){ //TODO:IfthisisaRICHEDITcontrol,thecontrolwillnot //sendthisnotificationunlessyouoverridetheCDialog::OnInitDialog() //functionandcallCRichEditCtrl().SetEventMask() //withtheENM_CHANGEflagORedintothemask. CStringsreceive,schange,stotal; m_oChange.SetWindowText(""); m_oReceive.GetWindowText(sreceive); m_oTotalm.GetWindowText(stotal); fchange=atof(sreceive)-atof(stotal); if(fchange>=0) { schange.Format("%.2f",fchange); m_oChange.SetWindowText(schange); }}voidCCheckDlg::ReadtoList(CStringsbillid){ _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! CStringsql,sclassname,sclassname1,sctotal; longlclassid; floatfctotal=0; sql="SelectSum(ITEMTOTAL)asXXX,CLASSIDfromSALEDETAILwhereBILLID='"+sbillid+"'groupbyCLASSID"; //删除所有list中的数据。 m_oChecklist.DeleteAllItems(); intnumline=0; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); LV_ITEMlvitem; lvitem.pszText=""; lvitem.mask=LVIF_TEXT; lvitem.iSubItem=0; while(!m_pRecordset->adoEOF) { lvitem.iItem=numline; m_oChecklist.InsertItem(&lvitem); //读出数据写入到list中 lclassid=(long)m_pRecordset->GetCollect("CLASSID"); sclassname=GetClassName(lclassid); sclassname1=sclassname.Left(sclassname.GetLength()-4); m_oChecklist.SetItemText(numline,0,sclassname1);//Readclassnameto0column. fctotal=(float)m_pRecordset->GetCollect("XXX"); sctotal.Format("%.2f",fctotal); m_oChecklist.SetItemText(numline,1,sctotal);//Readclassconsumetotalto1stcolumn. if(sclassname.Right(1)=="0") m_oChecklist.SetItemText(numline,2,"0.00");//Readclassconsumediscounttotalto2ndcolumn. else m_oChecklist.SetItemText(numline,2,sctotal); m_oChecklist.SetItemText(numline,3,"100"); m_oChecklist.SetItemText(numline,4,sctotal);//Readclassconsumeacttotalto4thcolumn. numline++; m_pRecordset->MoveNext(); } m_pRecordset->Close(); } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]列表读入商品出错:%s",e.ErrorMessage()); AfxMessageBox(temp); return; }}CStringCCheckDlg::GetClassName(longlclassid){ _RecordsetPtrm_pRecordset;//Mustdefineitinfunction!!!! CStringsql,sclassid,sname,sdiscount; sclassid.Format("%d",lclassid); sql="SelectNAME,DISCOUNTfromMATERIELCLASSwhereID="+sclassid+""; try { m_pRecordset.CreateInstance("ADODB.Recordset"); m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText); if(!m_pRecordset->adoEOF) { sname=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("NAME"); sdiscount=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("DISCOUNT"); sname=sname+"xxx"+sdiscount; } } catch(_com_errore)///捕捉异常 { CStringtemp; temp.Format("[结帐]获取类别名称出错:%s",e.ErrorMessage()); AfxMessageBox(temp); } returnsname;}voidCCheckDlg::OnClickListChecklist(NMHDR*pNMHDR,LRESULT*pResult){ //得到当前选中的行 POSITIONpos=m_oChecklist.GetFirstSelectedItemPosition(); //如果选中一行 if(pos) { intnItem=m_oChecklist.GetNextSelectedItem(pos); CString sdiscount=m_oChecklist.GetItemText(nItem,3); m_oCdiscount.SetWindowText(sdiscount); } *pResult=0;}voidCCheckDlg::OnChangeEditCdiscount(){ //TODO:IfthisisaRICHEDITcontrol,thecontrolwillnot //sendthisnotificationunlessyouoverridetheCDialog::OnInitDialog() //functionandcallCRichEditCtrl().SetEventMask() //withtheENM_CHANGEflagORedintothemask. CStringsdiscountsum,sdiscount,ssum; floatfdiscountsum,fsum; longldiscount; LV_ITEMlvitem; lvitem.pszText=""; lvitem.mask=LVIF_TEXT; //得到当前选中的行 POSITIONpos=m_oChecklist.GetFirstSelectedItemPosition(); //如果选中一行 if(pos) { intnItem=m_oChecklist.GetNextSelected
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年广东公务员考试行测试题
- 2024婚礼司仪主持词开场白模版(33篇)
- 2024西安市房屋租赁合同范本(22篇)
- 2025年个人资产转让协议官方版
- 2025年代理出口合作协议范例
- 2025年农村自用土地转让合同示例
- 2025年油污清洁剂项目立项申请报告模板
- 2025年公路清障车项目规划申请报告模稿
- 2025年中国邮政快递运输合同标准
- 2025年快递员职业技能培训与发展协议
- 新教科版一年级科学下册第一单元《身边的物体》全部课件(共7课时)
- 2025年中国水解聚马来酸酐市场调查研究报告
- 高考百日誓师动员大会
- 2025江苏常州西太湖科技产业园管委会事业单位招聘8人历年高频重点提升(共500题)附带答案详解
- 2025年北京控股集团有限公司招聘笔试参考题库含答案解析
- 2024年北京东城社区工作者招聘笔试真题
- 信息技术必修一《数据与计算》第三章第三节《数据分析报告与应用》说课稿
- 2024新人教版初中英语单词表默写版(七~九年级)
- 体育科学急救知识
- 复工复产质量管理工作
- 2025年东方电气集团东方锅炉股份限公司校园招聘高频重点提升(共500题)附带答案详解
评论
0/150
提交评论