StaffAchievementShowAll.cpp 28 KB

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