Card2RegChart.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. // Card2RegChart.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Card2RegChart.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. /////////////////////////////////////////////////////////////////////////////
  29. // Card2RegChart
  30. IMPLEMENT_DYNCREATE(Card2RegChart, MyFormView)
  31. Card2RegChart::Card2RegChart()
  32. : MyFormView(Card2RegChart::IDD)
  33. {
  34. //{{AFX_DATA_INIT(Card2RegChart)
  35. m_year = atoi(g_date.Mid (0,4));
  36. m_month = atoi(g_date.Mid (5,2));
  37. m_day = atoi(g_date.Mid (8,2));
  38. m_bInit=0;
  39. m_radio1 = 1;
  40. //}}AFX_DATA_INIT
  41. //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  42. }
  43. Card2RegChart::~Card2RegChart()
  44. {
  45. }
  46. void Card2RegChart::DoDataExchange(CDataExchange* pDX)
  47. {
  48. MyFormView::DoDataExchange(pDX);
  49. //{{AFX_DATA_MAP(Card2RegChart)
  50. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  51. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  52. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  53. DDX_Control(pDX, IDC_STATIC1, m_static1);
  54. DDX_Text(pDX, IDC_EDITyear, m_year);
  55. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  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_Control(pDX, IDC_MSCHART1, m_Chart);
  61. DDX_Control(pDX, IDC_MSCHART2, m_Chart2);
  62. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(Card2RegChart, MyFormView)
  66. //{{AFX_MSG_MAP(Card2RegChart)
  67. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  68. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  69. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  70. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  71. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  72. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  73. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////////////////////
  77. // Card2RegChart diagnostics
  78. #ifdef _DEBUG
  79. void Card2RegChart::AssertValid() const
  80. {
  81. MyFormView::AssertValid();
  82. }
  83. void Card2RegChart::Dump(CDumpContext& dc) const
  84. {
  85. MyFormView::Dump(dc);
  86. }
  87. #endif //_DEBUG
  88. /////////////////////////////////////////////////////////////////////////////
  89. // Card2RegChart message handlers
  90. void Card2RegChart::OnInitialUpdate()
  91. {
  92. MyFormView::OnInitialUpdate();
  93. // TODO: Add your specialized code here and/or call the base class
  94. CMyMdi Mdi;
  95. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  96. // Here we create the outbar control using the splitter as its parent
  97. // and setting its id to the first pane.
  98. CRect rc2;
  99. GetWindowRect(rc2);
  100. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  101. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  102. m_static1.SetFont (&g_titlefont);
  103. m_spinyear.SetRange (1900, 3000);
  104. m_spinmonth.SetRange (1, 12);
  105. m_spinday.SetRange (1, 31);
  106. m_Chart.GetBackdrop().GetFill().SetStyle(1);
  107. m_Chart.GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  108. m_Chart.SetShowLegend(TRUE);
  109. m_Chart.SetColumnCount(2);
  110. m_Chart.SetColumn(1);
  111. m_Chart.SetColumnLabel((LPCTSTR)"发放副卡数");
  112. m_Chart.SetColumn(2);
  113. m_Chart.SetColumnLabel((LPCTSTR)"收回副卡数");
  114. m_Chart.SetChartType(3);
  115. // 栈模式
  116. m_Chart.SetStacking(FALSE);
  117. VARIANT var;
  118. m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度
  119. m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  120. m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  121. m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  122. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  123. m_Chart.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 0);
  124. // 线宽(对点线图有效)
  125. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  126. m_Chart.GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(30);
  127. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  128. // 0: 不显示 1: 显示在柱状图外
  129. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  130. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  131. m_Chart.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  132. //////////////////////
  133. m_Chart2.GetBackdrop().GetFill().SetStyle(1);
  134. m_Chart2.GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  135. m_Chart2.SetShowLegend(TRUE);
  136. m_Chart2.SetColumn(1);
  137. m_Chart2.SetColumnLabel((LPCTSTR)"转介绍积分");
  138. m_Chart2.SetChartType(3);
  139. // 栈模式
  140. m_Chart2.SetStacking(FALSE);
  141. m_Chart2.GetPlot().GetAxis(1,var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度
  142. m_Chart2.GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  143. m_Chart2.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  144. m_Chart2.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  145. m_Chart2.SetColumnCount(1);
  146. m_Chart2.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  147. // 线宽(对点线图有效)
  148. m_Chart2.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  149. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  150. // 0: 不显示 1: 显示在柱状图外
  151. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  152. m_Chart2.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  153. ///////////////////////////
  154. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc2);
  155. ScreenToClient(rc2);
  156. m_Chart.MoveWindow (rc2);
  157. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc2);
  158. ScreenToClient(rc2);
  159. m_Chart2.MoveWindow (rc2);
  160. m_Chart.SetChartType(1);
  161. m_Chart2.SetChartType(1);
  162. m_bInit=1;
  163. DateChange();
  164. }
  165. void Card2RegChart::OnBUTclose()
  166. {
  167. // TODO: Add your control notification handler code here
  168. GetParent()->SendMessage(WM_CLOSE);
  169. }
  170. void Card2RegChart::OnChangeEDITyear()
  171. {
  172. // TODO: If this is a RICHEDIT control, the control will not
  173. // send this notification unless you override the MyFormView::OnInitDialog()
  174. // function and call CRichEditCtrl().SetEventMask()
  175. // with the ENM_CHANGE flag ORed into the mask.
  176. DateChange();
  177. // TODO: Add your control notification handler code here
  178. }
  179. void Card2RegChart::OnChangeEDITmonth()
  180. {
  181. // TODO: If this is a RICHEDIT control, the control will not
  182. // send this notification unless you override the MyFormView::OnInitDialog()
  183. // function and call CRichEditCtrl().SetEventMask()
  184. // with the ENM_CHANGE flag ORed into the mask.
  185. // DateChange();
  186. // TODO: Add your control notification handler code here
  187. }
  188. void Card2RegChart::OnChangeEDITday()
  189. {
  190. // TODO: If this is a RICHEDIT control, the control will not
  191. // send this notification unless you override the MyFormView::OnInitDialog()
  192. // function and call CRichEditCtrl().SetEventMask()
  193. // with the ENM_CHANGE flag ORed into the mask.
  194. // DateChange();
  195. // TODO: Add your control notification handler code here
  196. }
  197. void Card2RegChart::DateChange()
  198. {
  199. if(m_bInit==0)return;
  200. m_spinyear.EnableWindow(0);
  201. m_spinmonth.EnableWindow(0);
  202. m_spinday.EnableWindow(0);
  203. UpdateData();
  204. g_sendhead.bsql=0;
  205. g_sendhead.code[0]=129;
  206. g_sendhead.tabcount=1;
  207. CString sql,strdate;
  208. strdate.Format ("%04d", m_year);
  209. m_static1.SetWindowText (strdate+"转介绍积分");
  210. g_pMainWnd->ProcessChatMessageRequest2(strdate);
  211. if(g_bSendOK==0)
  212. {
  213. m_spinyear.EnableWindow(1);
  214. m_spinmonth.EnableWindow(1);
  215. m_spinday.EnableWindow(1);
  216. return;
  217. }
  218. DataToArray(&m_List1array);
  219. KindChange();
  220. m_spinyear.EnableWindow(1);
  221. m_spinmonth.EnableWindow(1);
  222. m_spinday.EnableWindow(1);
  223. }
  224. void Card2RegChart::KindChange()
  225. {
  226. int i=0;
  227. int nsum[12]={0};
  228. int nret[12]={0};
  229. int npoint[12]={0};
  230. int scount=0;
  231. int nsret=0;
  232. int spoint=0;
  233. CString stryear[12]={"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
  234. for( i=0; i<m_List1array.GetSize (); i++)
  235. {
  236. if(m_List1array.ElementAt (i).ElementAt (9)!="")
  237. {
  238. nsret++;
  239. spoint+=atoi(m_List1array.ElementAt (i).ElementAt (8));
  240. nret[atoi(m_List1array.ElementAt (i).ElementAt (5).Mid (5, 2))-1]+=1;
  241. npoint[atoi(m_List1array.ElementAt (i).ElementAt (5).Mid (5, 2))-1]+=atoi(m_List1array.ElementAt (i).ElementAt (8));
  242. }
  243. nsum[atoi(m_List1array.ElementAt (i).ElementAt (5).Mid (5, 2))-1]+=1;
  244. scount++;
  245. }
  246. int nRowCount=12;// VARIANT var;
  247. m_Chart.SetRowCount(nRowCount);
  248. m_Chart2.SetRowCount(nRowCount);
  249. for(int row = 1; row <= nRowCount; ++row)
  250. {
  251. m_Chart.SetRow(row);
  252. m_Chart.SetRowLabel(stryear[row-1]);
  253. m_Chart.GetDataGrid().SetData(row, 1, nsum[row-1], 0);
  254. m_Chart.GetDataGrid().SetData(row, 2, nret[row-1], 0);
  255. m_Chart2.SetRow(row);
  256. m_Chart2.SetRowLabel(stryear[row-1]);
  257. m_Chart2.GetDataGrid().SetData(row, 1, npoint[row-1], 0);
  258. }
  259. m_Chart.Refresh();
  260. m_Chart2.Refresh();
  261. CString str;
  262. str.Format ("%d", scount);
  263. SetDlgItemText(IDC_EDITmoney1, str);
  264. str.Format ("%d", nsret);
  265. SetDlgItemText(IDC_EDITmoney2, str);
  266. str.Format ("%d", spoint);
  267. SetDlgItemText(IDC_EDITmoney3, str);
  268. }
  269. BOOL Card2RegChart::PreTranslateMessage(MSG* pMsg)
  270. {
  271. // TODO: Add your specialized code here and/or call the base class
  272. try
  273. {
  274. if(pMsg->message==WM_KEYDOWN)
  275. {
  276. switch (pMsg->wParam)
  277. {
  278. case VK_RETURN:
  279. return 1;
  280. case 0x43: // copy
  281. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  282. {
  283. GetFocus()->SendMessage(WM_COPY);
  284. return TRUE;
  285. }
  286. break;
  287. case 0x56: //Ctrl + V:
  288. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  289. {
  290. GetFocus()->SendMessage(WM_PASTE);
  291. return TRUE;
  292. }
  293. break;
  294. case 0x58: // cut
  295. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  296. {
  297. GetFocus()->SendMessage(WM_CUT);
  298. return TRUE;
  299. }
  300. break;
  301. case 0x5A: //undo
  302. case 0x59: //redo
  303. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  304. {
  305. GetFocus()->SendMessage(WM_UNDO);
  306. return TRUE;
  307. }
  308. break;
  309. }
  310. }
  311. return MyFormView::PreTranslateMessage(pMsg);
  312. }
  313. catch(...)
  314. {
  315. }
  316. return TRUE;
  317. }
  318. void Card2RegChart::OnRadio3()
  319. {
  320. // TODO: Add your control notification handler code here
  321. UpdateData();
  322. if(m_radio1==0)
  323. {
  324. m_Chart.SetChartType(3);
  325. m_Chart2.SetChartType(3);
  326. }
  327. else if(m_radio1==1)
  328. {
  329. m_Chart.SetChartType(1);
  330. m_Chart2.SetChartType(1);
  331. }
  332. else if(m_radio1==2)
  333. {
  334. m_Chart.SetChartType(14);
  335. m_Chart2.SetChartType(14);
  336. }
  337. }
  338. void Card2RegChart::OnRadio4()
  339. {
  340. // TODO: Add your control notification handler code here
  341. OnRadio3();
  342. }
  343. void Card2RegChart::OnRadio5()
  344. {
  345. // TODO: Add your control notification handler code here
  346. OnRadio3();
  347. }