IncomeInput3.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. // IncomeInput3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "IncomeInput3.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. // IncomeInput3
  14. IMPLEMENT_DYNCREATE(IncomeInput3, MyFormView)
  15. IncomeInput3::IncomeInput3()
  16. : MyFormView(IncomeInput3::IDD)
  17. {
  18. //{{AFX_DATA_INIT(IncomeInput3)
  19. m_bz = _T("");
  20. m_date = g_date;
  21. m_money = _T("");
  22. m_name = _T("");
  23. m_renyuan2 = g_user.name;
  24. m_year = atoi(g_date.Mid(0, 4));
  25. m_month = atoi(g_date.Mid(5, 2));
  26. m_day = atoi(g_date.Mid(8, 2));
  27. m_bInit = 0;
  28. m_bAdd = 1;
  29. //}}AFX_DATA_INIT
  30. }
  31. IncomeInput3::~IncomeInput3()
  32. {
  33. }
  34. void IncomeInput3::DoDataExchange(CDataExchange* pDX)
  35. {
  36. MyFormView::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(IncomeInput3)
  38. DDX_Control(pDX, IDC_COMBO7, m_comboexecute);
  39. DDX_Control(pDX, IDC_COMBO4, m_combotype);
  40. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  41. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  42. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  43. DDX_Control(pDX, IDC_COMBO2, m_comboren);
  44. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  45. DDX_Control(pDX, IDC_LIST2, m_List1);
  46. DDX_Control(pDX, IDC_STATIC1, m_static1);
  47. DDX_Text(pDX, IDC_EDITbz, m_bz);
  48. DDV_MaxChars(pDX, m_bz, 1000);
  49. DDX_Text(pDX, IDC_EDITdate, m_date);
  50. DDX_Text(pDX, IDC_EDITmoney, m_money);
  51. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  52. DDX_Text(pDX, IDC_EDITyear, m_year);
  53. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  54. DDX_Text(pDX, IDC_EDITmonth, m_month);
  55. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  56. DDX_Text(pDX, IDC_EDITday, m_day);
  57. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(IncomeInput3, MyFormView)
  61. //{{AFX_MSG_MAP(IncomeInput3)
  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_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  67. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  68. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  69. //}}AFX_MSG_MAP
  70. END_MESSAGE_MAP()
  71. /////////////////////////////////////////////////////////////////////////////
  72. // IncomeInput3 diagnostics
  73. #ifdef _DEBUG
  74. void IncomeInput3::AssertValid() const
  75. {
  76. MyFormView::AssertValid();
  77. }
  78. void IncomeInput3::Dump(CDumpContext& dc) const
  79. {
  80. MyFormView::Dump(dc);
  81. }
  82. #endif //_DEBUG
  83. /////////////////////////////////////////////////////////////////////////////
  84. // IncomeInput3 message handlers
  85. void IncomeInput3::OnInitialUpdate()
  86. {
  87. MyFormView::OnInitialUpdate();
  88. // TODO: Add your specialized code here and/or call the base class
  89. CMyMdi Mdi;
  90. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  91. // Here we create the outbar control using the splitter as its parent
  92. // and setting its id to the first pane.
  93. CRect rc2;
  94. GetWindowRect(rc2);
  95. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  96. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  97. m_comboren.RefDroppedWidth();
  98. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(60));
  99. m_static1.SetFont(&g_titlefont);
  100. m_List1.SetHeadings("id,0;相关人员,100;奖罚类别,100;奖罚金额, 100;是否执行, 100;日期,100;经手人,100;备注,100");
  101. m_List1.LoadColumnInfo(142);
  102. m_comboren.GetWindowRect(rc2);
  103. ScreenToClient(rc2);
  104. rc2.bottom += 400;
  105. m_comboren.MoveWindow(rc2);
  106. m_comboexecute.GetWindowRect(rc2);
  107. ScreenToClient(rc2);
  108. rc2.bottom += 400;
  109. m_comboexecute.MoveWindow(rc2);
  110. m_combotype.GetWindowRect(rc2);
  111. ScreenToClient(rc2);
  112. rc2.bottom += 400;
  113. m_combotype.MoveWindow(rc2);
  114. m_combotype.AddString("奖励");
  115. m_combotype.AddString("惩罚");
  116. m_comboexecute.AddString("未执行");
  117. m_comboexecute.AddString("已执行");
  118. m_spinyear.SetRange(1900, 3000);
  119. m_spinmonth.SetRange(1, 12);
  120. m_spinday.SetRange(1, 31);
  121. for (int i = 0; i < g_userarray.GetSize(); i++)
  122. m_comboren.AddString(g_userarray.ElementAt(i).ElementAt(1));
  123. m_bInit = 1;
  124. GetData();
  125. }
  126. void IncomeInput3::FillGrid()
  127. {
  128. m_List1.DeleteAllItems2();
  129. int ii = 0;
  130. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  131. int count = 0;
  132. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  133. {
  134. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  135. }
  136. m_List1.m_arLabels.SetSize(count, 1);
  137. ii = count;
  138. m_List1.m_LabelCount = ii;
  139. m_List1.SetItemCountEx(ii);
  140. }
  141. void IncomeInput3::OnBUTclose()
  142. {
  143. // TODO: Add your control notification handler code here
  144. GetParent()->SendMessage(WM_CLOSE);
  145. }
  146. void IncomeInput3::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  147. {
  148. // TODO: Add your control notification handler code here
  149. ListSelChange();
  150. *pResult = 0;
  151. }
  152. void IncomeInput3::ListSelChange()
  153. {
  154. GetDlgItem(IDC_BUTsave)->EnableWindow(1);
  155. POSITION pos;
  156. pos = m_List1.GetFirstSelectedItemPosition();
  157. if (pos == NULL)
  158. {
  159. ClearCtrl();
  160. m_bAdd = 1;
  161. return;
  162. }
  163. int iItem = m_List1.GetNextSelectedItem(pos);
  164. m_bAdd = 0;
  165. CString id = m_List1.GetItemText(iItem, 0);
  166. for (int ii = 0; ii < m_List1array.GetSize(); ii++)
  167. {
  168. if (m_List1array.ElementAt(ii).ElementAt(0) == id)
  169. {
  170. CString ren = m_List1array.ElementAt(ii).ElementAt(1);
  171. if (m_comboren.FindString(0, ren) == -1)
  172. m_comboren.AddString(ren);
  173. m_comboren.SetCurSel(m_comboren.FindString(0, ren));
  174. CString type = m_List1array.ElementAt(ii).ElementAt(2);
  175. if (m_combotype.FindString(0, type) == -1)
  176. m_combotype.AddString(type);
  177. m_combotype.SetCurSel(m_combotype.FindString(0, type));
  178. m_money = m_List1array.ElementAt(ii).ElementAt(3);
  179. CString execute = m_List1array.ElementAt(ii).ElementAt(4);
  180. if (m_comboexecute.FindString(0, execute) == -1)
  181. m_comboexecute.AddString(execute);
  182. m_comboexecute.SetCurSel(m_comboexecute.FindString(0, execute));
  183. m_date = m_List1array.ElementAt(ii).ElementAt(5);
  184. m_renyuan2 = m_List1array.ElementAt(ii).ElementAt(6);
  185. m_bz = m_List1array.ElementAt(ii).ElementAt(7);
  186. UpdateData(false);
  187. return;
  188. }
  189. }
  190. }
  191. void IncomeInput3::OnBUTsave()
  192. {
  193. // TODO: Add your control notification handler code here
  194. UpdateData();
  195. CString m_renyuan3;
  196. int pos = m_comboren.GetCurSel();
  197. if (pos == -1)
  198. {
  199. AfxMessageBox("请填写相关人员!", MB_ICONINFORMATION);
  200. return;
  201. }
  202. m_comboren.GetLBText(pos, m_renyuan3);
  203. CString type;
  204. pos = m_combotype.GetCurSel();
  205. if (pos == -1)
  206. {
  207. AfxMessageBox("请选择类别!", MB_ICONINFORMATION);
  208. return;
  209. }
  210. m_combotype.GetLBText(pos, type);
  211. CString execute;
  212. pos = m_comboexecute.GetCurSel();
  213. if (pos == -1)
  214. {
  215. AfxMessageBox("请选择类别!", MB_ICONINFORMATION);
  216. return;
  217. }
  218. m_comboexecute.GetLBText(pos, execute);
  219. CString sql;
  220. if (m_bAdd)
  221. sql.Format("insert into rewards([name],[type],[money],[execute],[date],[renyuan],[bz])values('%s','%s','%s','%s','%s','%s','%s')", m_renyuan3, type, m_money, execute, m_date, m_renyuan2, m_bz);
  222. else
  223. {
  224. POSITION pos;
  225. pos = m_List1.GetFirstSelectedItemPosition();
  226. if (pos == NULL)
  227. {
  228. return;
  229. }
  230. int iItem = m_List1.GetNextSelectedItem(pos);
  231. CString id = m_List1.GetItemText(iItem, 0);
  232. sql.Format("update rewards set [name]='%s',[type]='%s',[money]='%s',[execute]='%s',[date]='%s',[renyuan]='%s',[bz]='%s' where [id]=%d", m_renyuan3, type, m_money, execute, m_date, m_renyuan2, m_bz, atol(id));
  233. }
  234. g_sendhead.bsql = 1;
  235. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  236. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  237. GetData();
  238. }
  239. void IncomeInput3::OnBUTdel()
  240. {
  241. // TODO: Add your control notification handler code here
  242. if (IsHasRights2new(60) == 0)return;
  243. POSITION pos;
  244. pos = m_List1.GetFirstSelectedItemPosition();
  245. if (pos == NULL)
  246. {
  247. return;
  248. }
  249. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  250. int iItem = m_List1.GetNextSelectedItem(pos);
  251. CString id = m_List1.GetItemText(iItem, 0);
  252. CString sql;
  253. sql.Format("delete from rewards where id=%d ", atoi(id));
  254. g_sendhead.bsql = 1;
  255. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  256. GetData();
  257. }
  258. void IncomeInput3::GetData()
  259. {
  260. if (m_bInit == 0)return;
  261. UpdateData();
  262. g_sendhead.bsql = 0;
  263. g_sendhead.code[0] = 88;
  264. g_sendhead.tabcount = 1;
  265. g_pMainWnd->ProcessChatMessageRequest2(1);
  266. if (g_bSendOK == 0)
  267. {
  268. return;
  269. }
  270. DataToArray(&m_List1array);
  271. FillGrid();
  272. }
  273. void IncomeInput3::ClearCtrl()
  274. {
  275. UpdateData();
  276. m_bz = _T("");
  277. m_date = g_date;
  278. m_money = _T("");
  279. m_name = _T("");
  280. m_renyuan2 = g_user.name;
  281. UpdateData(false);
  282. m_comboren.SetCurSel(-1);
  283. m_comboexecute.SetCurSel(0);
  284. m_combotype.SetCurSel(0);
  285. }
  286. void IncomeInput3::OnChangeEDITyear()
  287. {
  288. // TODO: If this is a RICHEDIT control, the control will not
  289. // send this notification unless you override the MyFormView::OnInitDialog()
  290. // function and call CRichEditCtrl().SetEventMask()
  291. // with the ENM_CHANGE flag ORed into the mask.
  292. GetData();
  293. // TODO: Add your control notification handler code here
  294. }
  295. void IncomeInput3::OnChangeEDITmonth()
  296. {
  297. // TODO: If this is a RICHEDIT control, the control will not
  298. // send this notification unless you override the MyFormView::OnInitDialog()
  299. // function and call CRichEditCtrl().SetEventMask()
  300. // with the ENM_CHANGE flag ORed into the mask.
  301. GetData();
  302. // TODO: Add your control notification handler code here
  303. }
  304. void IncomeInput3::OnChangeEDITday()
  305. {
  306. // TODO: If this is a RICHEDIT control, the control will not
  307. // send this notification unless you override the MyFormView::OnInitDialog()
  308. // function and call CRichEditCtrl().SetEventMask()
  309. // with the ENM_CHANGE flag ORed into the mask.
  310. GetData();
  311. // TODO: Add your control notification handler code here
  312. }
  313. BOOL IncomeInput3::PreTranslateMessage(MSG* pMsg)
  314. {
  315. // TODO: Add your specialized code here and/or call the base class
  316. try
  317. {
  318. if (pMsg->message == WM_KEYDOWN)
  319. {
  320. switch (pMsg->wParam)
  321. {
  322. case 0x43: // copy
  323. if ((GetKeyState(VK_CONTROL) & 0x80))
  324. {
  325. GetFocus()->SendMessage(WM_COPY);
  326. return TRUE;
  327. }
  328. break;
  329. case 0x56: //Ctrl + V:
  330. if ((GetKeyState(VK_CONTROL) & 0x80))
  331. {
  332. GetFocus()->SendMessage(WM_PASTE);
  333. return TRUE;
  334. }
  335. break;
  336. case 0x58: // cut
  337. if ((GetKeyState(VK_CONTROL) & 0x80))
  338. {
  339. GetFocus()->SendMessage(WM_CUT);
  340. return TRUE;
  341. }
  342. break;
  343. case 0x5A: //undo
  344. case 0x59: //redo
  345. if ((GetKeyState(VK_CONTROL) & 0x80))
  346. {
  347. GetFocus()->SendMessage(WM_UNDO);
  348. return TRUE;
  349. }
  350. break;
  351. }
  352. }
  353. return MyFormView::PreTranslateMessage(pMsg);
  354. }
  355. catch (...)
  356. {
  357. }
  358. }