LoginReg2.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  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. int a = 0;
  224. for(/*int*/ a=1; a<=31; a++)
  225. {
  226. date.Format ("%04d-%02d-%02d", m_year, m_month, a);
  227. weekname=GetWeekName(date);
  228. if(::FindArray (&weeknamearray, weekname)==-1)
  229. weeknamearray.Add(weekname);
  230. }
  231. CString filterweekname;
  232. for( a=0; a<weeknamearray.GetSize (); a++)
  233. {
  234. weekname=weeknamearray.ElementAt (a);
  235. filterweekname+="or weekname='"+weekname+"' ";
  236. }
  237. filterweekname.TrimLeft ("or ");
  238. filterweekname.TrimRight (" ");
  239. CString filter=filterweekname+";[datetime]>'"+m_scurdate+"' and [datetime]<'"+m_scurdate2+"';dimission='在职';;[date]>'"+m_scurdate+"' and [date]<'"+m_scurdate2+"'";
  240. g_sendhead.code[0]=107;
  241. g_sendhead.code[1]=108;
  242. g_sendhead.code[2]=5;
  243. g_sendhead.code[3]=97;
  244. g_sendhead.code[4]=168;
  245. g_sendhead.tabcount=5;
  246. g_sendhead.bsql=0;
  247. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  248. CArray<CStringArray, CStringArray>m_List2array;
  249. CArray<CStringArray, CStringArray>m_List3array;
  250. CArray<CStringArray, CStringArray>m_List4array;
  251. CArray<CStringArray, CStringArray>m_List5array;
  252. CArray<CStringArray, CStringArray>m_List6array;
  253. DataToArray(&m_List5array,&m_List2array,&m_List3array,&m_List4array,&m_List6array);
  254. CStringArray array;
  255. CString no;
  256. int i;
  257. for( i=0; i<m_List2array.GetSize (); i++)
  258. {
  259. no=m_List2array.ElementAt (i).ElementAt (0);
  260. int pos=FindArray(&array, no);
  261. if(pos!=-1)
  262. {
  263. m_List2array.ElementAt (i).SetAt (0, array.ElementAt (pos+1));
  264. }
  265. else
  266. {
  267. BOOL bFind=0;
  268. for(int j=0; j<m_List3array.GetSize (); j++)
  269. {
  270. if(no==m_List3array.ElementAt (j).ElementAt (11) || no==m_List3array.ElementAt (j).ElementAt (12))
  271. {
  272. bFind=1;
  273. array.Add (no);
  274. array.Add (m_List3array.ElementAt (j).ElementAt (1));
  275. m_List2array.ElementAt (i).SetAt (0, m_List3array.ElementAt (j).ElementAt (1) ) ;
  276. break;
  277. }
  278. }
  279. }
  280. }
  281. ///////////
  282. m_List1array.RemoveAll ();
  283. for(i=0; i<m_List5array.GetSize (); i++)
  284. {
  285. CString bStr="0";
  286. CString weekname=m_List5array.ElementAt (i).ElementAt (8);
  287. CString name=m_List5array.ElementAt (i).ElementAt (0);
  288. int curpos=FindName(name);
  289. if(weekname.IsEmpty ())continue;
  290. int weekpos=GetWeekPos(weekname);//
  291. for(int j=1; j<=7; j++)
  292. {
  293. if(weekpos+j-1>=36)continue;
  294. if(weekpos+j-1<4)continue;
  295. m_List1array.ElementAt (curpos).SetAt (weekpos+j-1, m_List5array.ElementAt (i).ElementAt (j) );
  296. }
  297. }
  298. ///////////////开始填时间
  299. CTime begintm(m_year, m_month, 1, 0, 0, 0);
  300. CTime todaytm(atoi(g_date.Mid (0,4)),atoi(g_date.Mid (5,2)),atoi(g_date.Mid (8,2)),0,0,0);
  301. CString name;
  302. for(i=0; i<m_List1array.GetSize (); i++)
  303. {
  304. name=m_List1array.ElementAt (i).ElementAt (0);
  305. CString bStr="0";
  306. int ncot=0;
  307. int nTimes1=0; //迟到次数
  308. int nTimes2=0; //早退次数
  309. int nTimes3=0; //旷工次数
  310. int nMenite1=0; //迟到分钟
  311. int nMenite2=0; //早退分钟
  312. for(int j=4; j<35; j++)
  313. {
  314. CString in,out,time1,time2,time3,time4,in2,out2;
  315. CString ban=m_List1array.ElementAt (i).ElementAt (j);
  316. if(ban!="休息")
  317. {
  318. for(int a=0; a<m_List4array.GetSize (); a++)
  319. {
  320. if(ban==m_List4array.ElementAt (a).ElementAt (0))
  321. {
  322. time1=m_List4array.ElementAt (a).ElementAt (1);
  323. time2=m_List4array.ElementAt (a).ElementAt (2);
  324. time3=m_List4array.ElementAt (a).ElementAt (3);
  325. time4=m_List4array.ElementAt (a).ElementAt (4);
  326. break;
  327. }
  328. }
  329. }
  330. CTime tm=begintm+CTimeSpan(j-4, 0, 0, 0);
  331. if(tm.GetMonth ()!=m_month)continue;
  332. CString date=tm.Format("%Y-%m-%d");
  333. CStringArray array;
  334. for(int a=0; a<m_List2array.GetSize (); a++)
  335. {
  336. if(name==m_List2array.ElementAt (a).ElementAt (0) && m_List2array.ElementAt (a).ElementAt (1).Find (date)!=-1)
  337. {
  338. array.Add (m_List2array.ElementAt (a).ElementAt (1));
  339. }
  340. }
  341. if(time3!="")//多时间段
  342. {
  343. int dt1,dt2,dt3,dt4;
  344. for(int a=0; a<array.GetSize (); a++)
  345. {
  346. CString datetime=array.ElementAt (a);
  347. datetime=datetime.Mid (11, 5);
  348. // time1
  349. CTime tmcur(2012, 5, 29, atoi(datetime.Left (2)), atoi(datetime.Right(2)), 0);
  350. CTime tm1(2012, 5, 29, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  351. CTime tm2(2012, 5, 29, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  352. CTime tm3(2012, 5, 29, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
  353. CTime tm4(2012, 5, 29, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
  354. CTimeSpan sp;
  355. if(tmcur>tm1)
  356. sp=tmcur-tm1;
  357. else
  358. sp=tm1-tmcur;
  359. dt1=sp.GetHours ()*60+sp.GetMinutes ();
  360. if(tmcur>tm2)
  361. sp=tmcur-tm2;
  362. else
  363. sp=tm2-tmcur;
  364. dt2=sp.GetHours ()*60+sp.GetMinutes ();
  365. if(tmcur>tm3)
  366. sp=tmcur-tm3;
  367. else
  368. sp=tm3-tmcur;
  369. dt3=sp.GetHours ()*60+sp.GetMinutes ();
  370. if(tmcur>tm4)
  371. sp=tmcur-tm4;
  372. else
  373. sp=tm4-tmcur;
  374. dt4=sp.GetHours ()*60+sp.GetMinutes ();
  375. // CString ss;
  376. // ss.Format("%s %s-%d,%s-%d,%s-%d,%s-%d", datetime,time1,dt1, time2,dt2, time3,dt3, time4,dt4);
  377. // MessageBox(ss);
  378. if(dt1<=dt2 && dt1<=dt3 && dt1<=dt4 && in=="")
  379. {
  380. in=datetime;
  381. continue;
  382. }
  383. if(dt2<=dt1 && dt2<=dt3 && dt2<=dt4 && out=="")
  384. {
  385. out=datetime;continue;
  386. }
  387. if(dt3<=dt1 && dt3<=dt2 && dt3<=dt4 && in2=="")
  388. {
  389. in2=datetime;continue;
  390. }
  391. if(dt4<=dt1 && dt4<=dt2 && dt4<=dt3 && out2=="")
  392. {
  393. out2=datetime;continue;
  394. }
  395. }
  396. }
  397. else//单时间段
  398. {
  399. if(array.GetSize ())
  400. {
  401. in=array.ElementAt (0);
  402. in=in.Mid (11, 5);
  403. }
  404. if(array.GetSize ()>1)
  405. {
  406. out=array.ElementAt (array.GetSize ()-1);
  407. out=out.Mid (11, 5);
  408. }
  409. }
  410. for(a=0; a<m_List6array.GetSize (); a++)
  411. {
  412. if(name==m_List6array.ElementAt (a).ElementAt (1) && m_List6array.ElementAt (a).ElementAt (2).Find (date)!=-1)
  413. {
  414. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
  415. in="签单";
  416. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
  417. out="签单";
  418. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
  419. in="签单";
  420. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
  421. out="签单";
  422. if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
  423. in2="签单";
  424. if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
  425. out2="签单";
  426. }
  427. }
  428. if(time3=="" && array.GetSize () && in=="签单" && out!="签单")//防止上班签卡,只打了下班卡,会被认为是上班卡而没有下班时间
  429. {
  430. out=array.ElementAt (array.GetSize ()-1);
  431. out=out.Mid (11, 5);
  432. }
  433. if(time3=="")
  434. {
  435. if( (in.IsEmpty () || out.IsEmpty ()) && ban!="休息")
  436. nTimes3++;
  437. }
  438. else
  439. {
  440. if( (in.IsEmpty () || out.IsEmpty () || in2.IsEmpty () || out2.IsEmpty ()) && ban!="休息")
  441. nTimes3++;
  442. }
  443. if(time3=="")
  444. {
  445. if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
  446. {
  447. CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
  448. CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  449. CTimeSpan sp=tm1-tm2;
  450. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  451. nTimes1++;
  452. }
  453. if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
  454. {
  455. CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
  456. CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  457. CTimeSpan sp=tm2-tm1;
  458. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  459. nTimes2++;
  460. }
  461. }
  462. else//分段班
  463. {
  464. if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
  465. {
  466. CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
  467. CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
  468. CTimeSpan sp=tm1-tm2;
  469. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  470. nTimes1++;
  471. }
  472. if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
  473. {
  474. CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
  475. CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
  476. CTimeSpan sp=tm2-tm1;
  477. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  478. nTimes2++;
  479. }
  480. if(time3!="" && in2!="" && in2>time3 && in2!="签单")//计算迟到
  481. {
  482. CTime tm1(m_year, m_month, 1, atoi(in2.Left (2)), atoi(in2.Right(2)), 0);
  483. CTime tm2(m_year, m_month, 1, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
  484. CTimeSpan sp=tm1-tm2;
  485. nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
  486. nTimes1++;
  487. }
  488. if(time4!="" && out2!="" && out2<time4 && out2!="签单")//计算早退
  489. {
  490. CTime tm1(m_year, m_month, 1, atoi(out2.Left (2)), atoi(out2.Right(2)), 0);
  491. CTime tm2(m_year, m_month, 1, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
  492. CTimeSpan sp=tm2-tm1;
  493. nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
  494. nTimes2++;
  495. }
  496. }
  497. if(ban!="休息" && tm<todaytm)//今天或以后的不判断
  498. {
  499. if(time3!="")//多时间段
  500. {
  501. if (in>time1 && in!="签单")
  502. bStr="1";
  503. if (out<time2 && out!="签单")
  504. bStr="1";
  505. if (in2>time3 && in2!="签单")
  506. bStr="1";
  507. if (out2<time4 && out2!="签单")
  508. bStr="1";
  509. if(in==""||out==""||in2==""||out2=="")
  510. bStr="1";
  511. }
  512. else
  513. {
  514. if (in>time1 && in!="签单")
  515. bStr="1";
  516. if (out<time2 && out!="签单")
  517. bStr="1";
  518. if(in==""||out=="")
  519. bStr="1";
  520. }
  521. }
  522. if(time3!="")//多时间段
  523. m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")"+"("+in2+"-"+out2+")");
  524. else
  525. m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")");
  526. if(in!="")ncot++; if(out!="")ncot++;
  527. if(in2!="")ncot++; if(out2!="")ncot++;
  528. }
  529. m_List1array.ElementAt (i).SetAt(35, bStr);
  530. CString str;
  531. str.Format ("%d次/%d分", nTimes1, nMenite1);
  532. m_List1array.ElementAt (i).SetAt(1, str);
  533. str.Format ("%d次/%d分", nTimes2, nMenite2);
  534. m_List1array.ElementAt (i).SetAt(2, str);
  535. str.Format ("%d次", nTimes3);
  536. m_List1array.ElementAt (i).SetAt(3, str);
  537. CString scot;
  538. scot.Format("%d", ncot);
  539. m_List1array.ElementAt (i).SetAt(36, scot);
  540. }
  541. ///////////////
  542. FillGrid();
  543. }
  544. void LoginReg2::GetTimeRange()
  545. {
  546. if(!m_bInit)return;
  547. UpdateData();
  548. m_scurdate.Format ("%04d-%02d-%02d", m_year, m_month, 0);
  549. m_scurdate2.Format ("%04d-%02d-%02d", m_year, m_month, 32);
  550. ShowLoginData();
  551. }
  552. void LoginReg2::OnChangeEDITyear()
  553. {
  554. // TODO: If this is a RICHEDIT control, the control will not
  555. // send this notification unless you override the MyFormView::OnInitDialog()
  556. // function and call CRichEditCtrl().SetEventMask()
  557. // with the ENM_CHANGE flag ORed into the mask.
  558. GetTimeRange();
  559. // TODO: Add your control notification handler code here
  560. }
  561. void LoginReg2::OnChangeEDITmonth()
  562. {
  563. // TODO: If this is a RICHEDIT control, the control will not
  564. // send this notification unless you override the MyFormView::OnInitDialog()
  565. // function and call CRichEditCtrl().SetEventMask()
  566. // with the ENM_CHANGE flag ORed into the mask.
  567. GetTimeRange();
  568. // TODO: Add your control notification handler code here
  569. }
  570. void LoginReg2::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  571. {
  572. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  573. // Take the default processing unless we set this to something else below.
  574. *pResult = 0;
  575. // First thing - check the draw stage. If it's the control's prepaint
  576. // stage, then tell Windows we want messages for every item.
  577. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  578. {
  579. *pResult = CDRF_NOTIFYITEMDRAW;
  580. }
  581. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  582. {
  583. // This is the prepaint stage for an item. Here's where we set the
  584. // item's text color. Our return value will tell Windows to draw the
  585. // item itself, but it will use the new color we set here.
  586. // We'll cycle the colors through red, green, and light blue.
  587. if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (35)!="0")
  588. pLVCD->clrText = RGB(220,0,0);
  589. else
  590. pLVCD->clrText = RGB(20,133,20);
  591. if(pLVCD->nmcd.dwItemSpec%2)
  592. pLVCD->clrTextBk = g_gridcol1;
  593. else
  594. pLVCD->clrTextBk = g_gridcol2;
  595. // Store the color back in the NMLVCUSTOMDRAW struct.
  596. // Tell Windows to paint the control itself.
  597. *pResult = CDRF_DODEFAULT;
  598. }
  599. }
  600. int LoginReg2::FindName(CString name)
  601. {
  602. for(int i=0; i<m_List1array.GetSize (); i++)
  603. {
  604. if(name==m_List1array.ElementAt (i).ElementAt (0))return i;
  605. }
  606. int size=m_List1array.GetSize ();
  607. m_List1array.SetSize (size+1, 1);
  608. m_List1array.ElementAt (size).SetSize(37);
  609. m_List1array.ElementAt (size).SetAt (0, name);
  610. return size;
  611. }
  612. int LoginReg2::GetWeekPos(CString weekname)
  613. {
  614. CTime tm1(m_year, m_month, 1, 0, 0, 0);
  615. CTime tm2(atoi(weekname.Mid (0,4)),atoi(weekname.Mid (5,2)),atoi(weekname.Mid (8,2)),0,0,0);
  616. CTimeSpan sp=tm2-tm1;
  617. // CString ss;
  618. // ss.Format ("%s-%s %d", tm1.Format ("%Y-%m-%d"), tm2.Format ("%Y-%m-%d"), sp.GetDays ());
  619. return sp.GetDays ()+4;
  620. }
  621. void LoginReg2::OnBUTmoney()
  622. {
  623. // TODO: Add your control notification handler code here
  624. if(IsHasRights2new(19)==0)return;
  625. UpdateData();
  626. POSITION pos;
  627. pos=m_List1.GetFirstSelectedItemPosition();
  628. if(pos==NULL)
  629. {
  630. AfxMessageBox("请先选中您要签单的员工!", MB_ICONINFORMATION);
  631. return;
  632. }
  633. int iItem=m_List1.GetNextSelectedItem(pos);
  634. CString name=m_List1.GetItemText (iItem, 0);
  635. LoginSign dlg;
  636. dlg.m_name =name;
  637. if(dlg.DoModal ()==IDOK)
  638. {
  639. GetTimeRange();
  640. }
  641. }
  642. void LoginReg2::OnBUTmoney5()
  643. {
  644. // TODO: Add your control notification handler code here
  645. ReChargeReg dlg;
  646. dlg.m_mode=4;
  647. dlg.m_scurdate=m_scurdate;
  648. dlg.m_scurdate2=m_scurdate2;
  649. dlg.DoModal ();
  650. if(dlg.m_bNeedRefsh)GetTimeRange();
  651. }
  652. void LoginReg2::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  653. {
  654. // TODO: Add your control notification handler code here
  655. POSITION pos;
  656. pos=m_List1.GetFirstSelectedItemPosition();
  657. if(pos==NULL)return;
  658. int iItem=m_List1.GetNextSelectedItem(pos);
  659. m_curname = m_List1.GetItemText (iItem, 0);
  660. *pResult = 0;
  661. }
  662. void LoginReg2::OnButton5()
  663. {
  664. // TODO: Add your control notification handler code here
  665. POSITION pos;
  666. pos=m_List1.GetFirstSelectedItemPosition();
  667. if(pos==NULL)
  668. {
  669. AfxMessageBox("请先选中您要打印的项目!", MB_ICONINFORMATION);
  670. return;
  671. }
  672. int iItem;
  673. CArray<CStringArray, CStringArray>Listarray;
  674. int count=m_List1.GetItemCount ();
  675. Listarray.SetSize(count*33, 1);
  676. count=0;
  677. int curpos=0;
  678. CString str;
  679. while (pos)
  680. {
  681. iItem = m_List1.GetNextSelectedItem(pos);
  682. 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));
  683. Listarray.ElementAt (curpos).Add (str);curpos++;
  684. Listarray.ElementAt (curpos).Add ("日期");
  685. Listarray.ElementAt (curpos).Add ("考勤记录");
  686. curpos++;
  687. for(int i=0; i<31; i++)
  688. {
  689. str.Format ("%d", i+1);
  690. Listarray.ElementAt (curpos).Add (str);
  691. Listarray.ElementAt (curpos).Add (m_List1.GetItemText (iItem, i+4));
  692. curpos++;
  693. }
  694. count++;
  695. }
  696. Listarray.SetSize(count*33, 1);
  697. str.Format ("%d-%02d月考勤报表", m_year, m_month);
  698. CString title=g_cominfoarray.ElementAt (0).ElementAt (10)+str;
  699. g_pMainWnd->PrintLoginForm(&Listarray, title, "");
  700. }