EmployeeForm2.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. int i = 0;
  218. for( i=-1; i<g_brancharray.GetSize ()-1; i++)
  219. {
  220. if(i!=-1)
  221. {
  222. branch=g_brancharray.ElementAt (i).ElementAt (0);
  223. g_branchip=g_brancharray.ElementAt (i).ElementAt (1);
  224. g_pMainWnd->OnDisconnect();
  225. g_branchname=branch;
  226. g_bBranchModify=1;
  227. }
  228. else
  229. branch=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  230. g_sendhead.bsql=0;
  231. g_sendhead.code[0]=80;
  232. g_sendhead.tabcount=1;
  233. g_pMainWnd->ProcessChatMessageRequest2(1);
  234. if(g_bSendOK==0)
  235. {
  236. failbrancharray.Add (branch);
  237. continue;
  238. }
  239. CArray<CStringArray, CStringArray>List1array;
  240. DataToArray(&List1array);
  241. int size=m_List1array.GetSize ();
  242. for(int j=0; j<List1array.GetSize (); j++)
  243. {
  244. size++;
  245. m_List1array.SetSize(size , 1 );
  246. size--;
  247. m_List1array.ElementAt (size).Copy (List1array.ElementAt (j));
  248. m_List1array.ElementAt (size).SetAt (0, branch);
  249. size++;
  250. }
  251. }
  252. m_List1arrayBak.SetSize(m_List1array.GetSize ());
  253. for( i=0; i<m_List1array.GetSize (); i++)
  254. {
  255. m_List1arrayBak.ElementAt (i).Copy (m_List1array.ElementAt (i));
  256. if(m_List1array.ElementAt (i).ElementAt (10).GetLength ()>256)
  257. m_List1array.ElementAt (i).SetAt (10, m_List1array.ElementAt (i).ElementAt (10).Left (256)+"..");
  258. }
  259. OnCheck1();
  260. // FillGrid();
  261. g_pMainWnd->OnDisconnect();g_bBranchModify=0;g_branchip=g_branchname="";
  262. }
  263. extern void CovertDate2(CString &date);
  264. extern void CovertDate3(CString &date);
  265. void EmployeeForm2::OnCheck1()
  266. {
  267. // TODO: Add your control notification handler code here
  268. UpdateData();
  269. m_List1array.RemoveAll();
  270. m_List1array.SetSize(m_List1arrayBak.GetSize (), 1);
  271. CString today=g_date;
  272. CString todaynl=g_date;
  273. CovertDate2(todaynl);
  274. CTime todaytm=GetTmFromStr(today);
  275. CString birthday,days;
  276. int size=0;
  277. for(int i=0; i<m_List1arrayBak.GetSize (); i++)
  278. {
  279. if(m_check1)
  280. {
  281. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  282. days="未填";
  283. if(birthday.GetLength()==18)
  284. {
  285. birthday=birthday.Mid(6, 8);
  286. birthday.Insert(6, "-");
  287. birthday.Insert(4, "-");
  288. birthday=today.Left(4)+birthday.Right(6);
  289. birthday=todaynl.Left(4)+birthday.Right(6);
  290. CovertDate3(birthday);
  291. CTime tm=GetTmFromStr(birthday);
  292. CTimeSpan dt=tm-todaytm;
  293. int ndays=dt.GetDays();
  294. if(ndays<0)ndays+=365;
  295. days.Format("%d天后生日", ndays);
  296. if(ndays==0)
  297. days="今天生日";
  298. if(m_check2 && ndays>30)continue;
  299. }
  300. else if(m_check2)continue;
  301. }
  302. else
  303. {
  304. birthday=m_List1arrayBak.ElementAt (i).ElementAt (7);
  305. days="未填";
  306. if(birthday.GetLength()==18)
  307. {
  308. birthday=birthday.Mid(6, 8);
  309. birthday.Insert(6, "-");
  310. birthday.Insert(4, "-");
  311. birthday=today.Left(4)+birthday.Right(6);
  312. CTime tm=GetTmFromStr(birthday);
  313. CTimeSpan dt=tm-todaytm;
  314. int ndays=dt.GetDays(); if(ndays<0)ndays+=365;
  315. days.Format("%d天后生日", ndays);
  316. if(ndays==0)
  317. days="今天生日";
  318. if(m_check2 && ndays>30)continue;
  319. }
  320. else if(m_check2)continue;
  321. }
  322. m_List1array.ElementAt (size).Copy (m_List1arrayBak.ElementAt (i));
  323. m_List1array.ElementAt (size).Add(days);
  324. size++;
  325. }
  326. m_List1array.SetSize(size, 1);
  327. FillGrid();
  328. }
  329. void EmployeeForm2::OnCheck2()
  330. {
  331. // TODO: Add your control notification handler code here
  332. OnCheck1();
  333. }