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. #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. m_List1arrayBak.SetSize(m_List1array.GetSize ());
  90. for(int i=0; i<m_List1array.GetSize (); i++)
  91. {
  92. m_List1arrayBak.ElementAt (i).Copy (m_List1array.ElementAt (i));
  93. if(m_List1array.ElementAt (i).ElementAt (10).GetLength ()>256)
  94. m_List1array.ElementAt (i).SetAt (10, m_List1array.ElementAt (i).ElementAt (10).Left (256)+"..");
  95. }
  96. OnCheck1();
  97. for( i=0; i<m_List1array.GetSize (); i++)
  98. {
  99. m_combo1.AddString (m_List1array.ElementAt (i).ElementAt (1) );
  100. }
  101. m_combo1.GetWindowRect (rc2);
  102. ScreenToClient(rc2);
  103. rc2.bottom +=200;
  104. m_combo1.MoveWindow (rc2);
  105. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  106. SetComboHei(&m_combo1, rc2.Height ());
  107. }
  108. void EmployeeForm::FillGrid(BOOL bStatus)
  109. {
  110. m_List1.DeleteAllItems2 ();
  111. int ii=0;
  112. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  113. int count=0;
  114. if(m_filter.IsEmpty ())
  115. {
  116. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  117. {
  118. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  119. }
  120. }
  121. else
  122. {
  123. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  124. {
  125. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  126. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  127. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  128. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  129. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 || \
  130. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1|| \
  131. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1|| \
  132. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  133. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  134. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  135. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 )
  136. {
  137. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  138. }
  139. }
  140. }
  141. m_List1.m_arLabels.SetSize(count, 1);
  142. ii=count;
  143. m_List1.m_LabelCount=ii;
  144. m_List1.SetItemCountEx (ii);
  145. CString str;
  146. str.Format ("人数:%d", ii);
  147. SetDlgItemText(IDC_STATIC2, str);
  148. CRect rc;
  149. GetDlgItem(IDC_STATIC2)->GetWindowRect (rc);
  150. ScreenToClient(rc);
  151. InvalidateRect(rc);
  152. }
  153. void EmployeeForm::OnBUTclose()
  154. {
  155. // TODO: Add your control notification handler code here
  156. GetParent()->SendMessage(WM_CLOSE);
  157. }
  158. void EmployeeForm::OnSelchangeCombo1()
  159. {
  160. // TODO: Add your control notification handler code here
  161. SetTimer(1, 100, NULL);
  162. }
  163. void EmployeeForm::OnTimer(UINT nIDEvent)
  164. {
  165. // TODO: Add your message handler code here and/or call default
  166. KillTimer(nIDEvent);
  167. OnButton1();
  168. }
  169. BOOL EmployeeForm::PreTranslateMessage(MSG* pMsg)
  170. {
  171. // TODO: Add your specialized code here and/or call the base class
  172. try
  173. {
  174. if(pMsg->message==WM_KEYDOWN)
  175. {
  176. switch (pMsg->wParam)
  177. {
  178. case VK_RETURN:
  179. OnButton1();
  180. return 1;
  181. case 0x43: // copy
  182. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  183. {
  184. GetFocus()->SendMessage(WM_COPY);
  185. return TRUE;
  186. }
  187. break;
  188. case 0x56: //Ctrl + V:
  189. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  190. {
  191. GetFocus()->SendMessage(WM_PASTE);
  192. return TRUE;
  193. }
  194. break;
  195. case 0x58: // cut
  196. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  197. {
  198. GetFocus()->SendMessage(WM_CUT);
  199. return TRUE;
  200. }
  201. break;
  202. case 0x5A: //undo
  203. case 0x59: //redo
  204. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  205. {
  206. GetFocus()->SendMessage(WM_UNDO);
  207. return TRUE;
  208. }
  209. break;
  210. }
  211. }
  212. return MyFormView::PreTranslateMessage(pMsg);
  213. }
  214. catch(...)
  215. {
  216. }
  217. }
  218. void EmployeeForm::OnButton1()
  219. {
  220. // TODO: Add your control notification handler code here
  221. UpdateData();
  222. m_filter.TrimLeft ();
  223. m_filter.TrimRight ();
  224. FillGrid();
  225. }
  226. extern void CovertDate2(CString &date);
  227. extern void CovertDate3(CString &date);
  228. void EmployeeForm::OnCheck1()
  229. {
  230. // TODO: Add your control notification handler code here
  231. UpdateData();
  232. m_List1array.RemoveAll();
  233. m_List1array.SetSize(m_List1arrayBak.GetSize (), 1);
  234. CString today=g_date;
  235. CString todaynl=g_date;
  236. CovertDate2(todaynl);
  237. CTime todaytm=GetTmFromStr(today);
  238. CString birthday,days;
  239. int size=0;
  240. for(int i=0; i<m_List1arrayBak.GetSize (); i++)
  241. {
  242. if(m_check1)
  243. {
  244. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  245. days="未填";
  246. if(birthday.GetLength()==18)
  247. {
  248. birthday=birthday.Mid(6, 8);
  249. birthday.Insert(6, "-");
  250. birthday.Insert(4, "-");
  251. birthday=today.Left(4)+birthday.Right(6);
  252. birthday=todaynl.Left(4)+birthday.Right(6);
  253. CovertDate3(birthday);
  254. CTime tm=GetTmFromStr(birthday);
  255. CTimeSpan dt=tm-todaytm;
  256. int ndays=dt.GetDays();
  257. if(ndays<0)ndays+=365;
  258. days.Format("%d天后生日", ndays);
  259. if(ndays==0)
  260. days="今天生日";
  261. if(m_check2 && ndays>30)continue;
  262. }
  263. else if(m_check2)continue;
  264. }
  265. else
  266. {
  267. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  268. days="未填";
  269. if(birthday.GetLength()==18)
  270. {
  271. birthday=birthday.Mid(6, 8);
  272. birthday.Insert(6, "-");
  273. birthday.Insert(4, "-");
  274. birthday=today.Left(4)+birthday.Right(6);
  275. CTime tm=GetTmFromStr(birthday);
  276. CTimeSpan dt=tm-todaytm;
  277. int ndays=dt.GetDays(); if(ndays<0)ndays+=365;
  278. days.Format("%d天后生日", ndays);
  279. if(ndays==0)
  280. days="今天生日";
  281. if(m_check2 && ndays>30)continue;
  282. }
  283. else if(m_check2)continue;
  284. }
  285. m_List1array.ElementAt (size).Copy (m_List1arrayBak.ElementAt (i));
  286. m_List1array.ElementAt (size).Add(days);
  287. size++;
  288. }
  289. m_List1array.SetSize(size, 1);
  290. FillGrid();
  291. }
  292. void EmployeeForm::OnCheck2()
  293. {
  294. // TODO: Add your control notification handler code here
  295. OnCheck1();
  296. }