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. #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. // EmployeeForm2
  16. IMPLEMENT_DYNCREATE(EmployeeForm2, MyFormView)
  17. EmployeeForm2::EmployeeForm2()
  18. : MyFormView(EmployeeForm2::IDD)
  19. {
  20. //{{AFX_DATA_INIT(EmployeeForm2)
  21. m_filter = _T("");
  22. m_check1 = FALSE;
  23. m_check2 = FALSE;
  24. //}}AFX_DATA_INIT
  25. }
  26. EmployeeForm2::~EmployeeForm2()
  27. {
  28. }
  29. void EmployeeForm2::DoDataExchange(CDataExchange* pDX)
  30. {
  31. MyFormView::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(EmployeeForm2)
  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(EmployeeForm2, MyFormView)
  42. //{{AFX_MSG_MAP(EmployeeForm2)
  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. // EmployeeForm2 diagnostics
  53. #ifdef _DEBUG
  54. void EmployeeForm2::AssertValid() const
  55. {
  56. MyFormView::AssertValid();
  57. }
  58. void EmployeeForm2::Dump(CDumpContext& dc) const
  59. {
  60. MyFormView::Dump(dc);
  61. }
  62. #endif //_DEBUG
  63. /////////////////////////////////////////////////////////////////////////////
  64. // EmployeeForm2 message handlers
  65. void EmployeeForm2::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( "店名,100;姓名,60;部门,60;性别,40;电话,100;现居地,100;籍贯地址,100;身份证号码,100;婚否,60;在职,60;备注,100;生日,100" );
  79. m_List1.LoadColumnInfo (179);
  80. CStringArray m_iparray;
  81. for(int i=0; i<g_brancharray.GetSize (); i++)
  82. {
  83. if(m_iparray.GetSize ())
  84. {
  85. if(g_brancharray.ElementAt (i).ElementAt (2)==m_iparray.ElementAt (m_iparray.GetSize ()-1))continue;
  86. }
  87. m_combo1.AddString (g_brancharray.ElementAt (i).ElementAt (0)); m_iparray.Add (g_brancharray.ElementAt (i).ElementAt (2));
  88. }
  89. GetData();
  90. m_combo1.GetWindowRect (rc2);
  91. ScreenToClient(rc2);
  92. rc2.bottom +=200;
  93. m_combo1.MoveWindow (rc2);
  94. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  95. SetComboHei(&m_combo1, rc2.Height ());
  96. }
  97. void EmployeeForm2::FillGrid(BOOL bStatus)
  98. {
  99. m_List1.DeleteAllItems2 ();
  100. int ii=0;
  101. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  102. int count=0;
  103. if(m_filter.IsEmpty ())
  104. {
  105. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  106. {
  107. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  108. }
  109. }
  110. else
  111. {
  112. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  113. {
  114. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  115. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  116. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  117. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  118. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 || \
  119. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1|| \
  120. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1|| \
  121. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  122. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  123. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  124. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 )
  125. {
  126. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  127. }
  128. }
  129. }
  130. m_List1.m_arLabels.SetSize(count, 1);
  131. ii=count;
  132. m_List1.m_LabelCount=ii;
  133. m_List1.SetItemCountEx (ii);
  134. CString str;
  135. str.Format ("人数:%d", ii);
  136. SetDlgItemText(IDC_STATIC2, str);
  137. }
  138. void EmployeeForm2::OnBUTclose()
  139. {
  140. // TODO: Add your control notification handler code here
  141. GetParent()->SendMessage(WM_CLOSE);
  142. }
  143. void EmployeeForm2::OnSelchangeCombo1()
  144. {
  145. // TODO: Add your control notification handler code here
  146. SetTimer(1, 100, NULL);
  147. }
  148. void EmployeeForm2::OnTimer(UINT nIDEvent)
  149. {
  150. // TODO: Add your message handler code here and/or call default
  151. KillTimer(nIDEvent);
  152. OnButton1();
  153. }
  154. BOOL EmployeeForm2::PreTranslateMessage(MSG* pMsg)
  155. {
  156. // TODO: Add your specialized code here and/or call the base class
  157. try
  158. {
  159. if(pMsg->message==WM_KEYDOWN)
  160. {
  161. switch (pMsg->wParam)
  162. {
  163. case VK_RETURN:
  164. OnButton1();
  165. return 1;
  166. case 0x43: // copy
  167. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  168. {
  169. GetFocus()->SendMessage(WM_COPY);
  170. return TRUE;
  171. }
  172. break;
  173. case 0x56: //Ctrl + V:
  174. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  175. {
  176. GetFocus()->SendMessage(WM_PASTE);
  177. return TRUE;
  178. }
  179. break;
  180. case 0x58: // cut
  181. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  182. {
  183. GetFocus()->SendMessage(WM_CUT);
  184. return TRUE;
  185. }
  186. break;
  187. case 0x5A: //undo
  188. case 0x59: //redo
  189. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  190. {
  191. GetFocus()->SendMessage(WM_UNDO);
  192. return TRUE;
  193. }
  194. break;
  195. }
  196. }
  197. return MyFormView::PreTranslateMessage(pMsg);
  198. }
  199. catch(...)
  200. {
  201. }
  202. }
  203. void EmployeeForm2::OnButton1()
  204. {
  205. // TODO: Add your control notification handler code here
  206. UpdateData();
  207. m_filter.TrimLeft ();
  208. m_filter.TrimRight ();
  209. FillGrid();
  210. }
  211. void EmployeeForm2::GetData()
  212. {
  213. m_List1array.RemoveAll ();
  214. CStringArray failbrancharray;
  215. CString branch;
  216. int i = 0;
  217. for( 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. }