// Singleincomemoney.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "Singleincomemoney.h" #include "InputMemberno.h" #include "SelPayType.h" #include "Login2.h" #include "SelExpendType.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // Singleincomemoney dialog IDC_EDIT3 Singleincomemoney::Singleincomemoney(CWnd* pParent /*=NULL*/) : CDialog(Singleincomemoney::IDD, pParent) { //{{AFX_DATA_INIT(Singleincomemoney) m_money = _T(""); m_time1 = g_date; m_ren2 = g_user.name; m_money1 = _T(""); m_money2 = _T(""); m_money3 = _T(""); m_phone = _T(""); m_sitem = _T(""); m_id = _T(""); m_name = _T(""); //}}AFX_DATA_INIT } void Singleincomemoney::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(Singleincomemoney) DDX_Control(pDX, IDC_LIST1, m_List1); DDX_Control(pDX, IDC_EDIT2, m_editdate1); DDX_Control(pDX, IDC_EDIT1, m_editctrl1); DDX_Text(pDX, IDC_EDIT1, m_money); DDX_Text(pDX, IDC_EDIT2, m_time1); DDX_Text(pDX, IDC_EDITren2, m_ren2); DDX_Text(pDX, IDC_EDITmoney2, m_money1); DDX_Text(pDX, IDC_EDITmoney3, m_money2); DDX_Text(pDX, IDC_EDITmoney5, m_money3); DDX_Text(pDX, IDC_EDITphone, m_phone); DDX_Text(pDX, IDC_EDITsitem, m_sitem); DDX_Text(pDX, IDC_EDITid, m_id); DDX_Text(pDX, IDC_EDITname1, m_name); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(Singleincomemoney, CDialog) //{{AFX_MSG_MAP(Singleincomemoney) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON8, OnButton8) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // Singleincomemoney message handlers BOOL Singleincomemoney::OnInitDialog() { CDialog::OnInitDialog(); GetDlgItem(IDC_BUTTON1)->EnableWindow(IsHasRights2new(49)); // if(IsHasRights2new(49)==0)((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly (); // else ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly (); if(atoi(g_cominfoarray.ElementAt(0).ElementAt(115))) m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120;接单点,80" ); else m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120" ); m_List1.LoadColumnInfo (300); // TODO: Add extra initialization here g_sendhead.bsql=0; g_sendhead.code[0]=197; g_sendhead.tabcount=1; CString filter="id='"+m_id+"'"; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { CDialog::OnCancel (); return 0; } DataToArray( &m_List1array); CenterWindow(g_pMainWnd); FillGrid(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void Singleincomemoney::OnOK() { // TODO: Add extra validation here UpdateData(); if(m_money.IsEmpty ()) { AfxMessageBox("资料不全!", MB_ICONINFORMATION); return; } if(!CheckDateOK(m_time1))return; CString m_date=m_time1; BOOL bexist1=0; BOOL bexist2=0; if(bexist1==0) { for(int i=0; iProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); // CDialog::OnOK(); } HBRUSH Singleincomemoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (nCtlColor==CTLCOLOR_STATIC) { pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明 return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色 } // TODO: Return a different brush if the default is not desired return hbr; } void Singleincomemoney::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDialog::OnLButtonDown(nFlags, point); } void Singleincomemoney::GetData() { g_sendhead.bsql=0; g_sendhead.code[0]=197; g_sendhead.tabcount=1; CString filter="id='"+m_id+"'"; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0)return; DataToArray( &m_List1array); FillGrid(); float payed=0; for(int i=0; imessage==WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: return 1; } } return CDialog::PreTranslateMessage(pMsg); } void Singleincomemoney::OnButton1() { // TODO: Add your control notification handler code here if(IsHasRights2new(49)==0)return; // TODO: Add your control notification handler code here POSITION pos; pos=m_List1.GetFirstSelectedItemPosition(); if(pos==NULL) { AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION); return; } if(AfxMessageBox("是否删除此项目?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return; int iItem=m_List1.GetNextSelectedItem(pos); CString id=m_List1.GetItemText (iItem, 0); CString money=m_List1.GetItemText (iItem, 1); CString bz=m_List1.GetItemText (iItem, 2)+m_List1.GetItemText (iItem, 3); CString sql; sql.Format ("delete from singleincomemoney where [autoid]=%d***refresh singleincomemoney%s", atol(id), m_id); g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; GetData(); CString str; str=m_List1.GetItemText (iItem, 3); str+="删除客人"; str+=m_name; str+=m_List1.GetItemText (iItem, 2); str+="其它二销收款:"; str+=money; WriteLog(str); } void Singleincomemoney::OnButton3() { // TODO: Add your control notification handler code here Login2 dlg; dlg.m_mode=3; if(dlg.DoModal ()!=IDOK)return; if(IsHasRightsnew2(49, dlg.m_rights)==0)return; ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly (0); } void Singleincomemoney::OnButton8() // 其它二销打印; { // TODO: Add your control notification handler code here //AfxMessageBox("789"); POSITION pos; pos=m_List1.GetFirstSelectedItemPosition(); if(pos==NULL) { AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION); return; } int iItem; CStringArray array; array.Add (""); array.Add (g_cominfoarray.ElementAt (0).ElementAt (48)); array.Add ("NO."+m_id); CString str="地址:"+g_cominfoarray.ElementAt (0).ElementAt (12); str+=" 电话:"+g_cominfoarray.ElementAt (0).ElementAt (11); array.Add (str); CString name=m_name; CString phone=m_phone; array.Add ("客户姓名:"+name); if(IsHasRights2new(31)==0) array.Add (""); else array.Add ("联系电话:"+phone); CString date; date.Format ("日期:%s年%s月%s日", g_date.Mid (0,4), g_date.Mid (5,2), g_date.Mid (8,2)); array.Add (date); array.Add (" 收 款 项 目 "); #if 1 // Jeff 显示打印支付方式; array.Add(" 支付方式 "); #endif array.Add (" 金 额 "); array.Add (" 开单人 "); int count=0; float money=0; while (pos) { count++; if(m_bz!="" && count>3)break; if(count>4)break; iItem = m_List1.GetNextSelectedItem(pos); array.Add (m_sitem); #if 1 // 显示打印支付方式; array.Add(m_List1.GetItemText(iItem,4)); // add by Jeff:添加支付方式; #endif array.Add (m_List1.GetItemText (iItem, 1)); money+=atof(m_List1.GetItemText (iItem, 1)); array.Add (m_ren); } if(m_bz!="" && count==1) { array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (m_bz); array.Add (""); array.Add (""); array.Add (""); } if(m_bz!="" && count==2) { array.Add (""); array.Add (""); array.Add (""); array.Add (""); array.Add (m_bz); array.Add (""); array.Add (""); array.Add (""); } if(m_bz!="" && count==3) { array.Add (m_bz); array.Add (""); array.Add (""); array.Add (""); } if(m_bz!="" && count==4) { array.Add (m_bz); array.Add (""); array.Add (""); array.Add (""); } //while(array.GetSize ()<22) array.Add (""); while(array.GetSize()<27) array.Add(""); // 显示打印支付方式; CString smoney; smoney.Format ("%0.1f", money); if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单 { str="付款情况 应付:"+m_money1; str+=" 实付:"+m_money2; str+=" 欠款:"+m_money3; } else { str="付款情况 应付:"+m_money1; str+=" 实付:"+m_money2; str+=" 欠款:"+m_money3; } array.Add (str); if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单 { str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\ GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney))); } else { str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\ GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney))); } array.Add (str); array.Add (g_cominfoarray.ElementAt (0).ElementAt (120)); array.Add (" 收银:"+g_user.name); array.Add ("顾客签名:"); array.Add ("");//第\r\n一\r\n联\r\n存\r\n根\r\n∧\r\n白\r\n∨\r\n第\r\n二\r\n联\r\n财\r\n务\r\n∧\r\n黄\r\n∨\r\n第\r\n三\r\n联\r\n客\r\n户\r\n∧\r\n红\r\n∨"); g_pMainWnd->PrintReceipt_01(&array); // 2销收入,应该使用PrintReceipt_01,需要显示支付方式 Jeff } /* insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype]) select [id],[money],[dat],[renyuan2],[paytype] from singleincome where payed is null***update [singleincome] set [payed]=(select sum(cast(money as float)) from [singleincomemoney] where [singleincome].[id]=[singleincomemoney].[id])***update [singleincome] set [balance]=cast(money as float)-cast(payed as float) */