LoginReg2.cpp 21 KB

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