LoginReg2.cpp 21 KB

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