EmployeeForm2.cpp 9.2 KB

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