StaffAchievementShowAll.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. // StaffAchievementShowAll.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "StaffAchievementShowAll.h"
  6. #include "MyMdi.H"
  7. #include "VcPlot.h"
  8. #include "VcAxis.h"
  9. #include "VcValueScale.h"
  10. #include "VcSeriesCollection.h"
  11. #include "VcSeries.h"
  12. #include "VcPen.h"
  13. #include "VcCategoryScale.h"
  14. #include "VcColor.h"
  15. #include "VcDataGrid.h"
  16. #include "VcBackdrop.h"
  17. #include "VcFill.h"
  18. #include "VcBrush.h"
  19. #include "VcDataPoints.h"
  20. #include "VcDataPoint.h"
  21. #include "VcDataPointLabel.h"
  22. #include "VcAxisTitle.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #define LIM_TIME 1
  29. /////////////////////////////////////////////////////////////////////////////
  30. // StaffAchievementShowAll IDC_STATIC1
  31. StaffAchievementShowAll::StaffAchievementShowAll(CWnd* pParent /*=NULL*/)
  32. : CDialog(StaffAchievementShowAll::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(StaffAchievementShowAll)
  35. m_year = CTime::GetCurrentTime ().GetYear ();
  36. m_month = CTime::GetCurrentTime ().GetMonth ();
  37. m_day = 12;
  38. m_radio2 = 1;
  39. m_radio1 = 1;
  40. m_bInit=0;
  41. m_timestmap=0;
  42. //}}AFX_DATA_INIT
  43. //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  44. }
  45. void StaffAchievementShowAll::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CDialog::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(StaffAchievementShowAll)
  49. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  50. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  51. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  52. DDX_Control(pDX, IDC_STATIC1, m_static1);
  53. DDX_Text(pDX, IDC_EDITyear, m_year);
  54. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  55. DDX_Text(pDX, IDC_EDITmonth, m_month);
  56. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  57. DDX_Text(pDX, IDC_EDITday, m_day);
  58. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  59. DDX_Radio(pDX, IDC_RADIO6, m_radio2);
  60. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  61. //}}AFX_DATA_MAP
  62. }
  63. BEGIN_MESSAGE_MAP(StaffAchievementShowAll, CDialog)
  64. //{{AFX_MSG_MAP(StaffAchievementShowAll)
  65. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  66. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  67. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  68. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  69. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  70. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  71. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  72. ON_BN_CLICKED(IDC_RADIO6, OnRadio6)
  73. ON_BN_CLICKED(IDC_RADIO7, OnRadio7)
  74. ON_WM_DESTROY()
  75. ON_BN_CLICKED(IDC_BUTprint, OnBUTshowall)
  76. ON_WM_TIMER()
  77. ON_WM_CTLCOLOR()
  78. ON_WM_CLOSE()
  79. //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // StaffAchievementShowAll diagnostics
  83. #ifdef _DEBUG
  84. void StaffAchievementShowAll::AssertValid() const
  85. {
  86. CDialog::AssertValid();
  87. }
  88. void StaffAchievementShowAll::Dump(CDumpContext& dc) const
  89. {
  90. CDialog::Dump(dc);
  91. }
  92. #endif //_DEBUG
  93. /////////////////////////////////////////////////////////////////////////////
  94. // StaffAchievementShowAll message handlers
  95. void StaffAchievementShowAll::FillGrid()
  96. {
  97. }
  98. void StaffAchievementShowAll::OnBUTclose()
  99. {
  100. // TODO: Add your control notification handler code here
  101. CDialog::OnCancel ();
  102. }
  103. void StaffAchievementShowAll::OnChangeEDITyear()
  104. {
  105. // TODO: If this is a RICHEDIT control, the control will not
  106. // send this notification unless you override the CDialog::OnInitDialog()
  107. // function and call CRichEditCtrl().SetEventMask()
  108. // with the ENM_CHANGE flag ORed into the mask.
  109. DateChange();
  110. // TODO: Add your control notification handler code here
  111. }
  112. void StaffAchievementShowAll::OnChangeEDITmonth()
  113. {
  114. // TODO: If this is a RICHEDIT control, the control will not
  115. // send this notification unless you override the CDialog::OnInitDialog()
  116. // function and call CRichEditCtrl().SetEventMask()
  117. // with the ENM_CHANGE flag ORed into the mask.
  118. DateChange();
  119. // TODO: Add your control notification handler code here
  120. }
  121. void StaffAchievementShowAll::OnChangeEDITday()
  122. {
  123. // TODO: If this is a RICHEDIT control, the control will not
  124. // send this notification unless you override the CDialog::OnInitDialog()
  125. // function and call CRichEditCtrl().SetEventMask()
  126. // with the ENM_CHANGE flag ORed into the mask.
  127. if(m_bInit==0)return;
  128. DateChange();
  129. UpdateData();
  130. CString version = _T ("Version 1.0");
  131. AfxGetApp()->WriteProfileInt (version, "rowcount", m_day);
  132. // TODO: Add your control notification handler code here
  133. }
  134. extern void IsWaiter(CString id, CString name, CArray<CStringArray, CStringArray>*waiterarray, BOOL &bWait1, BOOL &bWait2);
  135. extern int GetYearPos(int year);
  136. void StaffAchievementShowAll::DateChange()
  137. {
  138. if(m_bInit==0)return;
  139. // if(::GetTickCount ()-m_timestmap<500)return;
  140. // m_timestmap=::GetTickCount ();
  141. UpdateData();
  142. CString date1,date2;
  143. #ifdef LIM_TIME
  144. date1.Format ("%d-%02d-14", m_year, m_month);
  145. date2.Format ("%d-%02d-31", m_year, 2);
  146. #else
  147. date1.Format ("%d-%02d-01", m_year, m_month);
  148. date2.Format ("%d-%02d-31", m_year, m_month);
  149. #endif
  150. #ifndef MNLS_VERSION
  151. date1.Format ("%d-%02d-01", m_year, m_month);
  152. date2.Format ("%d-%02d-31", m_year, m_month);
  153. #endif
  154. CArray<CStringArray, CStringArray>bukuanarray;
  155. CArray<CStringArray, CStringArray>bukuanarray2;
  156. CArray<CStringArray, CStringArray>singleincomearray;
  157. int i;
  158. int g_nYearposTemp=g_nYearpos;
  159. BOOL bLastYear=0;
  160. BOOL bThisYear=0;
  161. BOOL bOldYear=0;
  162. if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () )
  163. bThisYear=1;
  164. else if(m_year==atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ())
  165. bLastYear=1;
  166. else if(atoi(g_date.Left (4))-m_year>1 && g_hisyeararray.GetSize ()>=(atoi(g_date.Left (4))-m_year))
  167. {
  168. bOldYear=1;
  169. }
  170. g_nYearpos=GetYearPos(m_year);
  171. CString filter="date>='"+date1+"' and date<='"+date2+"';\
  172. dat>='"+date1+"' and dat<='"+date2+"';\
  173. ;\
  174. ;time2>='"+date1+"' and time2<='"+date2+"' and status<>'未拍'";
  175. //;time2>='"+date1+"' and time2<='"+date2+"' and status<>'未拍'
  176. g_sendhead.code[0]=59;
  177. g_sendhead.code[1]=14;
  178. g_sendhead.code[2]=60;
  179. g_sendhead.code[3]=34;
  180. g_sendhead.code[4]=61;
  181. g_sendhead.tabcount=5;
  182. g_sendhead.bsql=0;
  183. g_pMainWnd->ProcessChatMessageRequest2(filter);
  184. if(g_bSendOK==0)
  185. {
  186. g_nYearpos=g_nYearposTemp;
  187. return;
  188. }
  189. DataToArray(&bukuanarray,&singleincomearray,&waiterarray,&m_List1array,&bukuanarray2);
  190. if(bLastYear)//如果是去年, 则加今年的补款
  191. {
  192. g_nYearpos=-1;//今年
  193. filter="date>='"+date1+"' and date<='"+date2+"';;;time2>='"+date1+"' and time2<='"+date2+"' and status<>'未拍'";
  194. g_sendhead.code[0]=59;
  195. g_sendhead.code[1]=60;
  196. g_sendhead.code[2]=34;
  197. g_sendhead.code[3]=61;
  198. g_sendhead.tabcount=4;
  199. g_sendhead.bsql=0;
  200. g_pMainWnd->ProcessChatMessageRequest2(filter);
  201. if(g_bSendOK==0)
  202. {
  203. g_nYearpos=g_nYearposTemp;
  204. return;
  205. }
  206. CArray<CStringArray, CStringArray>ThisYearbukuanarray;
  207. CArray<CStringArray, CStringArray>ThisYearwaiterarray;
  208. CArray<CStringArray, CStringArray>ThisYearbukuanarray2;
  209. DataToArray(&ThisYearbukuanarray,&ThisYearwaiterarray,&m_List1array,&ThisYearbukuanarray2);
  210. int oldsize=bukuanarray.GetSize ();
  211. bukuanarray.SetSize(oldsize+ThisYearbukuanarray.GetSize ());
  212. for(i=oldsize; i<oldsize+ThisYearbukuanarray.GetSize (); i++)
  213. {
  214. bukuanarray.ElementAt (i).Copy(ThisYearbukuanarray.ElementAt (i-oldsize));
  215. }
  216. oldsize=bukuanarray2.GetSize ();
  217. bukuanarray2.SetSize(oldsize+ThisYearbukuanarray2.GetSize ());
  218. for(i=oldsize; i<oldsize+ThisYearbukuanarray2.GetSize (); i++)
  219. {
  220. bukuanarray2.ElementAt (i).Copy(ThisYearbukuanarray2.ElementAt (i-oldsize));
  221. }
  222. oldsize=waiterarray.GetSize ();
  223. waiterarray.SetSize(oldsize+ThisYearwaiterarray.GetSize ());
  224. for(i=oldsize; i<oldsize+ThisYearwaiterarray.GetSize (); i++)
  225. {
  226. waiterarray.ElementAt (i).Copy(ThisYearwaiterarray.ElementAt (i-oldsize));
  227. }
  228. }
  229. else if(bThisYear)//如果是今年, 则加去年的补款
  230. {
  231. g_nYearpos=0;//去年
  232. filter="date>='"+date1+"' and date<='"+date2+"';;time2>='"+date1+"' and time2<='"+date2+"' and status<>'未拍'";
  233. g_sendhead.code[0]=59;
  234. g_sendhead.code[1]=60;
  235. g_sendhead.code[2]=61;
  236. g_sendhead.tabcount=3;
  237. g_sendhead.bsql=0;
  238. g_pMainWnd->ProcessChatMessageRequest2(filter);
  239. if(g_bSendOK==0)
  240. {
  241. g_nYearpos=g_nYearposTemp;
  242. return;
  243. }
  244. CArray<CStringArray, CStringArray>LastYearbukuanarray;
  245. CArray<CStringArray, CStringArray>LastYearwaiterarray;
  246. CArray<CStringArray, CStringArray>LastYearbukuanarray2;
  247. DataToArray(&LastYearbukuanarray,&LastYearwaiterarray,&LastYearbukuanarray2);
  248. int oldsize=bukuanarray.GetSize ();
  249. bukuanarray.SetSize(oldsize+LastYearbukuanarray.GetSize ());
  250. for(i=oldsize; i<oldsize+LastYearbukuanarray.GetSize (); i++)
  251. {
  252. bukuanarray.ElementAt (i).Copy(LastYearbukuanarray.ElementAt (i-oldsize));
  253. }
  254. oldsize=bukuanarray2.GetSize ();
  255. bukuanarray2.SetSize(oldsize+LastYearbukuanarray2.GetSize ());
  256. for(i=oldsize; i<oldsize+LastYearbukuanarray2.GetSize (); i++)
  257. {
  258. bukuanarray2.ElementAt (i).Copy(LastYearbukuanarray2.ElementAt (i-oldsize));
  259. }
  260. oldsize=waiterarray.GetSize ();
  261. waiterarray.SetSize(oldsize+LastYearwaiterarray.GetSize ());
  262. for(i=oldsize; i<oldsize+LastYearwaiterarray.GetSize (); i++)
  263. {
  264. waiterarray.ElementAt (i).Copy(LastYearwaiterarray.ElementAt (i-oldsize));
  265. }
  266. }
  267. else if(bLastYear)//如果是以往年份, 则需更新员工信息
  268. {
  269. g_nYearpos=-1;//今年
  270. g_sendhead.code[0]=34;
  271. g_sendhead.tabcount=1;
  272. g_sendhead.bsql=0;
  273. g_pMainWnd->ProcessChatMessageRequest2(1);
  274. if(g_bSendOK==0)
  275. {
  276. g_nYearpos=g_nYearposTemp;
  277. return;
  278. }
  279. DataToArray(&m_List1array);
  280. }
  281. g_nYearpos=g_nYearposTemp;
  282. for( i=m_List1array.GetSize ()-1; i>=0; i--)
  283. {
  284. if(m_List1array.ElementAt(i).ElementAt (5)!="门市部" && m_List1array.ElementAt(i).ElementAt (5)!="摄影部" && m_List1array.ElementAt(i).ElementAt (5)!="化妆部" && m_List1array.ElementAt(i).ElementAt (5)!="礼服部")
  285. m_List1array.RemoveAt(i);
  286. }
  287. ////////////////////////////
  288. int ii=0;
  289. money1array.RemoveAll ();
  290. money1array.SetSize(m_List1array.GetSize ());
  291. money2array.RemoveAll ();
  292. money2array.SetSize(m_List1array.GetSize ());
  293. for(int n=0; n<m_List1array.GetSize (); n++)
  294. {
  295. CString name=m_List1array.ElementAt (n).ElementAt (0);
  296. float money1=0;
  297. float money2=0;
  298. int arraypos=0;
  299. for( ii=0; ii<bukuanarray.GetSize (); ii++)
  300. {
  301. if(bukuanarray.ElementAt (ii).ElementAt (2)=="3" || bukuanarray.ElementAt (ii).ElementAt (2)=="4")
  302. {
  303. /* BOOL bWait1=0;
  304. BOOL bWait2=0;
  305. IsWaiter(bukuanarray.ElementAt (ii).ElementAt (5), name, &waiterarray, bWait1, bWait2);
  306. if(bWait1)//我是摄影师
  307. {
  308. money1+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  309. }
  310. if(bWait2)//我是化妆师
  311. {
  312. money1+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  313. }*/
  314. if(bukuanarray.ElementAt (ii).ElementAt (6)!=name)continue;
  315. money1+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  316. }
  317. else if(bukuanarray.ElementAt (ii).ElementAt (2)=="2")//选片补款, 需加摄影师和化妆师
  318. {
  319. BOOL bWait1=0;
  320. BOOL bWait2=0;
  321. IsWaiter(bukuanarray.ElementAt (ii).ElementAt (5), name, &waiterarray, bWait1, bWait2);
  322. #ifdef MNLS_VERSION
  323. #ifdef LIM_TIME
  324. bWait1=0;
  325. bWait2=0;
  326. #endif
  327. #endif
  328. if(bWait1)//我是摄影师
  329. {
  330. money2+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  331. }
  332. if(bWait2)//我是化妆师
  333. {
  334. money2+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  335. }
  336. if(bukuanarray.ElementAt (ii).ElementAt (6)!=name)continue;
  337. money2+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  338. }
  339. else
  340. {
  341. if(bukuanarray.ElementAt (ii).ElementAt (6)!=name)continue;
  342. money2+=atof(bukuanarray.ElementAt (ii).ElementAt (0));
  343. }
  344. }
  345. for( ii=0; ii<bukuanarray2.GetSize (); ii++)
  346. {
  347. if(bukuanarray2.ElementAt (ii).ElementAt (2)=="3" || bukuanarray2.ElementAt (ii).ElementAt (2)=="4")
  348. {
  349. BOOL bWait1=0;
  350. BOOL bWait2=0;
  351. IsWaiter(bukuanarray2.ElementAt (ii).ElementAt (5), name, &waiterarray, bWait1, bWait2);
  352. #ifdef MNLS_VERSION
  353. #ifdef LIM_TIME
  354. bWait1=0;
  355. bWait2=0;
  356. #endif
  357. #endif
  358. if(bWait1)//我是摄影师
  359. {
  360. money1+=atof(bukuanarray2.ElementAt (ii).ElementAt (0));
  361. }
  362. if(bWait2)//我是化妆师
  363. {
  364. money1+=atof(bukuanarray2.ElementAt (ii).ElementAt (0));
  365. }
  366. }
  367. }
  368. for( ii=0; ii<singleincomearray.GetSize (); ii++)
  369. {
  370. if(singleincomearray.ElementAt (ii).ElementAt (6)!=name)continue;
  371. money2+=atof(singleincomearray.ElementAt (ii).ElementAt (2));
  372. }
  373. money1array.SetAt (n, money1);
  374. money2array.SetAt (n, money2);
  375. #ifdef MNLS_VERSION
  376. #ifdef LIM_TIME
  377. money2array.SetAt (n, 0);
  378. #endif
  379. #endif
  380. }
  381. #ifdef MNLS_VERSION
  382. #ifdef LIM_TIME
  383. m_radio2=0;//全部
  384. #endif
  385. #endif
  386. KindChange();
  387. OnRadio3();
  388. }
  389. void StaffAchievementShowAll::KindChange()
  390. {
  391. if(m_day<1)return;
  392. int chartcount=m_List1array.GetSize ()/m_day;
  393. if(m_List1array.GetSize ()%m_day)chartcount++;
  394. if(chartcount==0)return;
  395. int m_day=m_List1array.GetSize ()/chartcount;
  396. BOOL bAdd=0;
  397. if(m_List1array.GetSize ()%chartcount)
  398. {
  399. m_day++;
  400. bAdd=1;
  401. }
  402. for(int i=0; i<m_pChartArray.GetSize (); i++)
  403. {
  404. CMSChart *pChart=m_pChartArray.ElementAt (i);
  405. pChart->ShowWindow (SW_HIDE);
  406. }
  407. while(m_pChartArray.GetSize ()<chartcount)
  408. {
  409. CMSChart *pChart=new CMSChart;
  410. CRect rc(0,0,0,0);
  411. WCHAR pwchLicenseKey[] =
  412. {
  413. 0x0038, 0x0045, 0x0031, 0x0034, 0x0037, 0x0043,
  414. 0x0036, 0x0039, 0x002D, 0x0042, 0x0044, 0x0035,
  415. 0x0030, 0x002D, 0x0031, 0x0031, 0x0064, 0x0031,
  416. 0x002D, 0x0042, 0x0031, 0x0033, 0x0037, 0x002D,
  417. 0x0030, 0x0030, 0x0030, 0x0030, 0x0046, 0x0038,
  418. 0x0037, 0x0035, 0x0033, 0x0046, 0x0035, 0x0044
  419. };
  420. BSTR bstrLicense = ::SysAllocStringLen(pwchLicenseKey,
  421. sizeof(pwchLicenseKey)/sizeof(WCHAR));
  422. pChart->Create ("", WS_VISIBLE|WS_CHILD, rc, this, m_pChartArray.GetSize (), NULL, 0, bstrLicense );
  423. ::SysFreeString(bstrLicense);
  424. m_pChartArray.Add (pChart);
  425. InitChartStyle(pChart);
  426. SetChartStyle(pChart);
  427. }
  428. CRect rc;
  429. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  430. ScreenToClient(rc);
  431. int hei=rc.Height ()/chartcount;
  432. float fmaxmoney1=0;
  433. float fmaxmoney2=0; VARIANT var;
  434. for( i=0; i<chartcount; i++)
  435. {
  436. int nRowCount=min(m_day, m_List1array.GetSize ()-i*m_day);
  437. for(int row = 1; row <= nRowCount; ++row)
  438. {
  439. fmaxmoney1=max(fmaxmoney1, money1array.ElementAt (i*m_day+row-1));
  440. fmaxmoney2=max(fmaxmoney2, money2array.ElementAt (i*m_day+row-1));
  441. }
  442. }
  443. for( i=0; i<chartcount; i++)
  444. {
  445. CMSChart *pChart=m_pChartArray.ElementAt (i);
  446. rc.bottom =rc.top +hei;
  447. pChart->MoveWindow (rc);
  448. pChart->ShowWindow (SW_SHOW);
  449. rc.top +=hei;
  450. int nRowCount=min(m_day, m_List1array.GetSize ()-i*m_day);
  451. if(bAdd)
  452. {
  453. if(i==chartcount-1)nRowCount++;
  454. }
  455. pChart->SetRowCount(nRowCount);
  456. if(m_radio2==0)//叠加
  457. {
  458. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(fmaxmoney1+fmaxmoney2);
  459. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(0);
  460. for(int row = 1; row <= nRowCount; ++row)
  461. {
  462. pChart->SetRow(row);
  463. if(bAdd && i==chartcount-1 && row==nRowCount)
  464. {
  465. pChart->SetRowLabel("");
  466. pChart->GetDataGrid().SetData(row, 1, 0, 0);
  467. continue;
  468. }
  469. pChart->SetRowLabel(m_List1array.ElementAt (i*m_day+row-1).ElementAt (0));
  470. pChart->GetDataGrid().SetData(row, 1, money1array.ElementAt (i*m_day+row-1)+money2array.ElementAt (i*m_day+row-1), 0);
  471. }
  472. }
  473. else
  474. {
  475. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(max(fmaxmoney1,fmaxmoney2));
  476. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(0);
  477. for(int row = 1; row <= nRowCount; ++row)
  478. {
  479. pChart->SetRow(row);
  480. if(bAdd && i==chartcount-1 && row==nRowCount)
  481. {
  482. pChart->SetRowLabel("");
  483. pChart->GetDataGrid().SetData(row, 1, 0, 0);
  484. pChart->GetDataGrid().SetData(row, 2, 0, 0);
  485. continue;
  486. }
  487. pChart->SetRowLabel(m_List1array.ElementAt (i*m_day+row-1).ElementAt (0));
  488. pChart->GetDataGrid().SetData(row, 1, money1array.ElementAt (i*m_day+row-1), 0);
  489. pChart->GetDataGrid().SetData(row, 2, money2array.ElementAt (i*m_day+row-1), 0);
  490. }
  491. }
  492. pChart->Refresh();
  493. }
  494. }
  495. void StaffAchievementShowAll::OnRadio3()
  496. {
  497. // TODO: Add your control notification handler code here
  498. UpdateData();
  499. if(m_radio1==0)
  500. {
  501. for(int i=0; i<m_pChartArray.GetSize (); i++)
  502. {
  503. CMSChart *pChart=m_pChartArray.ElementAt (i);
  504. pChart->SetChartType(3);
  505. }
  506. }
  507. else if(m_radio1==1)
  508. {
  509. for(int i=0; i<m_pChartArray.GetSize (); i++)
  510. {
  511. CMSChart *pChart=m_pChartArray.ElementAt (i);
  512. pChart->SetChartType(1);
  513. }
  514. }
  515. else if(m_radio1==2)
  516. {
  517. for(int i=0; i<m_pChartArray.GetSize (); i++)
  518. {
  519. CMSChart *pChart=m_pChartArray.ElementAt (i);
  520. pChart->SetChartType(14);
  521. }
  522. }
  523. }
  524. void StaffAchievementShowAll::OnRadio4()
  525. {
  526. // TODO: Add your control notification handler code here
  527. OnRadio3();
  528. }
  529. void StaffAchievementShowAll::OnRadio5()
  530. {
  531. // TODO: Add your control notification handler code here
  532. OnRadio3();
  533. }
  534. void StaffAchievementShowAll::OnRadio6() //叠加
  535. {
  536. // TODO: Add your control notification handler code here
  537. UpdateData();
  538. for(int i=0; i<m_pChartArray.GetSize (); i++)
  539. {
  540. CMSChart *pChart=m_pChartArray.ElementAt (i);
  541. SetChartStyle(pChart);
  542. }
  543. KindChange();
  544. }
  545. void StaffAchievementShowAll::OnRadio7() //对比
  546. {
  547. // TODO: Add your control notification handler code here
  548. OnRadio6();
  549. }
  550. void StaffAchievementShowAll::SetChartStyle(CMSChart *pChart)
  551. {
  552. if(m_radio2==0)
  553. {
  554. pChart->SetColumnCount(1);
  555. pChart->SetColumn(1);
  556. pChart->SetColumnLabel((LPCTSTR)"全部");
  557. #ifdef MNLS_VERSION
  558. #ifdef LIM_TIME
  559. pChart->SetColumnLabel((LPCTSTR)"接单");
  560. #endif
  561. #endif
  562. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  563. // 线宽(对点线图有效)
  564. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  565. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  566. // 0: 不显示 1: 显示在柱状图外
  567. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  568. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  569. }
  570. else
  571. {
  572. pChart->SetColumnCount(2);
  573. pChart->SetColumn(1);
  574. pChart->SetColumnLabel((LPCTSTR)"前期");
  575. pChart->SetColumn(2);
  576. pChart->SetColumnLabel((LPCTSTR)"后期");
  577. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  578. pChart->GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 0);
  579. // 线宽(对点线图有效)
  580. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  581. pChart->GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(30);
  582. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  583. // 0: 不显示 1: 显示在柱状图外
  584. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  585. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  586. pChart->GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  587. }
  588. }
  589. void StaffAchievementShowAll::InitChartStyle(CMSChart *pChart)
  590. {
  591. VARIANT var;
  592. pChart->GetBackdrop().GetFill().SetStyle(1);
  593. pChart->GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  594. pChart->SetShowLegend(TRUE);
  595. pChart->SetChartType(3);
  596. // 栈模式
  597. pChart->SetStacking(FALSE);
  598. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetAuto(0); // 不自动标注Y轴刻度
  599. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  600. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  601. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  602. }
  603. void StaffAchievementShowAll::OnDestroy()
  604. {
  605. CDialog::OnDestroy();
  606. for(int i=0; i<m_pChartArray.GetSize (); i++)
  607. {
  608. CMSChart *pChart=m_pChartArray.ElementAt (i);
  609. pChart->DestroyWindow ();
  610. delete pChart;
  611. }
  612. KillTimer(1);
  613. m_pChartArray.RemoveAll ();
  614. HWND wnd = ::FindWindow("Shell_TrayWnd", 0);
  615. ::ShowWindow(wnd, SW_SHOW);
  616. ::ShowCursor (1);
  617. }
  618. void StaffAchievementShowAll::OnBUTshowall()
  619. {
  620. // TODO: Add your control notification handler code here
  621. }
  622. BOOL StaffAchievementShowAll::OnInitDialog()
  623. {
  624. CDialog::OnInitDialog();
  625. // TODO: Add extra initialization here
  626. CRect rc2;
  627. GetWindowRect(rc2);
  628. // ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  629. ::MoveWindow(m_hWnd,0,0,g_dm.dmPelsWidth,g_dm.dmPelsHeight,TRUE);
  630. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  631. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
  632. ScreenToClient(rc2);
  633. int wid=rc2.Width ();
  634. rc2.left =(g_dm.dmPelsWidth-wid)/2;
  635. rc2.right =rc2.left +wid;
  636. GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
  637. GetWindowRect(rc2);
  638. ScreenToClient(rc2);
  639. rc2.top +=40*g_fscaley;
  640. GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
  641. rc2.top =0;
  642. rc2.bottom =41*g_fscaley;
  643. GetDlgItem(IDC_STATIC3)->MoveWindow(rc2);
  644. m_static1.SetFont (&g_titlefont);
  645. CString str;
  646. #ifdef LIM_TIME
  647. str="蒙娜丽莎员工活动期间业绩图表(从2010-01-14开始,仅接单)";
  648. #else
  649. str.Format ("%s员工 %d年%d月 业绩图表", g_title, m_year, m_month);
  650. #endif
  651. #ifndef MNLS_VERSION
  652. str.Format ("%s员工 %d年%d月 业绩图表", g_title, m_year, m_month);
  653. #endif
  654. m_static1.SetWindowText (str);
  655. m_spinyear.SetRange (1900, 3000);
  656. m_spinmonth.SetRange (1, 12);
  657. m_spinday.SetRange (1, 31);
  658. CString version = _T ("Version 1.0");
  659. m_day=AfxGetApp()->GetProfileInt (version, "rowcount", 12);
  660. UpdateData(false);
  661. SetTimer(1, 1000*60*5, NULL);
  662. if(AfxGetApp()->GetProfileInt (version, "autoshutdown", 12))
  663. {
  664. SetTimer(2, 1000*60*5, NULL);
  665. m_time=AfxGetApp()->GetProfileInt (version, "shutdowntime", 20);
  666. }
  667. SetTimer(3, 100, NULL);
  668. HWND wnd = ::FindWindow("Shell_TrayWnd", 0);
  669. ::ShowWindow(wnd, SW_HIDE);
  670. ::ShowCursor (0);
  671. return TRUE; // return TRUE unless you set the focus to a control
  672. // EXCEPTION: OCX Property Pages should return FALSE
  673. }
  674. BOOL StaffAchievementShowAll::IsCtrlDown()
  675. {
  676. short state=GetKeyState(VK_LCONTROL);
  677. BYTE sta=(BYTE)(state>>8);
  678. state=GetKeyState(VK_RCONTROL);
  679. BYTE sta2=(BYTE)(state>>8);
  680. if(sta||sta2)
  681. return 1;
  682. else
  683. return 0;
  684. }//IsShiftDown
  685. BOOL StaffAchievementShowAll::IsShiftDown()
  686. {
  687. short state=GetKeyState(VK_LSHIFT);
  688. BYTE sta=(BYTE)(state>>8);
  689. state=GetKeyState(VK_RSHIFT);
  690. BYTE sta2=(BYTE)(state>>8);
  691. state=GetKeyState(VK_F2);
  692. BYTE sta3=(BYTE)(state>>8);
  693. if(sta||sta2||sta3)
  694. return 1;
  695. else
  696. return 0;
  697. }
  698. BOOL StaffAchievementShowAll::PreTranslateMessage(MSG* pMsg)
  699. {
  700. // TODO: Add your specialized code here and/or call the base class
  701. if(pMsg->message==WM_KEYDOWN)
  702. {
  703. switch (pMsg->wParam)
  704. {
  705. case VK_RETURN:
  706. case VK_ESCAPE:
  707. if(!g_bStaffAchievementShow)
  708. CDialog::OnCancel ();
  709. return 1;
  710. case VK_F4:
  711. if(IsCtrlDown() && IsShiftDown())
  712. CDialog::OnCancel ();
  713. return 1;
  714. }
  715. return 1;
  716. }
  717. return CDialog::PreTranslateMessage(pMsg);
  718. }
  719. void StaffAchievementShowAll::OnTimer(UINT nIDEvent)
  720. {
  721. // TODO: Add your message handler code here and/or call default
  722. if(nIDEvent==1)
  723. DateChange();
  724. else if(nIDEvent==2)
  725. {
  726. if(m_time<=CTime::GetCurrentTime ().GetHour ())
  727. {
  728. KillTimer(2);MyExitWindows();
  729. }
  730. }
  731. else if(nIDEvent==3)
  732. {
  733. KillTimer(3);
  734. m_bInit=1;
  735. DateChange();
  736. }
  737. }
  738. HBRUSH StaffAchievementShowAll::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  739. {
  740. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  741. // TODO: Change any attributes of the DC here
  742. if (nCtlColor==CTLCOLOR_STATIC && pWnd->GetDlgCtrlID ()==IDC_STATIC1)
  743. {
  744. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  745. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  746. }
  747. // TODO: Return a different brush if the default is not desired
  748. return hbr;
  749. }
  750. //Axis(1,var).GetValueScale().SetAu
  751. void StaffAchievementShowAll::MyExitWindows()
  752. {
  753. UINT t=EWX_SHUTDOWN|EWX_FORCE;
  754. OSVERSIONINFO osv; //定义一个操作系统信息的结构体
  755. osv.dwOSVersionInfoSize=sizeof OSVERSIONINFO;
  756. GetVersionEx(&osv); //查询当前操作系统
  757. if(osv.dwPlatformId==VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
  758. {
  759. //下面为向操作系统获取权限操作
  760. HANDLE hProcess,hToken;
  761. TOKEN_PRIVILEGES Privileges;
  762. LUID luid;
  763. hProcess=GetCurrentProcess();
  764. //下面为打开当前进程对话
  765. OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);
  766. Privileges.PrivilegeCount=1;
  767. LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid);
  768. Privileges.Privileges[0].Luid=luid;
  769. Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
  770. AdjustTokenPrivileges(hToken,FALSE,&Privileges,NULL,NULL,NULL);
  771. ExitWindowsEx(t,0);
  772. }
  773. else
  774. {
  775. ExitWindowsEx(t,0);//调用ExitWindowsEx关闭机器。
  776. PostQuitMessage(0);
  777. }
  778. }
  779. void StaffAchievementShowAll::OnClose()
  780. {
  781. // TODO: Add your message handler code here and/or call default
  782. // CDialog::OnClose();
  783. }