pos機管理系統(tǒng)軟件源代碼_第1頁
pos機管理系統(tǒng)軟件源代碼_第2頁
pos機管理系統(tǒng)軟件源代碼_第3頁
pos機管理系統(tǒng)軟件源代碼_第4頁
pos機管理系統(tǒng)軟件源代碼_第5頁
已閱讀5頁,還剩128頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、#if !defined(AFX_CLASSDLG_H_B_C0BF_47D8_8A7A_A2540CC35379_INCLUDED_)#define AFX_CLASSDLG_H_B_C0BF_47D8_8A7A_A2540CC35379_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000/ ClassDlg.h : header file/ CClassDlg dialogclass CClassDlg : public CDialog/ Constructionpublic:int CountMateriel(CStr

2、ing sclassid);CClassDlg(CWnd* pParent = NULL); / standard constructorstatic CString VariantToCString(VARIANT var);static int TreeSumRecordCount(CString strFieldValue);/ Dialog Data/AFX_DATA(CClassDlg)enum IDD = IDD_DIALOG_CLASS ;CButtonm_oRadiodiscount;CEditm_oClassname;CTreeCtrlm_oTreeclass;CString

3、m_classname;intm_radiodiscount;longm_tempid;/AFX_DATA/ Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CClassDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/ Generated message map functions/AFX_MSG(CClassD

4、lg)afx_msg void OnSelchangedTreeClass(NMHDR* pNMHDR, LRESULT* pResult);virtual BOOL OnInitDialog();afx_msg void OnButtonAddsame();afx_msg void OnButtonAddsub();afx_msg void OnButtonDel();afx_msg void OnButtonSave();/AFX_MSGDECLARE_MESSAGE_MAP()private:int GenNewID();/Generate a new record ID.void Ad

5、dSubTree(CString ParTree, HTREEITEM hPartItem);void AddTree();BOOL bRepeat(CString strFieldValue);HTREEITEM hCurrentItem,hParentItem;CString Curpar;/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_CLASSDLG_H_B_C0

6、BF_47D8_8A7A_A2540CC35379_INCLUDED_)/ ClassDlg.cpp : implementation file/#include stdafx.h#include MyPos.h#include ClassDlg.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CClassDlg dialogextern CMyPosApp theApp;CClassDlg:CClassDlg(CWnd* pParent /*=NULL*/):

7、CDialog(CClassDlg:IDD, pParent)/AFX_DATA_INIT(CClassDlg)m_classname = _T();m_radiodiscount = -1;m_tempid = 0;/AFX_DATA_INITvoid CClassDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CClassDlg)DDX_Control(pDX, IDC_RADIO1_DISCOUNT, m_oRadiodiscount);DDX_Control(pDX, IDC

8、_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_MAPBEGIN_MESSAGE_MAP(CClassDlg, CDialog)/AFX_MSG_MAP(CClassDlg)ON_NOTIFY(TVN

9、_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()/ CClassDlg message handlersvoid CCl

10、assDlg:OnSelchangedTreeClass(NMHDR* pNMHDR, LRESULT* pResult) NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;CString sql;CString curtext;_RecordsetPtr m_pRecordset; /Must define it in function!HTREEITEM hCurItem;hCurItem=m_oTreeclass.GetSelectedItem ();/Get Current item and its sub items.curtext=m_

11、oTreeclass.GetItemText(hCurItem);/Read current item text into edit control.m_classname=curtext;sql=SELECT * FROM MATERIELCLASS where NAME=+curtext+;trym_tempid=0;m_pRecordset.CreateInstance(ADODB.Recordset);m_pRecordset-Open(_variant_t)sql,_variant_t(IDispatch*)theApp.m_pConnection,true),adOpenDynam

12、ic,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-Clos

13、e();catch(_com_error e)/捕捉異常 CString errormessage; MessageBox(讀取單選按鈕出錯!,m_classname);UpdateData(false);*pResult = 0;void CClassDlg:AddSubTree(CString ParTree, HTREEITEM hPartItem)HTREEITEM hCurrent;CString sql;CString curID;_RecordsetPtr m_pTRecordset; /Must define it in function!Becourse this is a

14、RECURSION function.sql=SELECT * FROM MATERIELCLASS where PARENT=;sql=sql+ParTree+;/The 1st time Partree=1.trym_pTRecordset.CreateInstance(ADODB.Recordset);m_pTRecordset-Open(_variant_t)sql,_variant_t(IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);m_pTRecordset-MoveFi

15、rst();if(!m_pTRecordset-adoEOF)while(!m_pTRecordset-adoEOF)hCurrent = m_oTreeclass.InsertItem(LPCTSTR)(_bstr_t)(m_pTRecordset-GetCollect(NAME), hPartItem, NULL);/Insert an item into current parent.curID=VariantToCString(m_pTRecordset-GetCollect(ID);if (TreeSumRecordCount(curID)0)AddSubTree(VariantTo

16、CString(m_pTRecordset-GetCollect(ID),hCurrent);/Recursion.if (!m_pTRecordset-adoEOF)m_pTRecordset-MoveNext();m_pTRecordset-Close();catch(_com_error e)/捕捉異常 CString errormessage; MessageBox(讀取類別子樹出錯!,ParTree);void CClassDlg:AddTree()TVINSERTSTRUCT tvInsert;HTREEITEM hParent;_RecordsetPtr m_pTRecordse

17、t; /Must define it in function!Becourse this is a RECURSION function.CString sroot,sql;tvInsert.hParent = NULL;tvInsert.hInsertAfter = NULL;tvInsert.item.mask = TVIF_TEXT;sql=SELECT * FROM MATERIELCLASS where ID=1;trym_pTRecordset.CreateInstance(ADODB.Recordset);m_pTRecordset-Open(_variant_t)sql,_va

18、riant_t(IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);if(!m_pTRecordset-adoEOF)sroot=(LPTSTR)(_bstr_t)m_pTRecordset-GetCollect(NAME);/Insert an item into current parent.m_pTRecordset-Close();catch(_com_error e)/捕捉異常CString errormessage;errormessage.Format(讀取類別樹出錯:%s

19、,e.ErrorMessage();AfxMessageBox(errormessage);/tvInsert.item.pszText = _T(root);if(sroot!=)/tvInsert.item.pszText =_T();/User this line to give the tree a sum root.hParent = m_oTreeclass.InsertItem(&tvInsert);/HTREEITEM of root./AddSubTree(1,hParent);/Here strChildTree just must not equal root,can b

20、e anyother string.AddSubTree(RootClass,hParent);/Here strChildTree just must not equal root,can be anyother string.m_oTreeclass.Expand(hParent,TVE_EXPAND);int CClassDlg:TreeSumRecordCount(CString strFieldValue)int Sum=0;CString sql;_RecordsetPtr m_pRecordset; /Must define it in function!sql=SELECT *

21、 FROM MATERIELCLASS where PARENT =;sql=sql+strFieldValue+;trym_pRecordset.CreateInstance(ADODB.Recordset);m_pRecordset-Open(_variant_t)sql,_variant_t(IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);if(!m_pRecordset-BOF)/If current record is not the first record.m_pRe

22、cordset-MoveFirst ();while(!m_pRecordset-adoEOF)Sum+=1;m_pRecordset-MoveNext ();m_pRecordset-Close();catch(_com_error e)/捕捉異常CString stemp;stemp.Format(計算類別總數(shù)出錯:%s,e.ErrorMessage();AfxMessageBox(stemp);return Sum;CString CClassDlg:VariantToCString(VARIANT var)CString strValue;_variant_t var_t;_bstr_

23、t bst_t;time_t cur_time;CTime time_value;COleCurrency var_currency;switch(var.vt)case VT_EMPTY:strValue=_T();break;case VT_UI1:strValue.Format (%d,var.bVal);break;case VT_I2:strValue.Format (%d,var.iVal );break;case VT_I4:strValue.Format (%d,var.lVal);break;case VT_R4:strValue.Format (%f,var.fltVal)

24、;break;case VT_R8:strValue.Format (%f,var.dblVal);break;case VT_CY:var_currency=var;strValue=var_currency.Format(0);break;case VT_BSTR:var_t=var;bst_t=var_t;strValue.Format (%s,(const char*)bst_t);break;case VT_NULL:strValue=_T();break;case VT_DATE:cur_time=var.date;time_value=cur_time;strValue=time

25、_value.Format(%A,%B%d,%Y);break;case VT_BOOL:strValue.Format (%d,var.boolVal );break;default:strValue=_T();break;return strValue;BOOL CClassDlg:OnInitDialog() CDialog:OnInitDialog();AddTree();return TRUE; / return TRUE unless you set the focus to a control / EXCEPTION: OCX Property Pages should retu

26、rn FALSEvoid CClassDlg:OnButtonAddsame() CString sql;CString newclassname,Newpar,snewid;long lNewID;/Get new record id._RecordsetPtr m_pRecordset; /Must define it in function!hParentItem=m_oTreeclass.GetParentItem(m_oTreeclass.GetSelectedItem ();/Get parent item handle.lNewID=GenNewID();/Call the Ge

27、nNewID function to get a new ID.snewid.Format(%d,lNewID);Newpar=Curpar;newclassname.Format(新類別%d,lNewID);try_variant_t RecordsAffected;sql=Insert into MATERIELCLASS (ID,NAME,DISCOUNT,PARENT) VALUES (+snewid+,+newclassname+,0,+Newpar+);if(lNewID=1)sql=Insert into MATERIELCLASS (ID,NAME,DISCOUNT,PAREN

28、T) VALUES (1,+newclassname+,0,RootClass);theApp.m_pConnection-Execute(_bstr_t)sql,&RecordsAffected,adCmdText);catch(_com_error e)/捕捉異常CString errormessage;errormessage.Format(增加同級分類出錯:%s,e.ErrorMessage();AfxMessageBox(errormessage);m_oClassname.SetWindowText(newclassname);m_oTreeclass.InsertItem(LPC

29、TSTR)(_bstr_t)(newclassname), hParentItem, NULL);/Insert an item into current parent.void CClassDlg:OnButtonAddsub() CString sql;CString newclassname,Newpar,snewid;long lNewID;_RecordsetPtr m_pRecordset; /Must define it in function!hCurrentItem=m_oTreeclass.GetSelectedItem ();/Get current item handl

30、e as subs parent.lNewID=GenNewID();snewid.Format(%d,lNewID);Newpar.Format(%d,m_tempid);newclassname.Format(新類別%d,lNewID);try_variant_t RecordsAffected;sql=Insert into MATERIELCLASS (ID,NAME,DISCOUNT,PARENT) VALUES (+snewid+,+newclassname+,0,+Newpar+);if(lNewID=1)sql=Insert into MATERIELCLASS (ID,NAM

31、E,DISCOUNT,PARENT) VALUES (1,+newclassname+,0,RootClass);theApp.m_pConnection-Execute(_bstr_t)sql,&RecordsAffected,adCmdText);catch(_com_error e)/捕捉異常CString errormessage;errormessage.Format(增加下級分類出錯:%s,e.ErrorMessage();AfxMessageBox(errormessage);m_oClassname.SetWindowText(newclassname);m_oTreeclas

32、s.InsertItem(LPCTSTR)(_bstr_t)(newclassname), hCurrentItem, NULL);/Insert an item into current parent.void CClassDlg:OnButtonDel() CString sql,curID;_RecordsetPtr m_pRecordset; /Must define it in function!HTREEITEM hCurItem;hCurItem=m_oTreeclass.GetSelectedItem ();/Get Current item and its sub items

33、.sql=SELECT * FROM MATERIELCLASS where NAME =;sql=sql+m_classname+;if(AfxMessageBox(確定刪除此類別嗎?,MB_YESNO)=IDYES)trym_pRecordset.CreateInstance(ADODB.Recordset);m_pRecordset-Open(_variant_t)sql,_variant_t(IDispatch*)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);if(!m_pRecordset-

34、BOF)/If current record is not the first record.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(此類別下已有商品,不能刪除!);elsem_pRecordset-Delete(adAffectCurrent);/刪除當(dāng)前記錄m_oTreecl

35、ass.DeleteItem(hCurItem);if (TreeSumRecordCount(curID)0)MessageBox(不能刪除結(jié)點類別!,m_classname);m_pRecordset-Update();m_pRecordset-Close();catch(_com_error e)/捕捉異常CString errormessage;MessageBox(刪除類別出錯!,m_classname);void CClassDlg:OnButtonSave() CString sql,parent,name,sdiscount;/,stempidlong discount;Upd

36、ateData();/檢查數(shù)據(jù)完整性if(m_classname.IsEmpty()AfxMessageBox(類別名稱不能為空!);return;m_oClassname.GetWindowText(name);/Get the current text in edit.if(bRepeat(name)=TRUE)AfxMessageBox(類別名稱重復(fù)!請重新輸入!);return;if(AfxMessageBox(確定要保存修改嗎?,MB_YESNO)=IDYES)int nDiscount=GetCheckedRadioButton(IDC_RADIO1_DISCOUNT,IDC_RA

37、DIO2_DISCOUNT); switch(nDiscount)/Get if it is discount.case IDC_RADIO1_DISCOUNT:discount=0;break;case IDC_RADIO2_DISCOUNT:discount=1;break;default:break;sdiscount.Format(%d,discount);/stempid.Format(%d,m_tempid);try_variant_t RecordsAffected;/sql=Update MATERIELCLASS set NAME=+name+,DISCOUNT=+sdisc

38、ount+ where ID=+stempid+;sql.Format(Update MATERIELCLASS set NAME=%s,DISCOUNT=%d where ID=%d,name,discount,m_tempid);/Must add!theApp.m_pConnection-Execute(_bstr_t)sql,&RecordsAffected,adCmdText);hCurrentItem=m_oTreeclass.GetSelectedItem ();/Get current item handle as subs parent.m_oTreeclass.SetIte

39、mText(hCurrentItem,(LPCTSTR)(_bstr_t)(name);catch(_com_error e)/捕捉異常CString stemp;stemp.Format(修改類別出錯:%s,e.ErrorMessage();/AfxMessageBox(stemp);return;BOOL CClassDlg:bRepeat(CString strFieldValue)CString sql;BOOL br;_RecordsetPtr m_pRecordset; /Must define it in function!sql=SELECT * FROM MATERIELCL

40、ASS WHERE NAME=;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();catc

41、h(_com_error e)/捕捉異常CString stemp;stemp.Format(查找類別名稱出錯:%s,e.ErrorMessage();AfxMessageBox(stemp);return br;int CClassDlg:GenNewID()CString sql;int NewID;_RecordsetPtr m_pRecordset; /Must define it in function!sql=SELECT Max(ID) FROM MATERIELCLASS;try m_pRecordset.CreateInstance(ADODB.Recordset);m_pR

42、ecordset-Open(_variant_t)sql,_variant_t(IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);_variant_t vIndex = (long)0;/How to get field value in only 1 record and 1 field condition._variant_t vtemp = m_pRecordset-GetCollect(vIndex);if(vtemp.lVal0) NewID =(long)(m_pRecord

43、set-GetCollect(vIndex)+1;/取得第一個字段的值(MAX ID)加1后放入id變量.elseNewID=1;m_pRecordset-Close();catch(_com_error e)/捕捉異常CString stemp;stemp.Format(獲取類別ID最大值出錯:%s,e.ErrorMessage();AfxMessageBox(stemp);return NewID;int CClassDlg:CountMateriel(CString sclassid)CString sql;int ncount;_RecordsetPtr m_pRecordset; /

44、Must define it in function!sql=SELECT count(*) as XXX FROM MATERIEL where classid=+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-GetColle

45、ct(XXX);m_pRecordset-Close();catch(_com_error e)/捕捉異常CString stemp;stemp.Format(計算類別下商品數(shù)量出錯:%s,e.ErrorMessage();AfxMessageBox(stemp);return ncount;#if !defined(AFX_CHECKDLG_H_308FEC04_0401_46B6_B7DB_78EB89ABB23A_INCLUDED_)#define AFX_CHECKDLG_H_308FEC04_0401_46B6_B7DB_78EB89ABB23A_INCLUDED_#if _MSC_

46、VER 1000#pragma once#endif / _MSC_VER 1000/ CheckDlg.h : header file/ CCheckDlg dialogclass CCheckDlg : public CDialog/ Constructionpublic:long GetPaymodeID(CString payname);CCheckDlg(CWnd* pParent = NULL); / standard constructor/ Dialog Data/AFX_DATA(CCheckDlg)enum IDD = IDD_DIALOG_CHECK ;CEditm_oC

47、onsume;CEditm_oCdiscount;CEditm_oReceive;CEditm_oChange;CEditm_oTotalm;CComboBoxm_oCombopay;CListCtrlm_oChecklist;/AFX_DATA/ Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CCheckDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Imp

48、lementationprotected:/ Generated message map functions/AFX_MSG(CCheckDlg)virtual BOOL OnInitDialog();afx_msg void OnButtonCheckok();afx_msg void OnChangeEditReceive();afx_msg void OnClickListChecklist(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnChangeEditCdiscount();afx_msg void OnButtonRf();afx

49、_msg void OnButtonHang();/AFX_MSGDECLARE_MESSAGE_MAP()private:CString GetClassName(long lclassid);long VerifyDicsount();void ReadtoList(CString sbillid);float fchange;/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_CHECKDLG_H_308FEC04_0401_46B6_B7DB_78EB89ABB23A_INCLUDED_)/ CheckDlg.cpp : implementation file/#include stdafx.h#include MyPos.h#include CheckDlg.h#in

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論