StaffAchievementShowAll.cpp 28 KB

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