| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- // LoginReg2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "LoginReg2.h"
- #include "MyMdi.H"
- #include "ModifyDinDan.h"
- #include "InputPsw.h"
- #include "TakeMoney2.h"
- #include "SelWaiter2.h"
- #include "TakeStautsSel.h"
- #include "LoginSign.h"
- #include "ReChargeReg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #pragma comment(lib, "Shlwapi.lib")
- /////////////////////////////////////////////////////////////////////////////
- // LoginReg2 IDC_STATIC16
- IMPLEMENT_DYNCREATE(LoginReg2, MyFormView)
- LoginReg2::LoginReg2()
- : MyFormView(LoginReg2::IDD)
- {
- //{{AFX_DATA_INIT(LoginReg2)
- m_year = atoi(g_date.Mid (0,4));
- m_month = atoi(g_date.Mid (5,2));
- m_bInit=0;
- //}}AFX_DATA_INIT
- }
- LoginReg2::~LoginReg2()
- {
- }
- void LoginReg2::DoDataExchange(CDataExchange* pDX)
- {
- MyFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(LoginReg2)
- DDX_Control(pDX, IDC_LIST2, m_List1);
- DDX_Control(pDX, IDC_STATIC1, m_static1);
- DDX_Control(pDX, IDC_SPIN3, m_spinday);
- DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
- DDX_Control(pDX, IDC_SPIN1, m_spinyear);
- DDX_Text(pDX, IDC_EDITyear, m_year);
- DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
- DDX_Text(pDX, IDC_EDITmonth, m_month);
- DDV_MinMaxUInt(pDX, m_month, 1, 12);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(LoginReg2, MyFormView)
- //{{AFX_MSG_MAP(LoginReg2)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
- ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
- ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
- ON_BN_CLICKED(IDC_BUTmoney5, OnBUTmoney5)
- ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- //}}AFX_MSG_MAP
- ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // LoginReg2 diagnostics
- #ifdef _DEBUG
- void LoginReg2::AssertValid() const
- {
- MyFormView::AssertValid();
- }
- void LoginReg2::Dump(CDumpContext& dc) const
- {
- MyFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // LoginReg2 message handlers
- void LoginReg2::OnInitialUpdate()
- {
- MyFormView::OnInitialUpdate();
- // TODO: Add your specialized code here and/or call the base class
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
- if(IsHasRights2new(19)==0)
- {
- GetDlgItem(IDC_BUTmoney)->EnableWindow(0);
- }
- // Here we create the outbar control using the splitter as its parent
- // and setting its id to the first pane.
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
- m_static1.SetFont (&g_titlefont);
- 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" );
- m_List1.LoadColumnInfo (185);
- m_spinyear.SetRange (1900, 3000);
- m_spinmonth.SetRange (1, 12);
- m_spinday.SetRange (1, 31);
- m_bInit=1;
- GetTimeRange();
- CenterWindow();
- }
- int __cdecl CompareByLabel12( const void *elem1, const void *elem2)
- {
- CStringArray *p1 = (CStringArray*)elem1;
- CStringArray *p2 = (CStringArray*)elem2;
-
-
- if(p1->ElementAt (36)==p2->ElementAt (36))
- {
- return lstrcmp( p1->ElementAt (0), p2->ElementAt (0) ) ;
- }
- return (p1->ElementAt (36)>p2->ElementAt (36)?0:1) ;
-
-
- return 1;
- }
- int __cdecl CompareByLabel11( const void *elem1, const void *elem2)
- {
- CStringArray *p1 = (CStringArray*)elem1;
- CStringArray *p2 = (CStringArray*)elem2;
- return (p1->ElementAt (36)>p2->ElementAt (36)?0:1) ;
- }
- void LoginReg2::FillGrid(BOOL bStatus)
- {
- if(!m_List1array.GetSize ())return;
- qsort( static_cast<void*>(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel11 );
- qsort( static_cast<void*>(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel12 );
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
- int count=0;
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- if(!m_curname.IsEmpty ())
- {
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- if(m_curname==m_List1.GetItemText (i, 0))
- {
- m_List1.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
- m_List1.EnsureVisible(i,FALSE);
- break;
- }
- }
- }
- }
- void LoginReg2::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
- BOOL LoginReg2::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- try
- {
- if(pMsg->message==WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case VK_RETURN:
- return 1;
- case 0x43: // copy
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_COPY);
- return TRUE;
- }
- break;
- case 0x56: //Ctrl + V:
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_PASTE);
- return TRUE;
- }
- break;
- case 0x58: // cut
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_CUT);
- return TRUE;
- }
- break;
- case 0x5A: //undo
- case 0x59: //redo
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_UNDO);
- return TRUE;
- }
- break;
- }
- }
- return MyFormView::PreTranslateMessage(pMsg);
- }
- catch(...)
- {
- }
- }
- CString LoginReg2::GetWeekName(CString date)
- {
- CTime tm(atoi(date.Mid (0,4)),atoi(date.Mid (5,2)),atoi(date.Mid (8,2)),0,0,0);
- int nDayWeek = tm.GetDayOfWeek()-1;
- int days1=nDayWeek;
- int days2=6-nDayWeek;
- CTime tm2,tm3;
- CTimeSpan sp(days1, 0, 0, 0);
- tm2=tm-sp;
- CTimeSpan sp2(days2, 0, 0, 0);
- tm3=tm+sp2;
- CString m_weekname;
- m_weekname.Format ("%04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay () );
- return m_weekname;
- }
- void LoginReg2::ShowLoginData()
- {
- CStringArray weeknamearray;
- CString date,weekname;
- int a = 0;
- for( a=1; a<=31; a++)
- {
- date.Format ("%04d-%02d-%02d", m_year, m_month, a);
- weekname=GetWeekName(date);
- if(::FindArray (&weeknamearray, weekname)==-1)
- weeknamearray.Add(weekname);
- }
- CString filterweekname;
- for( a=0; a<weeknamearray.GetSize (); a++)
- {
- weekname=weeknamearray.ElementAt (a);
- filterweekname+="or weekname='"+weekname+"' ";
- }
- filterweekname.TrimLeft ("or ");
- filterweekname.TrimRight (" ");
-
- CString filter=filterweekname+";[datetime]>'"+m_scurdate+"' and [datetime]<'"+m_scurdate2+"';staff_dimission='在职';;[date]>'"+m_scurdate+"' and [date]<'"+m_scurdate2+"'";
-
- g_sendhead.code[0]=107;
- g_sendhead.code[1]=108;
- g_sendhead.code[2]=5;
- g_sendhead.code[3]=97;
- g_sendhead.code[4]=168;
- g_sendhead.tabcount=5;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>m_List2array;
- CArray<CStringArray, CStringArray>m_List3array;
- CArray<CStringArray, CStringArray>m_List4array;
- CArray<CStringArray, CStringArray>m_List5array;
- CArray<CStringArray, CStringArray>m_List6array;
- DataToArray(&m_List5array,&m_List2array,&m_List3array,&m_List4array,&m_List6array);
-
- CStringArray array;
- CString no;
- int i;
- for( i=0; i<m_List2array.GetSize (); i++)
- {
- no=m_List2array.ElementAt (i).ElementAt (0);
- int pos=FindArray(&array, no);
- if(pos!=-1)
- {
- m_List2array.ElementAt (i).SetAt (0, array.ElementAt (pos+1));
- }
- else
- {
- BOOL bFind=0;
- for(int j=0; j<m_List3array.GetSize (); j++)
- {
- if(no==m_List3array.ElementAt (j).ElementAt (11) || no==m_List3array.ElementAt (j).ElementAt (12))
- {
- bFind=1;
- array.Add (no);
- array.Add (m_List3array.ElementAt (j).ElementAt (1));
- m_List2array.ElementAt (i).SetAt (0, m_List3array.ElementAt (j).ElementAt (1) ) ;
- break;
- }
- }
- }
- }
- ///////////
- m_List1array.RemoveAll ();
- for(i=0; i<m_List5array.GetSize (); i++)
- {
- CString bStr="0";
- CString weekname=m_List5array.ElementAt (i).ElementAt (8);
- CString name=m_List5array.ElementAt (i).ElementAt (0);
- int curpos=FindName(name);
- if(weekname.IsEmpty ())continue;
- int weekpos=GetWeekPos(weekname);//
- for(int j=1; j<=7; j++)
- {
- if(weekpos+j-1>=36)continue;
- if(weekpos+j-1<4)continue;
- m_List1array.ElementAt (curpos).SetAt (weekpos+j-1, m_List5array.ElementAt (i).ElementAt (j) );
- }
- }
-
- ///////////////开始填时间
- CTime begintm(m_year, m_month, 1, 0, 0, 0);
- CTime todaytm(atoi(g_date.Mid (0,4)),atoi(g_date.Mid (5,2)),atoi(g_date.Mid (8,2)),0,0,0);
- CString name;
- for(i=0; i<m_List1array.GetSize (); i++)
- {
- name=m_List1array.ElementAt (i).ElementAt (0);
- CString bStr="0";
- int ncot=0;
- int nTimes1=0; //迟到次数
- int nTimes2=0; //早退次数
- int nTimes3=0; //旷工次数
- int nMenite1=0; //迟到分钟
- int nMenite2=0; //早退分钟
-
- for(int j=4; j<35; j++)
- {
- CString in,out,time1,time2,time3,time4,in2,out2;
- CString ban=m_List1array.ElementAt (i).ElementAt (j);
- if(ban!="休息")
- {
- for(int a=0; a<m_List4array.GetSize (); a++)
- {
- if(ban==m_List4array.ElementAt (a).ElementAt (0))
- {
- time1=m_List4array.ElementAt (a).ElementAt (1);
- time2=m_List4array.ElementAt (a).ElementAt (2);
- time3=m_List4array.ElementAt (a).ElementAt (3);
- time4=m_List4array.ElementAt (a).ElementAt (4);
- break;
- }
- }
- }
- CTime tm=begintm+CTimeSpan(j-4, 0, 0, 0);
- if(tm.GetMonth ()!=m_month)continue;
- CString date=tm.Format("%Y-%m-%d");
-
- CStringArray array;
- for( a=0; a<m_List2array.GetSize (); a++)
- {
- if(name==m_List2array.ElementAt (a).ElementAt (0) && m_List2array.ElementAt (a).ElementAt (1).Find (date)!=-1)
- {
- array.Add (m_List2array.ElementAt (a).ElementAt (1));
-
- }
- }
- if(time3!="")//多时间段
- {
- int dt1,dt2,dt3,dt4;
- for( a=0; a<array.GetSize (); a++)
- {
- CString datetime=array.ElementAt (a);
- datetime=datetime.Mid (11, 5);
- // time1
- CTime tmcur(2012, 5, 29, atoi(datetime.Left (2)), atoi(datetime.Right(2)), 0);
- CTime tm1(2012, 5, 29, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
- CTime tm2(2012, 5, 29, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
- CTime tm3(2012, 5, 29, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
- CTime tm4(2012, 5, 29, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
- CTimeSpan sp;
- if(tmcur>tm1)
- sp=tmcur-tm1;
- else
- sp=tm1-tmcur;
- dt1=sp.GetHours ()*60+sp.GetMinutes ();
- if(tmcur>tm2)
- sp=tmcur-tm2;
- else
- sp=tm2-tmcur;
- dt2=sp.GetHours ()*60+sp.GetMinutes ();
- if(tmcur>tm3)
- sp=tmcur-tm3;
- else
- sp=tm3-tmcur;
- dt3=sp.GetHours ()*60+sp.GetMinutes ();
- if(tmcur>tm4)
- sp=tmcur-tm4;
- else
- sp=tm4-tmcur;
- dt4=sp.GetHours ()*60+sp.GetMinutes ();
- // CString ss;
- // ss.Format("%s %s-%d,%s-%d,%s-%d,%s-%d", datetime,time1,dt1, time2,dt2, time3,dt3, time4,dt4);
- // MessageBox(ss);
- if(dt1<=dt2 && dt1<=dt3 && dt1<=dt4 && in=="")
- {
- in=datetime;
- continue;
- }
- if(dt2<=dt1 && dt2<=dt3 && dt2<=dt4 && out=="")
- {
- out=datetime;continue;
- }
- if(dt3<=dt1 && dt3<=dt2 && dt3<=dt4 && in2=="")
- {
- in2=datetime;continue;
- }
- if(dt4<=dt1 && dt4<=dt2 && dt4<=dt3 && out2=="")
- {
- out2=datetime;continue;
- }
- }
- }
- else//单时间段
- {
- if(array.GetSize ())
- {
- in=array.ElementAt (0);
- in=in.Mid (11, 5);
- }
- if(array.GetSize ()>1)
- {
- out=array.ElementAt (array.GetSize ()-1);
- out=out.Mid (11, 5);
- }
- }
- for(a=0; a<m_List6array.GetSize (); a++)
- {
- if(name==m_List6array.ElementAt (a).ElementAt (1) && m_List6array.ElementAt (a).ElementAt (2).Find (date)!=-1)
- {
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
- in="签单";
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("段")==-1)
- out="签单";
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
- in="签单";
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("上段")!=-1)
- out="签单";
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("上班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
- in2="签单";
- if(m_List6array.ElementAt (a).ElementAt (3).Find ("下班")!=-1 && m_List6array.ElementAt (a).ElementAt (3).Find ("下段")!=-1)
- out2="签单";
- }
- }
- if(time3=="" && array.GetSize () && in=="签单" && out!="签单")//防止上班签卡,只打了下班卡,会被认为是上班卡而没有下班时间
- {
- out=array.ElementAt (array.GetSize ()-1);
- out=out.Mid (11, 5);
- }
- if(time3=="")
- {
- if( (in.IsEmpty () || out.IsEmpty ()) && ban!="休息")
- nTimes3++;
- }
- else
- {
- if( (in.IsEmpty () || out.IsEmpty () || in2.IsEmpty () || out2.IsEmpty ()) && ban!="休息")
- nTimes3++;
- }
- if(time3=="")
- {
- if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
- {
- CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
- CTimeSpan sp=tm1-tm2;
- nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes1++;
- }
- if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
- {
- CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
- CTimeSpan sp=tm2-tm1;
- nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes2++;
- }
- }
- else//分段班
- {
- if(time1!="" && in!="" && in>time1 && in!="签单")//计算迟到
- {
- CTime tm1(m_year, m_month, 1, atoi(in.Left (2)), atoi(in.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time1.Left (2)), atoi(time1.Right(2)), 0);
- CTimeSpan sp=tm1-tm2;
- nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes1++;
- }
- if(time2!="" && out!="" && out<time2 && out!="签单")//计算早退
- {
- CTime tm1(m_year, m_month, 1, atoi(out.Left (2)), atoi(out.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time2.Left (2)), atoi(time2.Right(2)), 0);
- CTimeSpan sp=tm2-tm1;
- nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes2++;
- }
- if(time3!="" && in2!="" && in2>time3 && in2!="签单")//计算迟到
- {
- CTime tm1(m_year, m_month, 1, atoi(in2.Left (2)), atoi(in2.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time3.Left (2)), atoi(time3.Right(2)), 0);
- CTimeSpan sp=tm1-tm2;
- nMenite1+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes1++;
- }
- if(time4!="" && out2!="" && out2<time4 && out2!="签单")//计算早退
- {
- CTime tm1(m_year, m_month, 1, atoi(out2.Left (2)), atoi(out2.Right(2)), 0);
- CTime tm2(m_year, m_month, 1, atoi(time4.Left (2)), atoi(time4.Right(2)), 0);
- CTimeSpan sp=tm2-tm1;
- nMenite2+=sp.GetHours ()*60+sp.GetMinutes ();
- nTimes2++;
- }
- }
- if(ban!="休息" && tm<todaytm)//今天或以后的不判断
- {
- if(time3!="")//多时间段
- {
- if (in>time1 && in!="签单")
- bStr="1";
- if (out<time2 && out!="签单")
- bStr="1";
- if (in2>time3 && in2!="签单")
- bStr="1";
- if (out2<time4 && out2!="签单")
- bStr="1";
- if(in==""||out==""||in2==""||out2=="")
- bStr="1";
- }
- else
- {
- if (in>time1 && in!="签单")
- bStr="1";
- if (out<time2 && out!="签单")
- bStr="1";
- if(in==""||out=="")
- bStr="1";
- }
- }
- if(time3!="")//多时间段
- m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")"+"("+in2+"-"+out2+")");
- else
- m_List1array.ElementAt (i).SetAt (j, ban+"("+in+"-"+out+")");
- if(in!="")ncot++; if(out!="")ncot++;
- if(in2!="")ncot++; if(out2!="")ncot++;
- }
- m_List1array.ElementAt (i).SetAt(35, bStr);
- CString str;
- str.Format ("%d次/%d分", nTimes1, nMenite1);
- m_List1array.ElementAt (i).SetAt(1, str);
- str.Format ("%d次/%d分", nTimes2, nMenite2);
- m_List1array.ElementAt (i).SetAt(2, str);
- str.Format ("%d次", nTimes3);
- m_List1array.ElementAt (i).SetAt(3, str);
- CString scot;
- scot.Format("%d", ncot);
- m_List1array.ElementAt (i).SetAt(36, scot);
- }
- ///////////////
- FillGrid();
- }
- void LoginReg2::GetTimeRange()
- {
- if(!m_bInit)return;
- UpdateData();
- m_scurdate.Format ("%04d-%02d-%02d", m_year, m_month, 0);
- m_scurdate2.Format ("%04d-%02d-%02d", m_year, m_month, 32);
- ShowLoginData();
- }
- void LoginReg2::OnChangeEDITyear()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the MyFormView::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
- GetTimeRange();
- // TODO: Add your control notification handler code here
-
- }
- void LoginReg2::OnChangeEDITmonth()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the MyFormView::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
- GetTimeRange();
- // TODO: Add your control notification handler code here
-
- }
- void LoginReg2::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
- {
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
- // Take the default processing unless we set this to something else below.
- *pResult = 0;
- // First thing - check the draw stage. If it's the control's prepaint
- // stage, then tell Windows we want messages for every item.
- if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- *pResult = CDRF_NOTIFYITEMDRAW;
- }
- else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- // This is the prepaint stage for an item. Here's where we set the
- // item's text color. Our return value will tell Windows to draw the
- // item itself, but it will use the new color we set here.
- // We'll cycle the colors through red, green, and light blue.
-
- if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (35)!="0")
- pLVCD->clrText = RGB(220,0,0);
- else
- pLVCD->clrText = RGB(20,133,20);
-
- if(pLVCD->nmcd.dwItemSpec%2)
- pLVCD->clrTextBk = g_gridcol1;
- else
- pLVCD->clrTextBk = g_gridcol2;
- // Store the color back in the NMLVCUSTOMDRAW struct.
-
- // Tell Windows to paint the control itself.
- *pResult = CDRF_DODEFAULT;
- }
- }
- int LoginReg2::FindName(CString name)
- {
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(name==m_List1array.ElementAt (i).ElementAt (0))return i;
- }
- int size=m_List1array.GetSize ();
- m_List1array.SetSize (size+1, 1);
- m_List1array.ElementAt (size).SetSize(37);
- m_List1array.ElementAt (size).SetAt (0, name);
- return size;
- }
- int LoginReg2::GetWeekPos(CString weekname)
- {
- CTime tm1(m_year, m_month, 1, 0, 0, 0);
- CTime tm2(atoi(weekname.Mid (0,4)),atoi(weekname.Mid (5,2)),atoi(weekname.Mid (8,2)),0,0,0);
- CTimeSpan sp=tm2-tm1;
- // CString ss;
- // ss.Format ("%s-%s %d", tm1.Format ("%Y-%m-%d"), tm2.Format ("%Y-%m-%d"), sp.GetDays ());
- return sp.GetDays ()+4;
- }
- void LoginReg2::OnBUTmoney()
- {
- // TODO: Add your control notification handler code here
- if(IsHasRights2new(19)==0)return;
- UpdateData();
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要签单的员工!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString name=m_List1.GetItemText (iItem, 0);
- LoginSign dlg;
- dlg.m_name =name;
- if(dlg.DoModal ()==IDOK)
- {
- GetTimeRange();
- }
- }
- void LoginReg2::OnBUTmoney5()
- {
- // TODO: Add your control notification handler code here
- ReChargeReg dlg;
- dlg.m_mode=4;
- dlg.m_scurdate=m_scurdate;
- dlg.m_scurdate2=m_scurdate2;
- dlg.DoModal ();
- if(dlg.m_bNeedRefsh)GetTimeRange();
- }
- void LoginReg2::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)return;
- int iItem=m_List1.GetNextSelectedItem(pos);
- m_curname = m_List1.GetItemText (iItem, 0);
- *pResult = 0;
- }
- void LoginReg2::OnButton5()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要打印的项目!", MB_ICONINFORMATION);
- return;
- }
- int iItem;
- CArray<CStringArray, CStringArray>Listarray;
- int count=m_List1.GetItemCount ();
- Listarray.SetSize(count*33, 1);
- count=0;
- int curpos=0;
- CString str;
- while (pos)
- {
- iItem = m_List1.GetNextSelectedItem(pos);
-
- 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));
- Listarray.ElementAt (curpos).Add (str);curpos++;
- Listarray.ElementAt (curpos).Add ("日期");
- Listarray.ElementAt (curpos).Add ("考勤记录");
- curpos++;
- for(int i=0; i<31; i++)
- {
- str.Format ("%d", i+1);
- Listarray.ElementAt (curpos).Add (str);
- Listarray.ElementAt (curpos).Add (m_List1.GetItemText (iItem, i+4));
- curpos++;
- }
-
- count++;
- }
- Listarray.SetSize(count*33, 1);
-
- str.Format ("%d-%02d月考勤报表", m_year, m_month);
- CString title=g_cominfoarray.ElementAt (0).ElementAt (10)+str;
- g_pMainWnd->PrintLoginForm(&Listarray, title, "");
- }
|