// StaffAchievementShowAll.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "StaffAchievementShowAll.h" #include "MyMdi.H" #include "VcPlot.h" #include "VcAxis.h" #include "VcValueScale.h" #include "VcSeriesCollection.h" #include "VcSeries.h" #include "VcPen.h" #include "VcCategoryScale.h" #include "VcColor.h" #include "VcDataGrid.h" #include "VcBackdrop.h" #include "VcFill.h" #include "VcBrush.h" #include "VcDataPoints.h" #include "VcDataPoint.h" #include "VcDataPointLabel.h" #include "VcAxisTitle.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //#define LIM_TIME 1 #define ONLYBOOKING 1 //摄影师化妆师不提前期, 一般影楼是没有前期的。 ///////////////////////////////////////////////////////////////////////////// // StaffAchievementShowAll IDC_STATIC1 StaffAchievementShowAll::StaffAchievementShowAll(CWnd* pParent /*=NULL*/) : CDialog(StaffAchievementShowAll::IDD, pParent) { //{{AFX_DATA_INIT(StaffAchievementShowAll) m_year = atoi(g_date.Mid (0,4)); m_month = atoi(g_date.Mid (5,2)); m_day = 12; m_radio2 = 1; m_radio1 = 1; m_bInit=0; m_timestmap=0; m_radio3=0; //}}AFX_DATA_INIT //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d"); } void StaffAchievementShowAll::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(StaffAchievementShowAll) DDX_Control(pDX, IDC_SPIN3, m_spinday); DDX_Control(pDX, IDC_SPIN2, m_spinmonth); DDX_Control(pDX, IDC_SPIN1, m_spinyear); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_Text(pDX, IDC_EDITyear, m_year); DDX_Text(pDX, IDC_EDITmonth, m_month); DDV_MinMaxUInt(pDX, m_month, 1, 12); DDX_Text(pDX, IDC_EDITday, m_day); DDV_MinMaxUInt(pDX, m_day, 1, 31); DDX_Radio(pDX, IDC_RADIO6, m_radio2); DDX_Radio(pDX, IDC_RADIO3, m_radio1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(StaffAchievementShowAll, CDialog) //{{AFX_MSG_MAP(StaffAchievementShowAll) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear) ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth) ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_BN_CLICKED(IDC_RADIO4, OnRadio4) ON_BN_CLICKED(IDC_RADIO5, OnRadio5) ON_BN_CLICKED(IDC_RADIO6, OnRadio6) ON_BN_CLICKED(IDC_RADIO7, OnRadio7) ON_WM_DESTROY() ON_BN_CLICKED(IDC_BUTprint, OnBUTshowall) ON_WM_TIMER() ON_WM_CTLCOLOR() ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // StaffAchievementShowAll diagnostics #ifdef _DEBUG void StaffAchievementShowAll::AssertValid() const { CDialog::AssertValid(); } void StaffAchievementShowAll::Dump(CDumpContext& dc) const { CDialog::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // StaffAchievementShowAll message handlers void StaffAchievementShowAll::FillGrid() { } void StaffAchievementShowAll::OnBUTclose() { // TODO: Add your control notification handler code here CDialog::OnCancel (); } void StaffAchievementShowAll::OnChangeEDITyear() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. DateChange(); // TODO: Add your control notification handler code here } void StaffAchievementShowAll::OnChangeEDITmonth() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. DateChange(); // TODO: Add your control notification handler code here } void StaffAchievementShowAll::OnChangeEDITday() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. if(m_bInit==0)return; DateChange(); UpdateData(); AfxGetApp()->WriteProfileInt (LYFZVERSION, "rowcount", m_day); // TODO: Add your control notification handler code here } void StaffAchievementShowAll::DateChange() { if(m_bInit==0)return; // if(::GetTickCount ()-m_timestmap<500)return; // m_timestmap=::GetTickCount (); UpdateData(); CString date1,date2; #ifdef LIM_TIME date1.Format ("%d-%02d-14", m_year, m_month); date2.Format ("%d-%02d-31", m_year, 2); #else date1.Format ("%d-%02d-01", m_year, m_month); date2.Format ("%d-%02d-31", m_year, m_month); #endif #ifndef MNLS_VERSION date1.Format ("%d-%02d-01", m_year, m_month); date2.Format ("%d-%02d-31", m_year, m_month); #endif CArraybukuanarray; CArraybukuanarray2; CArraysingleincomearray; int i; int g_nYearposTemp=g_nYearpos; BOOL bLastYear=0; BOOL bThisYear=0; BOOL bOldYear=0; #if JEFF_TEST_ON // 2015开始禁用跨年数据; if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize()) { g_nYearpos = -1; bThisYear = 1; } else if (m_year <= 2013 && g_hisyeararray.GetSize()) { g_nYearpos = GetYearPos(m_year); bLastYear = 1; } #else if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () ) bThisYear=1; else if(m_year<=atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ()) bLastYear=1; else if(atoi(g_date.Left (4))-m_year>1 && g_hisyeararray.GetSize ()>=(atoi(g_date.Left (4))-m_year)) { bOldYear=1; } g_nYearpos=GetYearPos(m_year); #endif CString filter="date>='"+date1+"' and date<='"+date2+"';date>='"+date1+"' and date<='"+date2+"';;dimission='在职';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=198; g_sendhead.code[2]=60; g_sendhead.code[3]=34; g_sendhead.code[4]=61; g_sendhead.tabcount=5; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; return; } DataToArray(&bukuanarray,&singleincomearray,&waiterarray,&m_List1array,&bukuanarray2); if(bLastYear)//如果是去年, 则加今年的补款 { g_nYearpos=-1;//今年 filter="date>='"+date1+"' and date<='"+date2+"';date>='"+date1+"' and date<='"+date2+"';;dimission='在职';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=198; g_sendhead.code[2]=60; g_sendhead.code[3]=34; g_sendhead.code[4]=61; g_sendhead.tabcount=5; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; return; } CArrayThisYearbukuanarray; CArrayThisYearsingleincomearray; CArrayThisYearwaiterarray; CArrayThisYearbukuanarray2; DataToArray(&ThisYearbukuanarray,&ThisYearsingleincomearray,&ThisYearwaiterarray,&m_List1array,&ThisYearbukuanarray2); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+ThisYearbukuanarray.GetSize ()); for(i=oldsize; i='"+date1+"' and date<='"+date2+"';;time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=198; g_sendhead.code[2]=60; g_sendhead.code[3]=61; g_sendhead.tabcount=4; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; return; } CArrayThisYearbukuanarray; CArrayThisYearsingleincomearray; CArrayThisYearwaiterarray; CArrayThisYearbukuanarray2; DataToArray(&ThisYearbukuanarray,&ThisYearsingleincomearray,&ThisYearwaiterarray,&ThisYearbukuanarray2); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+ThisYearbukuanarray.GetSize ()); for(i=oldsize; im_List1arraytemp; CArraymoney1arraytemp; CArraymoney2arraytemp; CString str; if(m_radio3==0) { str.Format ("%s员工 %d年%d月 业绩图表-全体", g_title, m_year, m_month); m_List1arraytemp.SetSize(m_List1array.GetSize ()); money1arraytemp.SetSize(m_List1array.GetSize ()); money2arraytemp.SetSize(m_List1array.GetSize ()); for( i=0; iGetWindowRect (rc); ScreenToClient(rc); InvalidateRect(rc); m_static1.SetWindowText (str); int chartcount=m_List1arraytemp.GetSize ()/m_day; if(m_List1arraytemp.GetSize ()%m_day)chartcount++; if(chartcount==0)return; BOOL bAdd=0; /* int m_day=m_List1array.GetSize ()/chartcount; if(m_List1array.GetSize ()%chartcount) { m_day++; bAdd=1; }*/ for( i=0; iShowWindow (SW_HIDE); } while(m_pChartArray.GetSize ()Create ("", WS_VISIBLE|WS_CHILD, rc, this, m_pChartArray.GetSize (), NULL, 0, bstrLicense ); ::SysFreeString(bstrLicense); m_pChartArray.Add (pChart); InitChartStyle(pChart); SetChartStyle(pChart); } GetDlgItem(IDC_STATIC2)->GetWindowRect(rc); ScreenToClient(rc); int hei=rc.Height ()/chartcount; float fmaxmoney1=0; float fmaxmoney2=0; VARIANT var; for( i=0; iMoveWindow (rc); pChart->ShowWindow (SW_SHOW); rc.top +=hei; int nRowCount=min(m_day, m_List1arraytemp.GetSize ()-i*m_day); if(bAdd) { if(i==chartcount-1)nRowCount++; } pChart->SetRowCount(nRowCount); if(m_radio2==0)//叠加 { pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(fmaxmoney1+fmaxmoney2); pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(0); for(int row = 1; row <= nRowCount; ++row) { pChart->SetRow(row); if(bAdd && i==chartcount-1 && row==nRowCount) { pChart->SetRowLabel(""); pChart->GetDataGrid().SetData(row, 1, 0, 0); continue; } pChart->SetRowLabel(m_List1arraytemp.ElementAt (i*m_day+row-1).ElementAt (0)); pChart->GetDataGrid().SetData(row, 1, money1arraytemp.ElementAt (i*m_day+row-1)+money2arraytemp.ElementAt (i*m_day+row-1), 0); } } else { pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(max(fmaxmoney1,fmaxmoney2)); pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(0); for(int row = 1; row <= nRowCount; ++row) { pChart->SetRow(row); if(bAdd && i==chartcount-1 && row==nRowCount) { pChart->SetRowLabel(""); pChart->GetDataGrid().SetData(row, 1, 0, 0); pChart->GetDataGrid().SetData(row, 2, 0, 0); continue; } pChart->SetRowLabel(m_List1arraytemp.ElementAt (i*m_day+row-1).ElementAt (0)); pChart->GetDataGrid().SetData(row, 1, money1arraytemp.ElementAt (i*m_day+row-1), 0); pChart->GetDataGrid().SetData(row, 2, money2arraytemp.ElementAt (i*m_day+row-1), 0); } } pChart->Refresh(); } } void StaffAchievementShowAll::OnRadio3() { // TODO: Add your control notification handler code here UpdateData(); if(m_radio1==0) { for(int i=0; iSetChartType(3); } } else if(m_radio1==1) { for(int i=0; iSetChartType(1); } } else if(m_radio1==2) { for(int i=0; iSetChartType(14); } } } void StaffAchievementShowAll::OnRadio4() { // TODO: Add your control notification handler code here OnRadio3(); } void StaffAchievementShowAll::OnRadio5() { // TODO: Add your control notification handler code here OnRadio3(); } void StaffAchievementShowAll::OnRadio6() //叠加 { // TODO: Add your control notification handler code here UpdateData(); for(int i=0; iSetColumnCount(1); pChart->SetColumn(1); pChart->SetColumnLabel((LPCTSTR)"全部"); #ifdef MNLS_VERSION #ifdef LIM_TIME pChart->SetColumnLabel((LPCTSTR)"接单"); #endif #endif pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0); // 线宽(对点线图有效) pChart->GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30); // 数据点类型显示数据值的模式(对柱柱状图和点线图有效) // 0: 不显示 1: 显示在柱状图外 // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方 pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); } else { pChart->SetColumnCount(2); pChart->SetColumn(1); pChart->SetColumnLabel((LPCTSTR)"前期"); pChart->SetColumn(2); pChart->SetColumnLabel((LPCTSTR)"后期"); pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0); pChart->GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 0); // 线宽(对点线图有效) pChart->GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30); pChart->GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(30); // 数据点类型显示数据值的模式(对柱柱状图和点线图有效) // 0: 不显示 1: 显示在柱状图外 // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方 pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); pChart->GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); } } void StaffAchievementShowAll::InitChartStyle(CMSChart *pChart) { VARIANT var; pChart->GetBackdrop().GetFill().SetStyle(1); pChart->GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255); pChart->SetShowLegend(TRUE); pChart->SetChartType(3); // 栈模式 pChart->SetStacking(FALSE); pChart->GetPlot().GetAxis(1,var).GetValueScale().SetAuto(0); // 不自动标注Y轴刻度 pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度 pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注 pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线 } void StaffAchievementShowAll::OnDestroy() { g_nAutoShowStaffAchievement=-1; for(int i=0; iDestroyWindow (); delete pChart; } KillTimer(1); m_pChartArray.RemoveAll (); HWND wnd = ::FindWindow("Shell_TrayWnd", 0); ::ShowWindow(wnd, SW_SHOW); ::ShowCursor (1); CDialog::OnDestroy(); } void StaffAchievementShowAll::OnBUTshowall() { // TODO: Add your control notification handler code here } BOOL StaffAchievementShowAll::OnInitDialog() { CDialog::OnInitDialog(); //AfxMessageBox("789789"); // TODO: Add extra initialization here SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); BOOL bScrActive; SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &bScrActive, 0); if (bScrActive) { SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0); } CRect rc2; GetWindowRect(rc2); ::MoveWindow(m_hWnd,0,0,g_screenwid,g_screenhei,TRUE); EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0); GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2); ScreenToClient(rc2); int wid=rc2.Width (); rc2.left =(g_screenwid-wid)/2; rc2.right =rc2.left +wid; rc2.bottom -=rc2.top; rc2.bottom +=10; rc2.top =10; GetDlgItem(IDC_STATIC1)->MoveWindow(rc2); GetWindowRect(rc2); ScreenToClient(rc2); rc2.top +=40*g_fscaley; GetDlgItem(IDC_STATIC2)->MoveWindow(rc2); rc2.top =0; rc2.bottom =41*g_fscaley; GetDlgItem(IDC_STATIC3)->MoveWindow(rc2); m_static1.SetFont (&g_titlefont); CString str; #ifdef LIM_TIME str="蒙娜丽莎员工活动期间业绩图表(从2010-01-14开始,仅接单)"; #else str.Format ("%s员工 %d年%d月 业绩图表", g_title, m_year, m_month); #endif #ifndef MNLS_VERSION str.Format ("%s员工 %d年%d月 业绩图表", g_title, m_year, m_month); #endif m_static1.SetWindowText (str); m_spinyear.SetRange (1900, 3000); m_spinmonth.SetRange (1, 12); m_spinday.SetRange (1, 31); m_day=AfxGetApp()->GetProfileInt (LYFZVERSION, "rowcount", 12); UpdateData(false); SetTimer(1, 1000*60*5, NULL); SetTimer(5, 1000*8, NULL); if(AfxGetApp()->GetProfileInt (LYFZVERSION, "autoshutdown", 12)) { SetTimer(2, 1000*60*5, NULL); m_time=AfxGetApp()->GetProfileInt (LYFZVERSION, "shutdowntime", 20); } SetTimer(3, 100, NULL); // HWND wnd = ::FindWindow("Shell_TrayWnd", 0); // ::ShowWindow(wnd, SW_HIDE); //::ShowCursor(0); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL StaffAchievementShowAll::IsCtrlDown() { short state=GetKeyState(VK_LCONTROL); BYTE sta=(BYTE)(state>>8); state=GetKeyState(VK_RCONTROL); BYTE sta2=(BYTE)(state>>8); if(sta||sta2) return 1; else return 0; }//IsShiftDown BOOL StaffAchievementShowAll::IsShiftDown() { short state=GetKeyState(VK_LSHIFT); BYTE sta=(BYTE)(state>>8); state=GetKeyState(VK_RSHIFT); BYTE sta2=(BYTE)(state>>8); state=GetKeyState(VK_F2); BYTE sta3=(BYTE)(state>>8); if(sta||sta2||sta3) return 1; else return 0; } BOOL StaffAchievementShowAll::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message==WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: case VK_ESCAPE: if(!g_bStaffAchievementShow) CDialog::OnCancel (); else if(g_nAutoShowStaffAchievement==1) CDialog::OnCancel (); return 1; case VK_F4: if(IsCtrlDown() && IsShiftDown()) CDialog::OnCancel (); else if(g_nAutoShowStaffAchievement==1) CDialog::OnCancel (); return 1; } return 1; } if(pMsg->message==WM_MOUSEMOVE) { if(g_nAutoShowStaffAchievement==1) CDialog::OnCancel (); } return CDialog::PreTranslateMessage(pMsg); } void StaffAchievementShowAll::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if(nIDEvent==1) DateChange(); else if(nIDEvent==2) { if(m_time<=CTime::GetCurrentTime ().GetHour()) { KillTimer(2); MyExitWindows(); } } else if(nIDEvent==3) { KillTimer(3); m_bInit=1; DateChange(); } else if(nIDEvent==5) { if(m_bInit) { m_radio3++; if(m_radio3==4)m_radio3=0; KindChange(); } } } HBRUSH StaffAchievementShowAll::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if (nCtlColor==CTLCOLOR_STATIC && pWnd->GetDlgCtrlID ()==IDC_STATIC1) { pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明 return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色 } // TODO: Return a different brush if the default is not desired return hbr; } //Axis(1,var).GetValueScale().SetAu void StaffAchievementShowAll::MyExitWindows() { UINT t=EWX_SHUTDOWN|EWX_FORCE; OSVERSIONINFO osv; //定义一个操作系统信息的结构体 osv.dwOSVersionInfoSize=sizeof OSVERSIONINFO; GetVersionEx(&osv); //查询当前操作系统 if(osv.dwPlatformId==VER_PLATFORM_WIN32_NT) //判断是否是2000/NT { //下面为向操作系统获取权限操作 HANDLE hProcess,hToken; TOKEN_PRIVILEGES Privileges; LUID luid; hProcess=GetCurrentProcess(); //下面为打开当前进程对话 OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken); Privileges.PrivilegeCount=1; LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid); Privileges.Privileges[0].Luid=luid; Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken,FALSE,&Privileges,NULL,NULL,NULL); ExitWindowsEx(t,0); } else { ExitWindowsEx(t,0);//调用ExitWindowsEx关闭机器。 PostQuitMessage(0); } } void StaffAchievementShowAll::OnClose() { // TODO: Add your message handler code here and/or call default // CDialog::OnClose(); }