EmployeeForm.cpp 8.1 KB

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