TakeMoney3.cpp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. // TakeMoney3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "TakeMoney3.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // TakeMoney3 dialog
  13. TakeMoney3::TakeMoney3(CWnd* pParent /*=NULL*/)
  14. : CDialog(TakeMoney3::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(TakeMoney3)
  17. m_money = _T("");
  18. m_time1 = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  19. m_bz = _T("");
  20. m_id = _T("");
  21. m_name1 = _T("");
  22. m_name2 = _T("");
  23. m_ren2 = _T("");
  24. m_money2 = _T("");
  25. m_ren3 = _T("");
  26. m_time2 = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  27. m_bz2 =_T("");
  28. m_mode=0;
  29. m_bInit=0;
  30. m_sum1 = _T("");
  31. m_sum2 = _T("");
  32. m_sum3 = _T("");
  33. //}}AFX_DATA_INIT
  34. }
  35. void TakeMoney3::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(TakeMoney3)
  39. DDX_Control(pDX, IDC_LIST3, m_List2);
  40. DDX_Control(pDX, IDC_EDIT4, m_editctrl3);
  41. DDX_Control(pDX, IDC_LIST1, m_List1);
  42. DDX_Control(pDX, IDC_EDIT2, m_editdate1);
  43. DDX_Control(pDX, IDC_EDIT1, m_editctrl1);
  44. DDX_Control(pDX, IDC_COMBO1, m_comboren);
  45. DDX_Text(pDX, IDC_EDIT1, m_money);
  46. DDX_Text(pDX, IDC_EDIT2, m_time1);
  47. DDX_Text(pDX, IDC_EDIT3, m_bz);
  48. DDX_Text(pDX, IDC_EDITid, m_id);
  49. DDX_Text(pDX, IDC_EDITname1, m_name1);
  50. DDX_Text(pDX, IDC_EDITname2, m_name2);
  51. DDX_Text(pDX, IDC_EDITren2, m_ren2);
  52. DDX_Text(pDX, IDC_EDIT4, m_money2);
  53. DDX_Text(pDX, IDC_EDITren3, m_ren3);
  54. DDX_Text(pDX, IDC_EDIT5, m_time2);
  55. DDX_Text(pDX, IDC_EDIT6, m_bz2);
  56. DDX_Text(pDX, IDC_EDITmoney2, m_sum1);
  57. DDX_Text(pDX, IDC_EDITmoney3, m_sum2);
  58. DDX_Text(pDX, IDC_EDITmoney5, m_sum3);
  59. //}}AFX_DATA_MAP
  60. }
  61. BEGIN_MESSAGE_MAP(TakeMoney3, CDialog)
  62. //{{AFX_MSG_MAP(TakeMoney3)
  63. ON_WM_LBUTTONDOWN()
  64. ON_BN_CLICKED(IDOK2, OnOk2)
  65. ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
  66. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // TakeMoney3 message handlers
  71. BOOL TakeMoney3::OnInitDialog()
  72. {
  73. CDialog::OnInitDialog();
  74. // TODO: Add extra initialization here
  75. g_sendhead.bsql=0;
  76. g_sendhead.code[0]=27;
  77. g_sendhead.code[1]=38;
  78. g_sendhead.code[2]=11;
  79. g_sendhead.tabcount=3;
  80. CString filter="id='"+m_id+"';id='"+m_id+"';id='"+m_id+"'";
  81. g_pMainWnd->ProcessChatMessageRequest2(filter);
  82. if(g_bSendOK==0)return 0;
  83. CArray<CStringArray, CStringArray>dindanarray;
  84. DataToArray( &m_List1array,&m_List2array,&dindanarray);
  85. if(m_mode==2 || m_mode==3)
  86. {
  87. m_comboren.AddString (m_ren);
  88. m_comboren.SetCurSel (0);
  89. m_comboren.EnableWindow (0);
  90. GetDlgItem(IDC_EDIT3)->EnableWindow (0);
  91. }
  92. else
  93. {
  94. for(int i=0; i<g_userarray.GetSize (); i++)
  95. m_comboren.AddString (g_userarray.ElementAt (i).ElementAt (1));
  96. }
  97. CenterWindow(g_pMainWnd);
  98. if(m_mode==0)
  99. m_bz="拍照补款";
  100. else if(m_mode==1)
  101. m_bz="选片补款";
  102. SetWindowText(m_bz+"/加挑物品");
  103. m_ren2=g_user.name;
  104. m_ren3=g_user.name;
  105. CString m_taoxijiage = dindanarray.ElementAt (0).ElementAt (8);
  106. CString m_payed4 = dindanarray.ElementAt (0).ElementAt (19);
  107. CString m_payed5 = dindanarray.ElementAt (0).ElementAt (20);
  108. m_sum1.Format ("%f", atof(m_taoxijiage)+atof(m_payed4));
  109. m_sum2.Format ("%f", atof(m_payed5));
  110. m_sum3.Format ("%f", atof(m_sum1)-atof(m_sum2));
  111. ConvertToPrice(m_sum1);
  112. ConvertToPrice(m_sum2);
  113. ConvertToPrice(m_sum3);
  114. UpdateData(false);
  115. m_List1.SetHeadings("金额,60;日期,70;开单人,70;收款人,70;备注,80" );
  116. m_List1.LoadColumnInfo (115);
  117. m_List2.SetHeadings("加挑金额,80;日期,100;录单,70;加挑物品,100" );
  118. m_List2.LoadColumnInfo (123);
  119. FillGrid();
  120. m_bInit=1;
  121. if(m_mode==5)
  122. {
  123. SetWindowText("客户付款详情");
  124. GetDlgItem(IDC_EDIT1)->EnableWindow(0);
  125. GetDlgItem(IDC_COMBO1)->EnableWindow(0);
  126. GetDlgItem(IDOK)->EnableWindow(0);
  127. GetDlgItem(IDC_EDIT4)->EnableWindow(0);
  128. GetDlgItem(IDC_EDIT6)->EnableWindow(0);
  129. GetDlgItem(IDOK2)->EnableWindow(0);
  130. GetDlgItem(IDC_BUTTON1)->EnableWindow(0);
  131. }
  132. return TRUE; // return TRUE unless you set the focus to a control
  133. // EXCEPTION: OCX Property Pages should return FALSE
  134. }
  135. void TakeMoney3::OnOK()
  136. {
  137. // TODO: Add extra validation here
  138. UpdateData();
  139. if(m_money.IsEmpty ())
  140. {
  141. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  142. return;
  143. }
  144. int pos;
  145. pos=m_comboren.GetCurSel();
  146. if(pos==-1)
  147. {
  148. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  149. return;
  150. }
  151. m_comboren.GetLBText (pos, m_ren);
  152. BOOL bexist1=0;
  153. BOOL bexist2=0;
  154. if(bexist1==0)
  155. {
  156. for(int i=0; i<m_List1array.GetSize (); i++)
  157. {
  158. if(m_List1array.ElementAt (i).ElementAt (0)==m_money)
  159. {
  160. bexist1=1;
  161. break;
  162. }
  163. }
  164. }
  165. if(bexist2==0)
  166. {
  167. for(int i=0; i<m_List1array.GetSize (); i++)
  168. {
  169. if(m_List1array.ElementAt (i).ElementAt (4)==m_bz)
  170. {
  171. bexist2=1;
  172. break;
  173. }
  174. }
  175. }
  176. if(bexist1 && bexist2)
  177. {
  178. if(AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)
  179. return;
  180. }
  181. CString sql,sql2;
  182. sql.Format ("insert into dindanbukuan([id],[money],[ren],[date],[bz],[ren2],[kind])\
  183. values('%s','%s','%s','%s','%s','%s','%d')", m_id,m_money ,m_ren,m_time1 ,m_bz,m_ren2,m_mode+1);
  184. sql2="###"+m_id;
  185. sql+=sql2;
  186. sql+=BUKUAN_REF;
  187. g_sendhead.bsql=1;
  188. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  189. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  190. GetData();
  191. // CDialog::OnOK();
  192. }
  193. HBRUSH TakeMoney3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  194. {
  195. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  196. // TODO: Change any attributes of the DC here
  197. if (nCtlColor==CTLCOLOR_STATIC)
  198. {
  199. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  200. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  201. }
  202. // TODO: Return a different brush if the default is not desired
  203. return hbr;
  204. }
  205. void TakeMoney3::OnLButtonDown(UINT nFlags, CPoint point)
  206. {
  207. // TODO: Add your message handler code here and/or call default
  208. CDialog::OnLButtonDown(nFlags, point);
  209. }
  210. void TakeMoney3::GetData()
  211. {
  212. g_sendhead.bsql=0;
  213. g_sendhead.code[0]=27;
  214. g_sendhead.code[1]=38;
  215. g_sendhead.code[2]=11;
  216. g_sendhead.tabcount=3;
  217. CString filter="id='"+m_id+"';id='"+m_id+"';id='"+m_id+"'";
  218. g_pMainWnd->ProcessChatMessageRequest2(filter);
  219. if(g_bSendOK==0)return;
  220. CArray<CStringArray, CStringArray>dindanarray;
  221. DataToArray( &m_List1array, &m_List2array, &dindanarray);
  222. FillGrid();
  223. CString m_taoxijiage = dindanarray.ElementAt (0).ElementAt (8);
  224. CString m_payed4 = dindanarray.ElementAt (0).ElementAt (19);
  225. CString m_payed5 = dindanarray.ElementAt (0).ElementAt (20);
  226. m_sum1.Format ("%f", atof(m_taoxijiage)+atof(m_payed4));
  227. m_sum2.Format ("%f", atof(m_payed5));
  228. m_sum3.Format ("%f", atof(m_sum1)-atof(m_sum2));
  229. ConvertToPrice(m_sum1);
  230. ConvertToPrice(m_sum2);
  231. ConvertToPrice(m_sum3);
  232. UpdateData(false);
  233. }
  234. void TakeMoney3::FillGrid()
  235. {
  236. m_List1.DeleteAllItems2 ();
  237. int ii=0;
  238. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  239. int count=0;
  240. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  241. {
  242. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  243. }
  244. m_List1.m_arLabels.SetSize(count, 1);
  245. ii=count;
  246. m_List1.m_LabelCount=ii;
  247. m_List1.SetItemCountEx (ii);
  248. {
  249. m_List2.DeleteAllItems2 ();
  250. int ii=0;
  251. m_List2.m_arLabels.SetSize( m_List2array.GetSize (), 1 );
  252. int count=0;
  253. for(ii=0; ii<m_List2.m_arLabels.GetSize (); ii++)
  254. {
  255. m_List2.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
  256. }
  257. m_List2.m_arLabels.SetSize(count, 1);
  258. ii=count;
  259. m_List2.m_LabelCount=ii;
  260. m_List2.SetItemCountEx (ii);
  261. }
  262. }
  263. BOOL TakeMoney3::PreTranslateMessage(MSG* pMsg)
  264. {
  265. // TODO: Add your specialized code here and/or call the base class
  266. if(pMsg->message==WM_KEYDOWN)
  267. {
  268. switch (pMsg->wParam)
  269. {
  270. case VK_RETURN:
  271. return 1;
  272. }
  273. }
  274. return CDialog::PreTranslateMessage(pMsg);
  275. }
  276. void TakeMoney3::OnOk2()
  277. {
  278. // TODO: Add your control notification handler code here
  279. UpdateData();
  280. m_bz2.TrimLeft ();
  281. m_money2.TrimLeft ();
  282. if(m_money2.IsEmpty ())
  283. {
  284. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  285. return;
  286. }
  287. if(m_bz2.IsEmpty ())
  288. {
  289. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  290. return;
  291. }
  292. BOOL bexist1=0;
  293. if(bexist1==0)
  294. {
  295. for(int i=0; i<m_List2array.GetSize (); i++)
  296. {
  297. if(m_List2array.ElementAt (i).ElementAt (0)==m_money2)
  298. {
  299. bexist1=1;
  300. break;
  301. }
  302. }
  303. }
  304. if(bexist1)
  305. {
  306. if(AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)
  307. return;
  308. }
  309. CString sql,sql2;
  310. sql.Format ("insert into dindanbukuan2([id],[money],[date],[bz],[ren2],[kind])\
  311. values('%s','%s','%s','%s','%s','%d')", m_id,m_money2 ,m_time1 ,m_bz2,m_ren3,m_mode+1);
  312. sql2="$$$"+m_id;
  313. sql+=sql2;
  314. sql+=BUKUAN_REF2;
  315. g_sendhead.bsql=1;
  316. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  317. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  318. GetData();
  319. }
  320. void TakeMoney3::OnChangeEdit1()
  321. {
  322. // TODO: If this is a RICHEDIT control, the control will not
  323. // send this notification unless you override the CDialog::OnInitDialog()
  324. // function and call CRichEditCtrl().SetEventMask()
  325. // with the ENM_CHANGE flag ORed into the mask.
  326. if(m_bInit==0)return;
  327. UpdateData();
  328. SetDlgItemText(IDC_EDIT4, m_money);
  329. // TODO: Add your control notification handler code here
  330. }
  331. void TakeMoney3::OnButton1()
  332. {
  333. // TODO: Add your control notification handler code here
  334. SPBox dlg;
  335. if(dlg.DoModal ()!=IDOK)return;
  336. SetDlgItemText(IDC_EDIT6, dlg.m_spname );
  337. }
  338. void TakeMoney3::RefreshMoney()
  339. {
  340. }