LoginReg2.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. // LoginReg2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "LoginReg2.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #include "ImportPhoto.h"
  10. #include "ShowPic.h"
  11. #include "TakeMoney2.h"
  12. #include "SelWaiter2.h"
  13. #include "TakeStautsSel.h"
  14. #include "LoginSign.h"
  15. #include "ReChargeReg.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. #pragma comment(lib, "Shlwapi.lib")
  22. /////////////////////////////////////////////////////////////////////////////
  23. // LoginReg2 IDC_STATIC16
  24. IMPLEMENT_DYNCREATE(LoginReg2, MyFormView)
  25. LoginReg2::LoginReg2()
  26. : MyFormView(LoginReg2::IDD)
  27. {
  28. //{{AFX_DATA_INIT(LoginReg2)
  29. m_year = atoi(g_date.Mid (0,4));
  30. m_month = atoi(g_date.Mid (5,2));
  31. m_bInit=0;
  32. //}}AFX_DATA_INIT
  33. }
  34. LoginReg2::~LoginReg2()
  35. {
  36. }
  37. void LoginReg2::DoDataExchange(CDataExchange* pDX)
  38. {
  39. MyFormView::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(LoginReg2)
  41. DDX_Control(pDX, IDC_LIST2, m_List1);
  42. DDX_Control(pDX, IDC_STATIC1, m_static1);
  43. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  44. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  45. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  46. DDX_Text(pDX, IDC_EDITyear, m_year);
  47. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  48. DDX_Text(pDX, IDC_EDITmonth, m_month);
  49. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(LoginReg2, MyFormView)
  53. //{{AFX_MSG_MAP(LoginReg2)
  54. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  55. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  56. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  57. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  58. ON_BN_CLICKED(IDC_BUTmoney5, OnBUTmoney5)
  59. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  60. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  61. //}}AFX_MSG_MAP
  62. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  63. END_MESSAGE_MAP()
  64. /////////////////////////////////////////////////////////////////////////////
  65. // LoginReg2 diagnostics
  66. #ifdef _DEBUG
  67. void LoginReg2::AssertValid() const
  68. {
  69. MyFormView::AssertValid();
  70. }
  71. void LoginReg2::Dump(CDumpContext& dc) const
  72. {
  73. MyFormView::Dump(dc);
  74. }
  75. #endif //_DEBUG
  76. /////////////////////////////////////////////////////////////////////////////
  77. // LoginReg2 message handlers
  78. void LoginReg2::OnInitialUpdate()
  79. {
  80. MyFormView::OnInitialUpdate();
  81. // TODO: Add your specialized code here and/or call the base class
  82. CMyMdi Mdi;
  83. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  84. if(IsHasRights2new(19)==0)
  85. {
  86. GetDlgItem(IDC_BUTmoney)->EnableWindow(0);
  87. }
  88. // Here we create the outbar control using the splitter as its parent
  89. // and setting its id to the first pane.
  90. CRect rc2;
  91. GetWindowRect(rc2);
  92. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  93. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  94. m_static1.SetFont (&g_titlefont);
  95. m_List1.SetHeadings("姓名,80;迟到,80;早退,80;旷工,80;1号,160;2号,160;3号,160;4号,160;5号,160;6号,160;7号,160;8号,160;9号,160;10号,160;11号,160;12号,160;13号,160;14号,160;15号,160;16号,160;17号,160;18号,160;19号,160;20号,160;21号,160;22号,160;23号,160;24号,160;25号,160;26号,160;27号,160;28号,160;29号,160;30号,160;31号,160" );
  96. m_List1.LoadColumnInfo (185);
  97. m_spinyear.SetRange (1900, 3000);
  98. m_spinmonth.SetRange (1, 12);
  99. m_spinday.SetRange (1, 31);
  100. m_bInit=1;
  101. GetTimeRange();
  102. CenterWindow();
  103. }
  104. int __cdecl CompareByLabel12( const void *elem1, const void *elem2)
  105. {
  106. CStringArray *p1 = (CStringArray*)elem1;
  107. CStringArray *p2 = (CStringArray*)elem2;
  108. if(p1->ElementAt (36)==p2->ElementAt (36))
  109. {
  110. return lstrcmp( p1->ElementAt (0), p2->ElementAt (0) ) ;
  111. }
  112. return (p1->ElementAt (36)>p2->ElementAt (36)?0:1) ;
  113. return 1;
  114. }
  115. int __cdecl CompareByLabel11( const void *elem1, const void *elem2)
  116. {
  117. CStringArray *p1 = (CStringArray*)elem1;
  118. CStringArray *p2 = (CStringArray*)elem2;
  119. return (p1->ElementAt (36)>p2->ElementAt (36)?0:1) ;
  120. }
  121. void LoginReg2::FillGrid(BOOL bStatus)
  122. {
  123. if(!m_List1array.GetSize ())return;
  124. qsort( static_cast<void*>(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel11 );
  125. qsort( static_cast<void*>(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel12 );
  126. m_List1.DeleteAllItems2 ();
  127. int ii=0;
  128. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  129. int count=0;
  130. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  131. {
  132. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  133. }
  134. m_List1.m_arLabels.SetSize(count, 1);
  135. ii=count;
  136. m_List1.m_LabelCount=ii;
  137. m_List1.SetItemCountEx (ii);
  138. if(!m_curname.IsEmpty ())
  139. {
  140. for(int i=0; i<m_List1.GetItemCount (); i++)
  141. {
  142. if(m_curname==m_List1.GetItemText (i, 0))
  143. {
  144. m_List1.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
  145. m_List1.EnsureVisible(i,FALSE);
  146. break;
  147. }
  148. }
  149. }
  150. }
  151. void LoginReg2::OnBUTclose()
  152. {
  153. // TODO: Add your control notification handler code here
  154. GetParent()->SendMessage(WM_CLOSE);
  155. }
  156. BOOL LoginReg2::PreTranslateMessage(MSG* pMsg)
  157. {
  158. // TODO: Add your specialized code here and/or call the base class
  159. try
  160. {
  161. if(pMsg->message==WM_KEYDOWN)
  162. {
  163. switch (pMsg->wParam)
  164. {
  165. case VK_RETURN:
  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. CString LoginReg2::GetWeekName(CString date)
  205. {
  206. CTime tm(atoi(date.Mid (0,4)),atoi(date.Mid (5,2)),atoi(date.Mid (8,2)),0,0,0);
  207. int nDayWeek = tm.GetDayOfWeek()-1;
  208. int days1=nDayWeek;
  209. int days2=6-nDayWeek;
  210. CTime tm2,tm3;
  211. CTimeSpan sp(days1, 0, 0, 0);
  212. tm2=tm-sp;
  213. CTimeSpan sp2(days2, 0, 0, 0);
  214. tm3=tm+sp2;
  215. CString m_weekname;
  216. m_weekname.Format ("%04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay () );
  217. return m_weekname;
  218. }
  219. void LoginReg2::ShowLoginData()
  220. {
  221. CStringArray weeknamearray;
  222. CString date,weekname;
  223. for(int a=1; a<=31; a++)
  224. {
  225. date.Format ("%04d-%02d-%02d", m_year, m_month, a);
  226. weekname=GetWeekName(date);
  227. if(::FindArray (&weeknamearray, weekname)==-1)
  228. weeknamearray.Add(weekname);
  229. }
  230. CString filterweekname;
  231. for( a=0; a<weeknamearray.GetSize (); a++)
  232. {
  233. weekname=weeknamearray.ElementAt (a);
  234. filterweekname+="or weekname='"+weekname+"' ";
  235. }
  236. filterweekname.TrimLeft ("or ");
  237. filterweekname.TrimRight (" ");
  238. CString filter=filterweekname+";[datetime]>'"+m_scurdate+"' and [datetime]<'"+m_scurdate2+"';dimission='在职';;[date]>'"+m_scurdate+"' and [date]<'"+m_scurdate2+"'";
  239. g_sendhead.code[0]=107;
  240. g_sendhead.code[1]=108;
  241. g_sendhead.code[2]=5;
  242. g_sendhead.code[3]=97;
  243. g_sendhead.code[4]=168;
  244. g_sendhead.tabcount=5;
  245. g_sendhead.bsql=0;
  246. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  247. CArray<CStringArray, CStringArray>m_List2array;
  248. CArray<CStringArray, CStringArray>m_List3array;
  249. CArray<CStringArray, CStringArray>m_List4array;
  250. CArray<CStringArray, CStringArray>m_List5array;
  251. CArray<CStringArray, CStringArray>m_List6array;
  252. DataToArray(&m_List5array,&m_List2array,&m_List3array,&m_List4array,&m_List6array);
  253. CStringArray array;
  254. CString no;
  255. int i;
  256. for( i=0; i<m_List2array.GetSize (); i++)
  257. {
  258. no=m_List2array.ElementAt (i).ElementAt (0);
  259. int pos=FindArray(&array, no);
  260. if(pos!=-1)
  261. {
  262. m_List2array.ElementAt (i).SetAt (0, array.ElementAt (pos+1));
  263. }
  264. else
  265. {
  266. BOOL bFind=0;
  267. for(int j=0; j<m_List3array.GetSize (); j++)
  268. {
  269. if(no==m_List3array.ElementAt (j).ElementAt (11) || no==m_List3array.ElementAt (j).ElementAt (12))
  270. {
  271. bFind=1;
  272. array.Add (no);
  273. array.Add (m_List3array.ElementAt (j).ElementAt (1));
  274. m_List2array.ElementAt (i).SetAt (0, m_List3array.ElementAt (j).ElementAt (1) ) ;
  275. break;
  276. }
  277. }
  278. }
  279. }
  280. ///////////
  281. m_List1array.RemoveAll ();
  282. for(i=0; i<m_List5array.GetSize (); i++)
  283. {
  284. CString bStr="0";
  285. CString weekname=m_List5array.ElementAt (i).ElementAt (8);
  286. CString name=m_List5array.ElementAt (i).ElementAt (0);
  287. int curpos=FindName(name);
  288. if(weekname.IsEmpty ())continue;
  289. int weekpos=GetWeekPos(weekname);//
  290. for(int j=1; j<=7; j++)
  291. {
  292. if(weekpos+j-1>=36)continue;
  293. if(weekpos+j-1<4)continue;
  294. m_List1array.ElementAt (curpos).SetAt (weekpos+j-1, m_List5array.ElementAt (i).ElementAt (j) );
  295. }
  296. }
  297. ///////////////开始填时间
  298. CTime begintm(m_year, m_month, 1, 0, 0, 0);
  299. CTime todaytm(atoi(g_date.Mid (0,4)),atoi(g_date.Mid (5,2)),atoi(g_date.Mid (8,2)),0,0,0);
  300. CString name;
  301. for(i=0; i<m_List1array.GetSize (); i++)
  302. {
  303. name=m_List1array.ElementAt (i).ElementAt (0);
  304. CString bStr="0";
  305. int ncot=0;
  306. int nTimes1=0; //迟到次数
  307. int nTimes2=0; //早退次数
  308. int nTimes3=0; //旷工次数
  309. int nMenite1=0; //迟到分钟
  310. int nMenite2=0; //早退分钟
  311. for(int j=4; j<35; j++)
  312. {
  313. CString in,out,time1,time2,time3,time4,in2,out2;
  314. CString ban=m_List1array.ElementAt (i).ElementAt (j);
  315. if(ban!="休息")
  316. {
  317. for(int a=0; a<m_List4array.GetSize (); a++)
  318. {
  319. if(ban==m_List4array.ElementAt (a).ElementAt (0))
  320. {
  321. time1=m_List4array.ElementAt (a).ElementAt (1);
  322. time2=m_List4array.ElementAt (a).ElementAt (2);
  323. time3=m_List4array.ElementAt (a).ElementAt (3);
  324. time4=m_List4array.ElementAt (a).ElementAt (4);
  325. break;
  326. }
  327. }
  328. }
  329. CTime tm=begintm+CTimeSpan(j-4, 0, 0, 0);
  330. if(tm.GetMonth ()!=m_month)continue;
  331. CString date=tm.Format("%Y-%m-%d");
  332. CStringArray array;
  333. for(int a=0; a<m_List2array.GetSize (); a++)
  334. {
  335. if(name==m_List2array.ElementAt (a).ElementAt (0) && m_List2array.ElementAt (a).ElementAt (1).Find (date)!=-1)
  336. {
  337. array.Add (m_List2array.ElementAt (a).ElementAt (1));
  338. }
  339. }
  340. if(time3!="")//多时间段
  341. {
  342. int dt1,dt2,dt3,dt4;
  343. for(int a=0; a<array.GetSize (); a++)
  344. {
  345. CString datetime=array.ElementAt (a);
  346. datetime=datetime.Mid (11, 5);
  347. // time1
  348. CTime tmcur(2012, 5, 29, atoi(datetime.Left (2)), atoi(datetime.Right(2)), 0);
  349. CTime tm1(2012, 5, 29, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  350. CTime tm2(2012, 5, 29, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  351. CTime tm3(2012, 5, 29, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
  352. CTime tm4(2012, 5, 29, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
  353. CTimeSpan sp;
  354. if(tmcur>tm1)
  355. sp=tmcur-tm1;
  356. else
  357. sp=tm1-tmcur;
  358. dt1=sp.GetHours ()*60+sp.GetMinutes ();
  359. if(tmcur>tm2)
  360. sp=tmcur-tm2;
  361. else
  362. sp=tm2-tmcur;
  363. dt2=sp.GetHours ()*60+sp.GetMinutes ();
  364. if(tmcur>tm3)
  365. sp=tmcur-tm3;
  366. else
  367. sp=tm3-tmcur;
  368. dt3=sp.GetHours ()*60+sp.GetMinutes ();
  369. if(tmcur>tm4)
  370. sp=tmcur-tm4;
  371. else
  372. sp=tm4-tmcur;
  373. dt4=sp.GetHours ()*60+sp.GetMinutes ();
  374. // CString ss;
  375. // ss.Format("%s %s-%d,%s-%d,%s-%d,%s-%d", datetime,time1,dt1, time2,dt2, time3,dt3, time4,dt4);
  376. // MessageBox(ss);
  377. if(dt1<=dt2 && dt1<=dt3 && dt1<=dt4 && in=="")
  378. {
  379. in=datetime;
  380. continue;
  381. }
  382. if(dt2<=dt1 && dt2<=dt3 && dt2<=dt4 && out=="")
  383. {
  384. out=datetime;continue;
  385. }
  386. if(dt3<=dt1 && dt3<=dt2 && dt3<=dt4 && in2=="")
  387. {
  388. in2=datetime;continue;
  389. }
  390. if(dt4<=dt1 && dt4<=dt2 && dt4<=dt3 && out2=="")
  391. {
  392. out2=datetime;continue;
  393. }
  394. }
  395. }
  396. else//单时间段
  397. {
  398. if(array.GetSize ())
  399. {
  400. in=array.ElementAt (0);
  401. in=in.Mid (11, 5);
  402. }
  403. if(array.GetSize ()>1)
  404. {
  405. out=array.ElementAt (array.GetSize ()-1);
  406. out=out.Mid (11, 5);
  407. }
  408. }
  409. for(a=0; a<m_List6array.GetSize (); a++)
  410. {
  411. if(name==m_List6array.ElementAt (a).ElementAt (1) && m_List6array.ElementAt (a).ElementAt (2).Find (date)!=-1)
  412. {
  413. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
  414. in="签单";
  415. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
  416. out="签单";
  417. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
  418. in="签单";
  419. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
  420. out="签单";
  421. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
  422. in2="签单";
  423. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
  424. out2="签单";
  425. }
  426. }
  427. if(time3=="" && array.GetSize () && in=="签单" && out!="签单")//防止上班签卡,只打了下班卡,会被认为是上班卡而没有下班时间
  428. {
  429. out=array.ElementAt (array.GetSize ()-1);
  430. out=out.Mid (11, 5);
  431. }
  432. if(time3=="")
  433. {
  434. if( (in.IsEmpty () || out.IsEmpty ()) && ban!="休息")
  435. nTimes3++;
  436. }
  437. else
  438. {
  439. if( (in.IsEmpty () || out.IsEmpty () || in2.IsEmpty () || out2.IsEmpty ()) && ban!="休息")
  440. nTimes3++;
  441. }
  442. if(time3=="")
  443. {
  444. if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
  445. {
  446. CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
  447. CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  448. CTimeSpan sp=tm1-tm2;
  449. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  450. nTimes1++;
  451. }
  452. if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
  453. {
  454. CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
  455. CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  456. CTimeSpan sp=tm2-tm1;
  457. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  458. nTimes2++;
  459. }
  460. }
  461. else//分段班
  462. {
  463. if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
  464. {
  465. CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
  466. CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  467. CTimeSpan sp=tm1-tm2;
  468. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  469. nTimes1++;
  470. }
  471. if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
  472. {
  473. CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
  474. CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  475. CTimeSpan sp=tm2-tm1;
  476. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  477. nTimes2++;
  478. }
  479. if(time3!="" && in2!="" && in2>time3 && in2!="签单")//计算迟到
  480. {
  481. CTime tm1(m_year, m_month, 1, atoi(in2.Left (2)), atoi(in2.Right(2)), 0);
  482. CTime tm2(m_year, m_month, 1, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
  483. CTimeSpan sp=tm1-tm2;
  484. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  485. nTimes1++;
  486. }
  487. if(time4!="" && out2!="" && out2<time4 && out2!="签单")//计算早退
  488. {
  489. CTime tm1(m_year, m_month, 1, atoi(out2.Left (2)), atoi(out2.Right(2)), 0);
  490. CTime tm2(m_year, m_month, 1, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
  491. CTimeSpan sp=tm2-tm1;
  492. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  493. nTimes2++;
  494. }
  495. }
  496. if(ban!="休息" && tm<todaytm)//今天或以后的不判断
  497. {
  498. if(time3!="")//多时间段
  499. {
  500. if (in>time1 && in!="签单")
  501. bStr="1";
  502. if (out<time2 && out!="签单")
  503. bStr="1";
  504. if (in2>time3 && in2!="签单")
  505. bStr="1";
  506. if (out2<time4 && out2!="签单")
  507. bStr="1";
  508. if(in==""||out==""||in2==""||out2=="")
  509. bStr="1";
  510. }
  511. else
  512. {
  513. if (in>time1 && in!="签单")
  514. bStr="1";
  515. if (out<time2 && out!="签单")
  516. bStr="1";
  517. if(in==""||out=="")
  518. bStr="1";
  519. }
  520. }
  521. if(time3!="")//多时间段
  522. m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")"+"("+in2+"-"+out2+")");
  523. else
  524. m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")");
  525. if(in!="")ncot++; if(out!="")ncot++;
  526. if(in2!="")ncot++; if(out2!="")ncot++;
  527. }
  528. m_List1array.ElementAt (i).SetAt(35, bStr);
  529. CString str;
  530. str.Format ("%d次/%d分", nTimes1, nMenite1);
  531. m_List1array.ElementAt (i).SetAt(1, str);
  532. str.Format ("%d次/%d分", nTimes2, nMenite2);
  533. m_List1array.ElementAt (i).SetAt(2, str);
  534. str.Format ("%d次", nTimes3);
  535. m_List1array.ElementAt (i).SetAt(3, str);
  536. CString scot;
  537. scot.Format("%d", ncot);
  538. m_List1array.ElementAt (i).SetAt(36, scot);
  539. }
  540. ///////////////
  541. FillGrid();
  542. }
  543. void LoginReg2::GetTimeRange()
  544. {
  545. if(!m_bInit)return;
  546. UpdateData();
  547. m_scurdate.Format ("%04d-%02d-%02d", m_year, m_month, 0);
  548. m_scurdate2.Format ("%04d-%02d-%02d", m_year, m_month, 32);
  549. ShowLoginData();
  550. }
  551. void LoginReg2::OnChangeEDITyear()
  552. {
  553. // TODO: If this is a RICHEDIT control, the control will not
  554. // send this notification unless you override the MyFormView::OnInitDialog()
  555. // function and call CRichEditCtrl().SetEventMask()
  556. // with the ENM_CHANGE flag ORed into the mask.
  557. GetTimeRange();
  558. // TODO: Add your control notification handler code here
  559. }
  560. void LoginReg2::OnChangeEDITmonth()
  561. {
  562. // TODO: If this is a RICHEDIT control, the control will not
  563. // send this notification unless you override the MyFormView::OnInitDialog()
  564. // function and call CRichEditCtrl().SetEventMask()
  565. // with the ENM_CHANGE flag ORed into the mask.
  566. GetTimeRange();
  567. // TODO: Add your control notification handler code here
  568. }
  569. void LoginReg2::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  570. {
  571. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  572. // Take the default processing unless we set this to something else below.
  573. *pResult = 0;
  574. // First thing - check the draw stage. If it's the control's prepaint
  575. // stage, then tell Windows we want messages for every item.
  576. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  577. {
  578. *pResult = CDRF_NOTIFYITEMDRAW;
  579. }
  580. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  581. {
  582. // This is the prepaint stage for an item. Here's where we set the
  583. // item's text color. Our return value will tell Windows to draw the
  584. // item itself, but it will use the new color we set here.
  585. // We'll cycle the colors through red, green, and light blue.
  586. if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (35)!="0")
  587. pLVCD->clrText = RGB(220,0,0);
  588. else
  589. pLVCD->clrText = RGB(20,133,20);
  590. if(pLVCD->nmcd.dwItemSpec%2)
  591. pLVCD->clrTextBk = g_gridcol1;
  592. else
  593. pLVCD->clrTextBk = g_gridcol2;
  594. // Store the color back in the NMLVCUSTOMDRAW struct.
  595. // Tell Windows to paint the control itself.
  596. *pResult = CDRF_DODEFAULT;
  597. }
  598. }
  599. int LoginReg2::FindName(CString name)
  600. {
  601. for(int i=0; i<m_List1array.GetSize (); i++)
  602. {
  603. if(name==m_List1array.ElementAt (i).ElementAt (0))return i;
  604. }
  605. int size=m_List1array.GetSize ();
  606. m_List1array.SetSize (size+1, 1);
  607. m_List1array.ElementAt (size).SetSize(37);
  608. m_List1array.ElementAt (size).SetAt (0, name);
  609. return size;
  610. }
  611. int LoginReg2::GetWeekPos(CString weekname)
  612. {
  613. CTime tm1(m_year, m_month, 1, 0, 0, 0);
  614. CTime tm2(atoi(weekname.Mid (0,4)),atoi(weekname.Mid (5,2)),atoi(weekname.Mid (8,2)),0,0,0);
  615. CTimeSpan sp=tm2-tm1;
  616. // CString ss;
  617. // ss.Format ("%s-%s %d", tm1.Format ("%Y-%m-%d"), tm2.Format ("%Y-%m-%d"), sp.GetDays ());
  618. return sp.GetDays ()+4;
  619. }
  620. void LoginReg2::OnBUTmoney()
  621. {
  622. // TODO: Add your control notification handler code here
  623. if(IsHasRights2new(19)==0)return;
  624. UpdateData();
  625. POSITION pos;
  626. pos=m_List1.GetFirstSelectedItemPosition();
  627. if(pos==NULL)
  628. {
  629. AfxMessageBox("请先选中您要签单的员工!", MB_ICONINFORMATION);
  630. return;
  631. }
  632. int iItem=m_List1.GetNextSelectedItem(pos);
  633. CString name=m_List1.GetItemText (iItem, 0);
  634. LoginSign dlg;
  635. dlg.m_name =name;
  636. if(dlg.DoModal ()==IDOK)
  637. {
  638. GetTimeRange();
  639. }
  640. }
  641. void LoginReg2::OnBUTmoney5()
  642. {
  643. // TODO: Add your control notification handler code here
  644. ReChargeReg dlg;
  645. dlg.m_mode=4;
  646. dlg.m_scurdate=m_scurdate;
  647. dlg.m_scurdate2=m_scurdate2;
  648. dlg.DoModal ();
  649. if(dlg.m_bNeedRefsh)GetTimeRange();
  650. }
  651. void LoginReg2::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  652. {
  653. // TODO: Add your control notification handler code here
  654. POSITION pos;
  655. pos=m_List1.GetFirstSelectedItemPosition();
  656. if(pos==NULL)return;
  657. int iItem=m_List1.GetNextSelectedItem(pos);
  658. m_curname = m_List1.GetItemText (iItem, 0);
  659. *pResult = 0;
  660. }
  661. void LoginReg2::OnButton5()
  662. {
  663. // TODO: Add your control notification handler code here
  664. POSITION pos;
  665. pos=m_List1.GetFirstSelectedItemPosition();
  666. if(pos==NULL)
  667. {
  668. AfxMessageBox("请先选中您要打印的项目!", MB_ICONINFORMATION);
  669. return;
  670. }
  671. int iItem;
  672. CArray<CStringArray, CStringArray>Listarray;
  673. int count=m_List1.GetItemCount ();
  674. Listarray.SetSize(count*33, 1);
  675. count=0;
  676. int curpos=0;
  677. CString str;
  678. while (pos)
  679. {
  680. iItem = m_List1.GetNextSelectedItem(pos);
  681. str.Format ("%s:迟到:%s,早退:%s,旷工:%s", m_List1.GetItemText (iItem, 0), m_List1.GetItemText (iItem, 1), m_List1.GetItemText (iItem, 2), m_List1.GetItemText (iItem, 3));
  682. Listarray.ElementAt (curpos).Add (str);curpos++;
  683. Listarray.ElementAt (curpos).Add ("日期");
  684. Listarray.ElementAt (curpos).Add ("考勤记录");
  685. curpos++;
  686. for(int i=0; i<31; i++)
  687. {
  688. str.Format ("%d", i+1);
  689. Listarray.ElementAt (curpos).Add (str);
  690. Listarray.ElementAt (curpos).Add (m_List1.GetItemText (iItem, i+4));
  691. curpos++;
  692. }
  693. count++;
  694. }
  695. Listarray.SetSize(count*33, 1);
  696. str.Format ("%d-%02d月考勤报表", m_year, m_month);
  697. CString title=g_cominfoarray.ElementAt (0).ElementAt (10)+str;
  698. g_pMainWnd->PrintLoginForm(&Listarray, title, "");
  699. }