EmployeeForm2.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. // EmployeeForm2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "EmployeeForm2.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. // EmployeeForm2
  17. IMPLEMENT_DYNCREATE(EmployeeForm2, MyFormView)
  18. EmployeeForm2::EmployeeForm2()
  19. : MyFormView(EmployeeForm2::IDD)
  20. {
  21. //{{AFX_DATA_INIT(EmployeeForm2)
  22. m_filter = _T("");
  23. m_check1 = FALSE;
  24. m_check2 = FALSE;
  25. //}}AFX_DATA_INIT
  26. }
  27. EmployeeForm2::~EmployeeForm2()
  28. {
  29. }
  30. void EmployeeForm2::DoDataExchange(CDataExchange* pDX)
  31. {
  32. MyFormView::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(EmployeeForm2)
  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(EmployeeForm2, MyFormView)
  43. //{{AFX_MSG_MAP(EmployeeForm2)
  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. // EmployeeForm2 diagnostics
  54. #ifdef _DEBUG
  55. void EmployeeForm2::AssertValid() const
  56. {
  57. MyFormView::AssertValid();
  58. }
  59. void EmployeeForm2::Dump(CDumpContext& dc) const
  60. {
  61. MyFormView::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. /////////////////////////////////////////////////////////////////////////////
  65. // EmployeeForm2 message handlers
  66. void EmployeeForm2::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( "店名,100;姓名,60;部门,60;性别,40;电话,100;现居地,100;籍贯地址,100;身份证号码,100;婚否,60;在职,60;备注,100;生日,100" );
  80. m_List1.LoadColumnInfo (179);
  81. CStringArray m_iparray;
  82. for(int i=0; i<g_brancharray.GetSize (); i++)
  83. {
  84. if(m_iparray.GetSize ())
  85. {
  86. if(g_brancharray.ElementAt (i).ElementAt (2)==m_iparray.ElementAt (m_iparray.GetSize ()-1))continue;
  87. }
  88. m_combo1.AddString (g_brancharray.ElementAt (i).ElementAt (0)); m_iparray.Add (g_brancharray.ElementAt (i).ElementAt (2));
  89. }
  90. GetData();
  91. m_combo1.GetWindowRect (rc2);
  92. ScreenToClient(rc2);
  93. rc2.bottom +=200;
  94. m_combo1.MoveWindow (rc2);
  95. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  96. SetComboHei(&m_combo1, rc2.Height ());
  97. }
  98. void EmployeeForm2::FillGrid(BOOL bStatus)
  99. {
  100. m_List1.DeleteAllItems2 ();
  101. int ii=0;
  102. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  103. int count=0;
  104. if(m_filter.IsEmpty ())
  105. {
  106. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  107. {
  108. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  109. }
  110. }
  111. else
  112. {
  113. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  114. {
  115. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  116. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  117. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  118. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  119. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 || \
  120. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1|| \
  121. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1|| \
  122. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  123. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  124. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  125. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 )
  126. {
  127. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  128. }
  129. }
  130. }
  131. m_List1.m_arLabels.SetSize(count, 1);
  132. ii=count;
  133. m_List1.m_LabelCount=ii;
  134. m_List1.SetItemCountEx (ii);
  135. CString str;
  136. str.Format ("人数:%d", ii);
  137. SetDlgItemText(IDC_STATIC2, str);
  138. }
  139. void EmployeeForm2::OnBUTclose()
  140. {
  141. // TODO: Add your control notification handler code here
  142. GetParent()->SendMessage(WM_CLOSE);
  143. }
  144. void EmployeeForm2::OnSelchangeCombo1()
  145. {
  146. // TODO: Add your control notification handler code here
  147. SetTimer(1, 100, NULL);
  148. }
  149. void EmployeeForm2::OnTimer(UINT nIDEvent)
  150. {
  151. // TODO: Add your message handler code here and/or call default
  152. KillTimer(nIDEvent);
  153. OnButton1();
  154. }
  155. BOOL EmployeeForm2::PreTranslateMessage(MSG* pMsg)
  156. {
  157. // TODO: Add your specialized code here and/or call the base class
  158. try
  159. {
  160. if(pMsg->message==WM_KEYDOWN)
  161. {
  162. switch (pMsg->wParam)
  163. {
  164. case VK_RETURN:
  165. OnButton1();
  166. return 1;
  167. case 0x43: // copy
  168. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  169. {
  170. GetFocus()->SendMessage(WM_COPY);
  171. return TRUE;
  172. }
  173. break;
  174. case 0x56: //Ctrl + V:
  175. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  176. {
  177. GetFocus()->SendMessage(WM_PASTE);
  178. return TRUE;
  179. }
  180. break;
  181. case 0x58: // cut
  182. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  183. {
  184. GetFocus()->SendMessage(WM_CUT);
  185. return TRUE;
  186. }
  187. break;
  188. case 0x5A: //undo
  189. case 0x59: //redo
  190. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  191. {
  192. GetFocus()->SendMessage(WM_UNDO);
  193. return TRUE;
  194. }
  195. break;
  196. }
  197. }
  198. return MyFormView::PreTranslateMessage(pMsg);
  199. }
  200. catch(...)
  201. {
  202. }
  203. }
  204. void EmployeeForm2::OnButton1()
  205. {
  206. // TODO: Add your control notification handler code here
  207. UpdateData();
  208. m_filter.TrimLeft ();
  209. m_filter.TrimRight ();
  210. FillGrid();
  211. }
  212. void EmployeeForm2::GetData()
  213. {
  214. m_List1array.RemoveAll ();
  215. CStringArray failbrancharray;
  216. CString branch;
  217. for(int i=-1; i<g_brancharray.GetSize ()-1; i++)
  218. {
  219. if(i!=-1)
  220. {
  221. branch=g_brancharray.ElementAt (i).ElementAt (0);
  222. g_branchip=g_brancharray.ElementAt (i).ElementAt (1);
  223. g_pMainWnd->OnDisconnect();
  224. g_branchname=branch;
  225. g_bBranchModify=1;
  226. }
  227. else
  228. branch=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  229. g_sendhead.bsql=0;
  230. g_sendhead.code[0]=80;
  231. g_sendhead.tabcount=1;
  232. g_pMainWnd->ProcessChatMessageRequest2(1);
  233. if(g_bSendOK==0)
  234. {
  235. failbrancharray.Add (branch);
  236. continue;
  237. }
  238. CArray<CStringArray, CStringArray>List1array;
  239. DataToArray(&List1array);
  240. int size=m_List1array.GetSize ();
  241. for(int j=0; j<List1array.GetSize (); j++)
  242. {
  243. size++;
  244. m_List1array.SetSize(size , 1 );
  245. size--;
  246. m_List1array.ElementAt (size).Copy (List1array.ElementAt (j));
  247. m_List1array.ElementAt (size).SetAt (0, branch);
  248. size++;
  249. }
  250. }
  251. m_List1arrayBak.SetSize(m_List1array.GetSize ());
  252. for( i=0; i<m_List1array.GetSize (); i++)
  253. {
  254. m_List1arrayBak.ElementAt (i).Copy (m_List1array.ElementAt (i));
  255. if(m_List1array.ElementAt (i).ElementAt (10).GetLength ()>256)
  256. m_List1array.ElementAt (i).SetAt (10, m_List1array.ElementAt (i).ElementAt (10).Left (256)+"..");
  257. }
  258. OnCheck1();
  259. // FillGrid();
  260. g_pMainWnd->OnDisconnect();g_bBranchModify=0;g_branchip=g_branchname="";
  261. }
  262. extern void CovertDate2(CString &date);
  263. extern void CovertDate3(CString &date);
  264. void EmployeeForm2::OnCheck1()
  265. {
  266. // TODO: Add your control notification handler code here
  267. UpdateData();
  268. m_List1array.RemoveAll();
  269. m_List1array.SetSize(m_List1arrayBak.GetSize (), 1);
  270. CString today=g_date;
  271. CString todaynl=g_date;
  272. CovertDate2(todaynl);
  273. CTime todaytm=GetTmFromStr(today);
  274. CString birthday,days;
  275. int size=0;
  276. for(int i=0; i<m_List1arrayBak.GetSize (); i++)
  277. {
  278. if(m_check1)
  279. {
  280. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  281. days="未填";
  282. if(birthday.GetLength()==18)
  283. {
  284. birthday=birthday.Mid(6, 8);
  285. birthday.Insert(6, "-");
  286. birthday.Insert(4, "-");
  287. birthday=today.Left(4)+birthday.Right(6);
  288. birthday=todaynl.Left(4)+birthday.Right(6);
  289. CovertDate3(birthday);
  290. CTime tm=GetTmFromStr(birthday);
  291. CTimeSpan dt=tm-todaytm;
  292. int ndays=dt.GetDays();
  293. if(ndays<0)ndays+=365;
  294. days.Format("%d天后生日", ndays);
  295. if(ndays==0)
  296. days="今天生日";
  297. if(m_check2 && ndays>30)continue;
  298. }
  299. else if(m_check2)continue;
  300. }
  301. else
  302. {
  303. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  304. days="未填";
  305. if(birthday.GetLength()==18)
  306. {
  307. birthday=birthday.Mid(6, 8);
  308. birthday.Insert(6, "-");
  309. birthday.Insert(4, "-");
  310. birthday=today.Left(4)+birthday.Right(6);
  311. CTime tm=GetTmFromStr(birthday);
  312. CTimeSpan dt=tm-todaytm;
  313. int ndays=dt.GetDays(); if(ndays<0)ndays+=365;
  314. days.Format("%d天后生日", ndays);
  315. if(ndays==0)
  316. days="今天生日";
  317. if(m_check2 && ndays>30)continue;
  318. }
  319. else if(m_check2)continue;
  320. }
  321. m_List1array.ElementAt (size).Copy (m_List1arrayBak.ElementAt (i));
  322. m_List1array.ElementAt (size).Add(days);
  323. size++;
  324. }
  325. m_List1array.SetSize(size, 1);
  326. FillGrid();
  327. }
  328. void EmployeeForm2::OnCheck2()
  329. {
  330. // TODO: Add your control notification handler code here
  331. OnCheck1();
  332. }