EmployeeForm.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. // EmployeeForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "EmployeeForm.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. //#pragma comment(lib, "Shlwapi.lib")
  15. /////////////////////////////////////////////////////////////////////////////
  16. // EmployeeForm
  17. IMPLEMENT_DYNCREATE(EmployeeForm, MyFormView)
  18. EmployeeForm::EmployeeForm()
  19. : MyFormView(EmployeeForm::IDD)
  20. {
  21. //{{AFX_DATA_INIT(EmployeeForm)
  22. m_filter = _T("");
  23. m_check1 = FALSE;
  24. m_check2 = FALSE;
  25. //}}AFX_DATA_INIT
  26. }
  27. EmployeeForm::~EmployeeForm()
  28. {
  29. }
  30. void EmployeeForm::DoDataExchange(CDataExchange* pDX)
  31. {
  32. MyFormView::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(EmployeeForm)
  34. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  35. DDX_Control(pDX, IDC_LIST2, m_List1);
  36. DDX_Control(pDX, IDC_STATIC1, m_static1);
  37. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  38. DDX_Check(pDX, IDC_CHECK1, m_check1);
  39. DDX_Check(pDX, IDC_CHECK2, m_check2);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(EmployeeForm, MyFormView)
  43. //{{AFX_MSG_MAP(EmployeeForm)
  44. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  45. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  46. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  47. ON_WM_TIMER()
  48. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  49. ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // EmployeeForm diagnostics
  54. #ifdef _DEBUG
  55. void EmployeeForm::AssertValid() const
  56. {
  57. MyFormView::AssertValid();
  58. }
  59. void EmployeeForm::Dump(CDumpContext& dc) const
  60. {
  61. MyFormView::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. /////////////////////////////////////////////////////////////////////////////
  65. // EmployeeForm message handlers
  66. void EmployeeForm::OnInitialUpdate()
  67. {
  68. MyFormView::OnInitialUpdate();
  69. // TODO: Add your specialized code here and/or call the base class
  70. CMyMdi Mdi;
  71. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  72. // Here we create the outbar control using the splitter as its parent
  73. // and setting its id to the first pane.
  74. CRect rc2;
  75. GetWindowRect(rc2);
  76. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  77. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  78. m_static1.SetFont(&g_titlefont);
  79. m_List1.SetHeadings("编号,40;姓名,60;部门,60;性别,40;电话,100;现居地,100;籍贯地址,100;身份证号码,100;婚否,60;在职,60;备注,60;生日,100");
  80. m_List1.LoadColumnInfo(138);
  81. g_sendhead.bsql = 0;
  82. g_sendhead.code[0] = 80;
  83. g_sendhead.tabcount = 1;
  84. g_pMainWnd->ProcessChatMessageRequest2(1);
  85. if (g_bSendOK == 0)return;
  86. DataToArray(&m_List1array);
  87. m_List1arrayBak.SetSize(m_List1array.GetSize());
  88. int i = 0;
  89. for ( i = 0; i < m_List1array.GetSize(); i++)
  90. {
  91. m_List1arrayBak.ElementAt(i).Copy(m_List1array.ElementAt(i));
  92. if (m_List1array.ElementAt(i).ElementAt(10).GetLength()>256)
  93. m_List1array.ElementAt(i).SetAt(10, m_List1array.ElementAt(i).ElementAt(10).Left(256) + "..");
  94. }
  95. OnCheck1();
  96. for (i = 0; i < m_List1array.GetSize(); i++)
  97. {
  98. m_combo1.AddString(m_List1array.ElementAt(i).ElementAt(1));
  99. }
  100. m_combo1.GetWindowRect(rc2);
  101. ScreenToClient(rc2);
  102. rc2.bottom += 200;
  103. m_combo1.MoveWindow(rc2);
  104. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  105. SetComboHei(&m_combo1, rc2.Height());
  106. }
  107. void EmployeeForm::FillGrid(BOOL bStatus)
  108. {
  109. m_List1.DeleteAllItems2();
  110. int ii = 0;
  111. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  112. int count = 0;
  113. if (m_filter.IsEmpty())
  114. {
  115. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  116. {
  117. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  118. }
  119. }
  120. else
  121. {
  122. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  123. {
  124. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  125. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  126. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  127. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  128. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  129. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  130. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \
  131. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  132. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  133. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  134. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1)
  135. {
  136. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  137. }
  138. }
  139. }
  140. m_List1.m_arLabels.SetSize(count, 1);
  141. ii = count;
  142. m_List1.m_LabelCount = ii;
  143. m_List1.SetItemCountEx(ii);
  144. CString str;
  145. str.Format("人数:%d", ii);
  146. SetDlgItemText(IDC_STATIC2, str);
  147. CRect rc;
  148. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  149. ScreenToClient(rc);
  150. InvalidateRect(rc);
  151. }
  152. void EmployeeForm::OnBUTclose()
  153. {
  154. // TODO: Add your control notification handler code here
  155. GetParent()->SendMessage(WM_CLOSE);
  156. }
  157. void EmployeeForm::OnSelchangeCombo1()
  158. {
  159. // TODO: Add your control notification handler code here
  160. SetTimer(1, 100, NULL);
  161. }
  162. void EmployeeForm::OnTimer(UINT nIDEvent)
  163. {
  164. // TODO: Add your message handler code here and/or call default
  165. KillTimer(nIDEvent);
  166. OnButton1();
  167. }
  168. BOOL EmployeeForm::PreTranslateMessage(MSG* pMsg)
  169. {
  170. // TODO: Add your specialized code here and/or call the base class
  171. try
  172. {
  173. if (pMsg->message == WM_KEYDOWN)
  174. {
  175. switch (pMsg->wParam)
  176. {
  177. case VK_RETURN:
  178. OnButton1();
  179. return 1;
  180. case 0x43: // copy
  181. if ((GetKeyState(VK_CONTROL) & 0x80))
  182. {
  183. GetFocus()->SendMessage(WM_COPY);
  184. return TRUE;
  185. }
  186. break;
  187. case 0x56: //Ctrl + V:
  188. if ((GetKeyState(VK_CONTROL) & 0x80))
  189. {
  190. GetFocus()->SendMessage(WM_PASTE);
  191. return TRUE;
  192. }
  193. break;
  194. case 0x58: // cut
  195. if ((GetKeyState(VK_CONTROL) & 0x80))
  196. {
  197. GetFocus()->SendMessage(WM_CUT);
  198. return TRUE;
  199. }
  200. break;
  201. case 0x5A: //undo
  202. case 0x59: //redo
  203. if ((GetKeyState(VK_CONTROL) & 0x80))
  204. {
  205. GetFocus()->SendMessage(WM_UNDO);
  206. return TRUE;
  207. }
  208. break;
  209. }
  210. }
  211. return MyFormView::PreTranslateMessage(pMsg);
  212. }
  213. catch (...)
  214. {
  215. }
  216. }
  217. void EmployeeForm::OnButton1()
  218. {
  219. // TODO: Add your control notification handler code here
  220. UpdateData();
  221. m_filter.TrimLeft();
  222. m_filter.TrimRight();
  223. FillGrid();
  224. }
  225. extern void CovertDate2(CString &date);
  226. extern void CovertDate3(CString &date);
  227. void EmployeeForm::OnCheck1()
  228. {
  229. // TODO: Add your control notification handler code here
  230. UpdateData();
  231. m_List1array.RemoveAll();
  232. m_List1array.SetSize(m_List1arrayBak.GetSize(), 1);
  233. CString today = g_date;
  234. CString todaynl = g_date;
  235. CovertDate2(todaynl);
  236. CTime todaytm = GetTmFromStr(today);
  237. CString birthday, days;
  238. int size = 0;
  239. for (int i = 0; i < m_List1arrayBak.GetSize(); i++)
  240. {
  241. if (m_check1)
  242. {
  243. birthday = m_List1arrayBak.ElementAt(i).ElementAt(7);
  244. days = "未填";
  245. if (birthday.GetLength() == 18)
  246. {
  247. birthday = birthday.Mid(6, 8);
  248. birthday.Insert(6, "-");
  249. birthday.Insert(4, "-");
  250. birthday = today.Left(4) + birthday.Right(6);
  251. birthday = todaynl.Left(4) + birthday.Right(6);
  252. CovertDate3(birthday);
  253. CTime tm = GetTmFromStr(birthday);
  254. CTimeSpan dt = tm - todaytm;
  255. int ndays = dt.GetDays();
  256. if (ndays < 0)ndays += 365;
  257. days.Format("%d天后生日", ndays);
  258. if (ndays == 0)
  259. days = "今天生日";
  260. if (m_check2 && ndays > 30)continue;
  261. }
  262. else if (m_check2)continue;
  263. }
  264. else
  265. {
  266. birthday = m_List1arrayBak.ElementAt(i).ElementAt(7);
  267. days = "未填";
  268. if (birthday.GetLength() == 18)
  269. {
  270. birthday = birthday.Mid(6, 8);
  271. birthday.Insert(6, "-");
  272. birthday.Insert(4, "-");
  273. birthday = today.Left(4) + birthday.Right(6);
  274. CTime tm = GetTmFromStr(birthday);
  275. CTimeSpan dt = tm - todaytm;
  276. int ndays = dt.GetDays(); if (ndays < 0)ndays += 365;
  277. days.Format("%d天后生日", ndays);
  278. if (ndays == 0)
  279. days = "今天生日";
  280. if (m_check2 && ndays > 30)continue;
  281. }
  282. else if (m_check2)continue;
  283. }
  284. m_List1array.ElementAt(size).Copy(m_List1arrayBak.ElementAt(i));
  285. m_List1array.ElementAt(size).Add(days);
  286. size++;
  287. }
  288. m_List1array.SetSize(size, 1);
  289. FillGrid();
  290. }
  291. void EmployeeForm::OnCheck2()
  292. {
  293. // TODO: Add your control notification handler code here
  294. OnCheck1();
  295. }