EmployeeForm.cpp 8.1 KB

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