// LoginReg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "LoginReg.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") ///////////////////////////////////////////////////////////////////////////// // LoginReg IMPLEMENT_DYNCREATE(LoginReg, MyFormView) LoginReg::LoginReg() : MyFormView(LoginReg::IDD) { //{{AFX_DATA_INIT(LoginReg) m_filter = _T(""); m_pos=0; //}}AFX_DATA_INIT } LoginReg::~LoginReg() { } void LoginReg::DoDataExchange(CDataExchange* pDX) { MyFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(LoginReg) DDX_Control(pDX, IDC_COMBO1, m_combo1); DDX_Control(pDX, IDC_LIST2, m_List1); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_CBString(pDX, IDC_COMBO1, m_filter); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(LoginReg, MyFormView) //{{AFX_MSG_MAP(LoginReg) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto) ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto) ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney) ON_BN_CLICKED(IDC_BTNaddsp, OnBTNaddsp) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTmoney5, OnBUTmoney5) ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2) //}}AFX_MSG_MAP ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // LoginReg diagnostics #ifdef _DEBUG void LoginReg::AssertValid() const { MyFormView::AssertValid(); } void LoginReg::Dump(CDumpContext& dc) const { MyFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // LoginReg message handlers messageBox void LoginReg::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("姓名,100;星期日,120;星期一,120;星期二,120;星期三,120;星期四,120;星期五,120;星期六,120" ); m_List1.LoadColumnInfo (150); GetTimeRange(); CenterWindow(); } int __cdecl CompareByLabel2( const void *elem1, const void *elem2) { CStringArray *p1 = (CStringArray*)elem1; CStringArray *p2 = (CStringArray*)elem2; return lstrcmp( p1->ElementAt (0), p2->ElementAt (0) ) ; } int __cdecl CompareByLabel10( const void *elem1, const void *elem2) { CStringArray *p1 = (CStringArray*)elem1; CStringArray *p2 = (CStringArray*)elem2; if(p1->ElementAt (10)==p2->ElementAt (10)) { return lstrcmp( p1->ElementAt (0), p2->ElementAt (0) ) ; } return (p1->ElementAt (10)>p2->ElementAt (10)?0:1) ; return 1; } int __cdecl CompareByLabel9( const void *elem1, const void *elem2) { CStringArray *p1 = (CStringArray*)elem1; CStringArray *p2 = (CStringArray*)elem2; return (p1->ElementAt (10)>p2->ElementAt (10)?0:1) ; } void LoginReg::FillGrid() { if(!m_List1array.GetSize ())return; qsort( static_cast(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel9 ); qsort( static_cast(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel10 ); m_List1.DeleteAllItems2 (); int ii=0; m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 ); int count=0; for(ii=0; iiSendMessage(WM_CLOSE); } void LoginReg::OnSelchangeCombo1() { // TODO: Add your control notification handler code here } void LoginReg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default KillTimer(nIDEvent); } BOOL LoginReg::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: OnButton1(); 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(...) { } } void LoginReg::OnBUTimportphoto() { } void LoginReg::OnBUTshowphoto() { } void LoginReg::OnBUTmoney() { // TODO: Add your control notification handler code here if(IsHasRights2new(19)==0)return; // TODO: Add your control notification handler code here 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 LoginReg::OnBTNaddsp() { } void LoginReg::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // TODO: Add your control notification handler code here *pResult = 0; } void LoginReg::OnButton1() { // TODO: Add your control notification handler code here } void LoginReg::OnButton2() { // TODO: Add your control notification handler code here } void LoginReg::ShowLoginData() { int a = 0; CString filter="weekname='"+m_weekname+"';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; CArraym_List2array; CArraym_List3array; CArraym_List4array; CArraym_List6array; DataToArray(&m_List1array,&m_List2array,&m_List3array,&m_List4array,&m_List6array); CStringArray array; CString no; int i; for( i=0; i1) tm+=CTimeSpan(j-1, 0, 0, 0); CString date=tm.Format("%Y-%m-%d"); CStringArray array; for( a=0; atm1) 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!="签单") bStr="1"; if (outtime3 && in2!="签单") bStr="1"; if (out2time1 && in!="签单") bStr="1"; if (out0) tm+=sp; else tm-=sp; } 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 str; str.Format ("时间段:%04d-%02d-%02d 至 %04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay (), tm3.GetYear (), tm3.GetMonth (), tm3.GetDay () ); SetDlgItemText(IDC_STATIC16, str); m_curtm=tm2; m_weekname.Format ("%04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay () ); { CTimeSpan sp2(1, 0, 0, 0); tm2-=sp2; } m_scurdate.Format ("%04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay () ); { CTimeSpan sp2(1, 0, 0, 0); tm3+=sp2; } m_scurdate2.Format ("%04d-%02d-%02d", tm3.GetYear (), tm3.GetMonth (), tm3.GetDay () ); ShowLoginData(); } void LoginReg::OnButton4() { // TODO: Add your control notification handler code here m_pos--; GetTimeRange(); } void LoginReg::OnButton5() { // TODO: Add your control notification handler code here m_pos++; GetTimeRange(); } void LoginReg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult ) { NMLVCUSTOMDRAW* pLVCD = reinterpret_cast( 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 (9)!="0") pLVCD->clrText = RGB(220,0,0); else pLVCD->clrText = RGB(20,133,20); // if(pLVCD->nmcd.dwItemSpec==2) // pLVCD->clrText = RGB(0,0,200); 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 it self. *pResult = CDRF_DODEFAULT; } } void LoginReg::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 LoginReg::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; }