TakeMoney.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // TakeMoney.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "LYFZIPManage.h"
  4. #include "TakeMoney.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // TakeMoney dialog
  12. TakeMoney::TakeMoney(CWnd* pParent /*=NULL*/)
  13. : CDialog(TakeMoney::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(TakeMoney)
  16. m_money = _T("");
  17. m_time1 = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  18. m_bz = _T("");
  19. m_id = _T("");
  20. m_name1 = _T("");
  21. m_name2 = _T("");
  22. m_mode=0;
  23. m_ren2 = _T("");
  24. //}}AFX_DATA_INIT
  25. }
  26. void TakeMoney::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(TakeMoney)
  30. DDX_Control(pDX, IDC_LIST1, m_List1);
  31. DDX_Control(pDX, IDC_EDIT2, m_editdate1);
  32. DDX_Control(pDX, IDC_EDIT1, m_editctrl1);
  33. DDX_Control(pDX, IDC_COMBO1, m_comboren);
  34. DDX_Text(pDX, IDC_EDIT1, m_money);
  35. DDX_Text(pDX, IDC_EDIT2, m_time1);
  36. DDX_Text(pDX, IDC_EDIT3, m_bz);
  37. DDX_Text(pDX, IDC_EDITid, m_id);
  38. DDX_Text(pDX, IDC_EDITname1, m_name1);
  39. DDX_Text(pDX, IDC_EDITname2, m_name2);
  40. DDX_Text(pDX, IDC_EDITren2, m_ren2);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(TakeMoney, CDialog)
  44. //{{AFX_MSG_MAP(TakeMoney)
  45. ON_WM_LBUTTONDOWN()
  46. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // TakeMoney message handlers
  51. BOOL TakeMoney::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. // TODO: Add extra initialization here
  55. g_sendhead.bsql=0;
  56. g_sendhead.code[0]=38;
  57. g_sendhead.tabcount=1;
  58. CString filter="id='"+m_id+"'";
  59. g_pMainWnd->ProcessChatMessageRequest2(filter);
  60. DataToArray( &m_List1array);
  61. if(m_mode==2 || m_mode==3)
  62. {
  63. m_comboren.AddString (m_ren);
  64. m_comboren.SetCurSel (0);
  65. m_comboren.EnableWindow (0);
  66. GetDlgItem(IDC_EDIT3)->EnableWindow (0);
  67. }
  68. else
  69. {
  70. for(int i=0; i<g_userarray.GetSize (); i++)
  71. m_comboren.AddString (g_userarray.ElementAt (i).ElementAt (1));
  72. }
  73. CenterWindow(g_pMainWnd);
  74. if(m_mode==0)
  75. SetWindowText("拍照加挑物品");
  76. else if(m_mode==1)
  77. SetWindowText("选片加挑物品");
  78. m_ren2=g_user.name;
  79. UpdateData(false);
  80. m_List1.SetHeadings("加挑金额,80;日期,100;录单,70;加挑物品,100" );
  81. m_List1.LoadColumnInfo (123);
  82. FillGrid();
  83. return TRUE; // return TRUE unless you set the focus to a control
  84. // EXCEPTION: OCX Property Pages should return FALSE
  85. }
  86. void TakeMoney::OnOK()
  87. {
  88. // TODO: Add extra validation here
  89. UpdateData();
  90. m_bz.TrimLeft ();
  91. m_money.TrimLeft ();
  92. if(m_money.IsEmpty ())
  93. {
  94. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  95. return;
  96. }
  97. if(m_bz.IsEmpty ())
  98. {
  99. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  100. return;
  101. }
  102. CString sql,sql2;
  103. sql.Format ("insert into dindanbukuan2([id],[money],[ren],[date],[bz],[ren2],[kind])\
  104. values('%s','%s','%s','%s','%s','%s','%d')", m_id,m_money ,m_ren,m_time1 ,m_bz,m_ren2,m_mode+1);
  105. sql2="$$$"+m_id;
  106. sql+=sql2;
  107. sql+=BUKUAN_REF2;
  108. g_sendhead.bsql=1;
  109. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  110. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  111. GetData();
  112. // CDialog::OnOK();
  113. }
  114. HBRUSH TakeMoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  115. {
  116. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  117. // TODO: Change any attributes of the DC here
  118. if (nCtlColor==CTLCOLOR_STATIC)
  119. {
  120. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  121. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  122. }
  123. // TODO: Return a different brush if the default is not desired
  124. return hbr;
  125. }
  126. void TakeMoney::OnLButtonDown(UINT nFlags, CPoint point)
  127. {
  128. // TODO: Add your message handler code here and/or call default
  129. CDialog::OnLButtonDown(nFlags, point);
  130. }
  131. void TakeMoney::GetData()
  132. {
  133. g_sendhead.bsql=0;
  134. g_sendhead.code[0]=38;
  135. g_sendhead.tabcount=1;
  136. CString filter="id='"+m_id+"';";
  137. g_pMainWnd->ProcessChatMessageRequest2(filter);
  138. DataToArray( &m_List1array);
  139. FillGrid();
  140. }
  141. void TakeMoney::FillGrid()
  142. {
  143. m_List1.DeleteAllItems2 ();
  144. int ii=0;
  145. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  146. int count=0;
  147. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  148. {
  149. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  150. }
  151. m_List1.m_arLabels.SetSize(count, 1);
  152. ii=count;
  153. m_List1.m_LabelCount=ii;
  154. m_List1.SetItemCountEx (ii);
  155. }
  156. BOOL TakeMoney::PreTranslateMessage(MSG* pMsg)
  157. {
  158. // TODO: Add your specialized code here and/or call the base class
  159. if(pMsg->message==WM_KEYDOWN)
  160. {
  161. switch (pMsg->wParam)
  162. {
  163. case VK_RETURN:
  164. return 1;
  165. }
  166. }
  167. return CDialog::PreTranslateMessage(pMsg);
  168. }
  169. void TakeMoney::OnButton1()
  170. {
  171. // TODO: Add your control notification handler code here
  172. SPBox dlg;
  173. if(dlg.DoModal ()!=IDOK)return;
  174. SetDlgItemText(IDC_EDIT3, dlg.m_spname );
  175. }