PayOutInput.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. // PayOutInput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "PayOutInput.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // PayOutInput
  14. IMPLEMENT_DYNCREATE(PayOutInput, CFormView)
  15. PayOutInput::PayOutInput()
  16. : CFormView(PayOutInput::IDD)
  17. {
  18. //{{AFX_DATA_INIT(PayOutInput)
  19. m_bz = _T("");
  20. m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  21. m_money = _T("");
  22. m_name = _T("");
  23. m_renyuan2 = g_user.name;
  24. m_renyuan1 = _T("");
  25. m_year = CTime::GetCurrentTime ().GetYear ();
  26. m_month = CTime::GetCurrentTime ().GetMonth ();
  27. m_day = CTime::GetCurrentTime ().GetDay ();
  28. m_bInit=0;
  29. //}}AFX_DATA_INIT
  30. }
  31. PayOutInput::~PayOutInput()
  32. {
  33. }
  34. void PayOutInput::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CFormView::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(PayOutInput)
  38. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  39. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  40. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  41. DDX_Control(pDX, IDC_COMBOrenyuan1, m_comborenyuan);
  42. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  43. DDX_Control(pDX, IDC_LIST1, m_list2);
  44. DDX_Control(pDX, IDC_LIST2, m_List1);
  45. DDX_Control(pDX, IDC_STATIC1, m_static1);
  46. DDX_Text(pDX, IDC_EDITbz, m_bz);
  47. DDX_Text(pDX, IDC_EDITdate, m_date);
  48. DDX_Text(pDX, IDC_EDITmoney, m_money);
  49. DDX_Text(pDX, IDC_EDITname, m_name);
  50. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  51. DDX_CBString(pDX, IDC_COMBOrenyuan1, m_renyuan1);
  52. DDX_Text(pDX, IDC_EDITday, m_day);
  53. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  54. DDX_Text(pDX, IDC_EDITmonth, m_month);
  55. DDV_MinMaxUInt(pDX, m_month, 1, 31);
  56. DDX_Text(pDX, IDC_EDITyear, m_year);
  57. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(PayOutInput, CFormView)
  61. //{{AFX_MSG_MAP(PayOutInput)
  62. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  63. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  64. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  65. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  66. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  67. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  68. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  69. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  70. //}}AFX_MSG_MAP
  71. END_MESSAGE_MAP()
  72. /////////////////////////////////////////////////////////////////////////////
  73. // PayOutInput diagnostics
  74. #ifdef _DEBUG
  75. void PayOutInput::AssertValid() const
  76. {
  77. CFormView::AssertValid();
  78. }
  79. void PayOutInput::Dump(CDumpContext& dc) const
  80. {
  81. CFormView::Dump(dc);
  82. }
  83. #endif //_DEBUG
  84. /////////////////////////////////////////////////////////////////////////////
  85. // PayOutInput message handlers
  86. void PayOutInput::OnInitialUpdate()
  87. {
  88. CFormView::OnInitialUpdate();
  89. // TODO: Add your specialized code here and/or call the base class
  90. CMyMdi Mdi;
  91. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  92. // Here we create the outbar control using the splitter as its parent
  93. // and setting its id to the first pane.
  94. CRect rc2;
  95. GetWindowRect(rc2);
  96. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  97. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  98. m_static1.SetFont (&g_titlefont);
  99. m_List1.SetHeadings("id,0;费用项目, 130;金额, 60;日期, 90;取款人,100;经手人,100;备注,110" );
  100. m_List1.LoadColumnInfo (105);
  101. g_sendhead.bsql=0;
  102. g_sendhead.code[0]=12;
  103. g_sendhead.tabcount=1;
  104. g_pMainWnd->ProcessChatMessageRequest2(12);if(g_bSendOK==0)return;
  105. DataToArray(&g_List1array);
  106. for(int i=0; i<g_userarray.GetSize (); i++)
  107. m_comborenyuan.AddString (g_userarray.ElementAt (i).ElementAt (1));
  108. m_comborenyuan.GetWindowRect (rc2);
  109. ScreenToClient(rc2);
  110. rc2.bottom +=200;
  111. m_comborenyuan.MoveWindow (rc2);
  112. for(int ii=0; ii<g_List1array.GetSize (); ii++)
  113. {
  114. m_list2.AddString (g_List1array.ElementAt (ii).ElementAt(0));
  115. }
  116. m_spinyear.SetRange (1900, 3000);
  117. m_spinmonth.SetRange (1, 12);
  118. m_spinday.SetRange (1, 31);
  119. m_bInit=1;
  120. GetData();
  121. }
  122. void PayOutInput::FillGrid()
  123. {
  124. m_List1.DeleteAllItems2 ();
  125. int ii=0;
  126. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  127. int count=0;
  128. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  129. {
  130. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  131. }
  132. m_List1.m_arLabels.SetSize(count, 1);
  133. ii=count;
  134. m_List1.m_LabelCount=ii;
  135. m_List1.SetItemCountEx (ii);
  136. }
  137. void PayOutInput::OnBUTclose()
  138. {
  139. // TODO: Add your control notification handler code here
  140. GetParent()->SendMessage(WM_CLOSE);
  141. }
  142. void PayOutInput::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  143. {
  144. // TODO: Add your control notification handler code here
  145. // ListSelChange();
  146. *pResult = 0;
  147. }
  148. void PayOutInput::ListSelChange()
  149. {
  150. POSITION pos;
  151. pos=m_List1.GetFirstSelectedItemPosition();
  152. if(pos==NULL)
  153. {
  154. return;
  155. }
  156. int iItem=m_List1.GetNextSelectedItem(pos);
  157. CString id=m_List1.GetItemText (iItem, 0);
  158. for(int ii=0; ii<m_List1array.GetSize (); ii++)
  159. {
  160. if(m_List1array.ElementAt (ii).ElementAt (0)==id)
  161. {
  162. CString bm;
  163. m_name = m_List1array.ElementAt (ii).ElementAt (1);
  164. m_money = m_List1array.ElementAt (ii).ElementAt (2);
  165. m_date = m_List1array.ElementAt (ii).ElementAt (3);
  166. m_renyuan1 = m_List1array.ElementAt (ii).ElementAt (4);
  167. m_renyuan2 = m_List1array.ElementAt (ii).ElementAt (5);
  168. m_bz = m_List1array.ElementAt (ii).ElementAt (6);
  169. UpdateData(false);
  170. return;
  171. }
  172. }
  173. }
  174. void PayOutInput::OnBUTsave()
  175. {
  176. // TODO: Add your control notification handler code here
  177. UpdateData();
  178. m_name.TrimRight ();
  179. if(m_name.IsEmpty () || m_money.IsEmpty () )
  180. {
  181. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  182. return;
  183. }
  184. CString sql;
  185. sql.Format ("insert into gudingfeiyong([name],[money],[dat],[renyuan1],[renyuan2],[bz])\
  186. values('%s','%s','%s','%s','%s','%s')",m_name,m_money,m_date,m_renyuan1,m_renyuan2,m_bz);
  187. sql+=GDFY_REF;
  188. g_sendhead.bsql=1;
  189. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  190. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  191. GetData();
  192. }
  193. void PayOutInput::OnBUTdel()
  194. {
  195. // TODO: Add your control notification handler code here
  196. POSITION pos;
  197. pos=m_List1.GetFirstSelectedItemPosition();
  198. if(pos==NULL)
  199. {
  200. return;
  201. }
  202. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  203. int iItem=m_List1.GetNextSelectedItem(pos);
  204. CString id=m_List1.GetItemText (iItem, 0);
  205. CString sql;
  206. sql.Format ("delete from gudingfeiyong where id=%d ", atoi(id));
  207. sql+=GDFY_REF;
  208. g_sendhead.bsql=1;
  209. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  210. GetData();
  211. }
  212. void PayOutInput::GetData()
  213. {
  214. if(m_bInit==0)return;
  215. UpdateData();
  216. CString sql,strdate;
  217. strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
  218. sql.Format ("dat='"+strdate+"'");
  219. g_sendhead.bsql=0;
  220. g_sendhead.code[0]=13;
  221. g_sendhead.tabcount=1;
  222. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  223. DataToArray(&m_List1array);
  224. FillGrid();
  225. m_date=strdate;
  226. UpdateData(false);
  227. }
  228. void PayOutInput::ClearCtrl()
  229. {
  230. m_bz = _T("");
  231. m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  232. m_money = _T("");
  233. m_name = _T("");
  234. m_renyuan1 = _T("");
  235. m_renyuan2 = g_user.name;
  236. UpdateData(false);
  237. }
  238. void PayOutInput::OnSelchangeList1()
  239. {
  240. // TODO: Add your control notification handler code here
  241. int pos=m_list2.GetCurSel ();
  242. if(pos==-1)return;
  243. CString str;
  244. m_list2.GetText (pos, str);
  245. m_name=str;
  246. m_bz = _T("");
  247. m_money = _T("");
  248. m_renyuan1 = _T("");
  249. UpdateData(false);
  250. }
  251. void PayOutInput::OnChangeEDITyear()
  252. {
  253. // TODO: If this is a RICHEDIT control, the control will not
  254. // send this notification unless you override the CFormView::OnInitDialog()
  255. // function and call CRichEditCtrl().SetEventMask()
  256. // with the ENM_CHANGE flag ORed into the mask.
  257. GetData();
  258. // TODO: Add your control notification handler code here
  259. }
  260. void PayOutInput::OnChangeEDITmonth()
  261. {
  262. // TODO: If this is a RICHEDIT control, the control will not
  263. // send this notification unless you override the CFormView::OnInitDialog()
  264. // function and call CRichEditCtrl().SetEventMask()
  265. // with the ENM_CHANGE flag ORed into the mask.
  266. GetData();
  267. // TODO: Add your control notification handler code here
  268. }
  269. void PayOutInput::OnChangeEDITday()
  270. {
  271. // TODO: If this is a RICHEDIT control, the control will not
  272. // send this notification unless you override the CFormView::OnInitDialog()
  273. // function and call CRichEditCtrl().SetEventMask()
  274. // with the ENM_CHANGE flag ORed into the mask.
  275. GetData();
  276. // TODO: Add your control notification handler code here
  277. }
  278. BOOL PayOutInput::PreTranslateMessage(MSG* pMsg)
  279. {
  280. // TODO: Add your specialized code here and/or call the base class
  281. try
  282. {
  283. if(pMsg->message==WM_KEYDOWN)
  284. {
  285. switch (pMsg->wParam)
  286. {
  287. case 0x43: // copy
  288. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  289. {
  290. GetFocus()->SendMessage(WM_COPY);
  291. return TRUE;
  292. }
  293. break;
  294. case 0x56: //Ctrl + V:
  295. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  296. {
  297. GetFocus()->SendMessage(WM_PASTE);
  298. return TRUE;
  299. }
  300. break;
  301. case 0x58: // cut
  302. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  303. {
  304. GetFocus()->SendMessage(WM_CUT);
  305. return TRUE;
  306. }
  307. break;
  308. case 0x5A: //undo
  309. case 0x59: //redo
  310. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  311. {
  312. GetFocus()->SendMessage(WM_UNDO);
  313. return TRUE;
  314. }
  315. break;
  316. }
  317. }
  318. return CFormView::PreTranslateMessage(pMsg);
  319. }
  320. catch(...)
  321. {
  322. }
  323. }