// 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(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel11 ); qsort( static_cast(&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; iiSendMessage(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'"+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; CArraym_List2array; CArraym_List3array; CArraym_List4array; CArraym_List5array; CArraym_List6array; DataToArray(&m_List5array,&m_List2array,&m_List3array,&m_List4array,&m_List6array); CStringArray array; CString no; int i; for( i=0; i=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; itm1) 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; atime1 && 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!="" && outtime1 && 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!="" && outtime3 && 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!="" && out2time1 && in!="签单") bStr="1"; if (outtime3 && in2!="签单") bStr="1"; if (out2time1 && in!="签单") bStr="1"; if (out( 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; iListarray; 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, ""); }