StoreInfoChart.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. // StoreInfoChart.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "StoreInfoChart.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 ONLYBOOKING 1
  29. /////////////////////////////////////////////////////////////////////////////
  30. // StoreInfoChart IDC_STATIC1
  31. IMPLEMENT_DYNCREATE(StoreInfoChart, MyFormView)
  32. StoreInfoChart::StoreInfoChart()
  33. : MyFormView(StoreInfoChart::IDD)
  34. {
  35. //{{AFX_DATA_INIT(StoreInfoChart)
  36. m_year = atoi(g_date.Mid (0,4));
  37. m_month = atoi(g_date.Mid (5,2));
  38. m_day = 12;
  39. m_radio1 = 1;
  40. m_bInit=0;
  41. //}}AFX_DATA_INIT
  42. g_pMainWnd->GetOcx();
  43. }
  44. StoreInfoChart::~StoreInfoChart()
  45. {
  46. }
  47. void StoreInfoChart::DoDataExchange(CDataExchange* pDX)
  48. {
  49. MyFormView::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(StoreInfoChart)
  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. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  57. DDX_Text(pDX, IDC_EDITmonth, m_month);
  58. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  59. DDX_Text(pDX, IDC_EDITday, m_day);
  60. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  61. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  62. //}}AFX_DATA_MAP
  63. }
  64. BEGIN_MESSAGE_MAP(StoreInfoChart, MyFormView)
  65. //{{AFX_MSG_MAP(StoreInfoChart)
  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_WM_DESTROY()
  73. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////////////////////
  77. // StoreInfoChart diagnostics
  78. #ifdef _DEBUG
  79. void StoreInfoChart::AssertValid() const
  80. {
  81. MyFormView::AssertValid();
  82. }
  83. void StoreInfoChart::Dump(CDumpContext& dc) const
  84. {
  85. MyFormView::Dump(dc);
  86. }
  87. #endif //_DEBUG
  88. /////////////////////////////////////////////////////////////////////////////
  89. // StoreInfoChart message handlers
  90. void StoreInfoChart::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. CString version = _T ("Version 1.0");
  107. m_day=AfxGetApp()->GetProfileInt (version, "rowcount2", 12);
  108. UpdateData(false);
  109. m_bInit=1;
  110. DateChange();
  111. }
  112. void StoreInfoChart::FillGrid()
  113. {
  114. }
  115. void StoreInfoChart::OnBUTclose()
  116. {
  117. // TODO: Add your control notification handler code here
  118. GetParent()->SendMessage(WM_CLOSE);
  119. }
  120. void StoreInfoChart::OnChangeEDITyear()
  121. {
  122. // TODO: If this is a RICHEDIT control, the control will not
  123. // send this notification unless you override the MyFormView::OnInitDialog()
  124. // function and call CRichEditCtrl().SetEventMask()
  125. // with the ENM_CHANGE flag ORed into the mask.
  126. DateChange();
  127. // TODO: Add your control notification handler code here
  128. }
  129. void StoreInfoChart::OnChangeEDITmonth()
  130. {
  131. // TODO: If this is a RICHEDIT control, the control will not
  132. // send this notification unless you override the MyFormView::OnInitDialog()
  133. // function and call CRichEditCtrl().SetEventMask()
  134. // with the ENM_CHANGE flag ORed into the mask.
  135. DateChange();
  136. // TODO: Add your control notification handler code here
  137. }
  138. void StoreInfoChart::OnChangeEDITday()
  139. {
  140. // TODO: If this is a RICHEDIT control, the control will not
  141. // send this notification unless you override the MyFormView::OnInitDialog()
  142. // function and call CRichEditCtrl().SetEventMask()
  143. // with the ENM_CHANGE flag ORed into the mask.
  144. if(m_bInit==0)return;
  145. DateChange();
  146. UpdateData();
  147. CString version = _T ("Version 1.0");
  148. AfxGetApp()->WriteProfileInt (version, "rowcount2", m_day);
  149. // TODO: Add your control notification handler code here
  150. }
  151. void StoreInfoChart::DateChange()
  152. {
  153. if(m_bInit==0)return;
  154. m_spinyear.EnableWindow(0);
  155. m_spinmonth.EnableWindow(0);
  156. m_spinday.EnableWindow(0);
  157. UpdateData();
  158. CString date1,date2;
  159. date1.Format ("%d-%02d-01", m_year, m_month);
  160. date2.Format ("%d-%02d-31", m_year, m_month);
  161. //CString filter="[date]>='"+date1+"' and [date]<='"+date2+"' \
  162. //and [id] like '%订单使用%' and [name]<>'入册' and [name]<>'入底' and [type]<>''";
  163. CString filter="[date]>='"+date1+"' and [date]<='"+date2+"' and [name]<>'入册' and [name]<>'入底' and [type]<>''";
  164. g_sendhead.code[0]=89;
  165. g_sendhead.tabcount=1;
  166. g_sendhead.bsql=0;
  167. g_pMainWnd->ProcessChatMessageRequest2(filter);
  168. if(g_bSendOK==0)
  169. {
  170. m_spinyear.EnableWindow(1);
  171. m_spinmonth.EnableWindow(1);
  172. m_spinday.EnableWindow(1);
  173. return;
  174. }
  175. DataToArray(&m_List1array);
  176. KindChange();
  177. m_spinyear.EnableWindow(1);
  178. m_spinmonth.EnableWindow(1);
  179. m_spinday.EnableWindow(1);
  180. }
  181. void StoreInfoChart::KindChange()
  182. {
  183. if(m_day<1)return;
  184. int chartcount=m_List1array.GetSize ()/m_day;
  185. if(m_List1array.GetSize ()%m_day)chartcount++;
  186. int i =0;
  187. for(i=0; i<m_pChartArray.GetSize (); i++)
  188. {
  189. CMSChart *pChart=m_pChartArray.ElementAt (i);
  190. pChart->ShowWindow (SW_HIDE);
  191. }
  192. if(chartcount==0)
  193. return;
  194. while(m_pChartArray.GetSize ()<chartcount)
  195. {
  196. CMSChart *pChart=new CMSChart;
  197. CRect rc(0,0,0,0);
  198. WCHAR pwchLicenseKey[] =
  199. {
  200. 0x0038, 0x0045, 0x0031, 0x0034, 0x0037, 0x0043,
  201. 0x0036, 0x0039, 0x002D, 0x0042, 0x0044, 0x0035,
  202. 0x0030, 0x002D, 0x0031, 0x0031, 0x0064, 0x0031,
  203. 0x002D, 0x0042, 0x0031, 0x0033, 0x0037, 0x002D,
  204. 0x0030, 0x0030, 0x0030, 0x0030, 0x0046, 0x0038,
  205. 0x0037, 0x0035, 0x0033, 0x0046, 0x0035, 0x0044
  206. };
  207. BSTR bstrLicense = ::SysAllocStringLen(pwchLicenseKey,
  208. sizeof(pwchLicenseKey)/sizeof(WCHAR));
  209. pChart->Create ("", WS_VISIBLE|WS_CHILD, rc, this, m_pChartArray.GetSize (), NULL, 0, bstrLicense );
  210. ::SysFreeString(bstrLicense);
  211. m_pChartArray.Add (pChart);
  212. InitChartStyle(pChart);
  213. SetChartStyle(pChart);
  214. }
  215. CRect rc;
  216. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  217. ScreenToClient(rc);
  218. int hei=rc.Height ()/chartcount;
  219. for( i=0; i<chartcount; i++)
  220. {
  221. CMSChart *pChart=m_pChartArray.ElementAt (i);
  222. rc.bottom =rc.top +hei;
  223. pChart->MoveWindow (rc);
  224. pChart->ShowWindow (SW_SHOW);
  225. rc.top +=hei;
  226. int nRowCount=min(m_day, m_List1array.GetSize ()-i*m_day);
  227. pChart->SetRowCount(nRowCount);
  228. for(int row = 1; row <= nRowCount; ++row)
  229. {
  230. pChart->SetRow(row);
  231. pChart->SetRowLabel(m_List1array.ElementAt (i*m_day+row-1).ElementAt (0));
  232. pChart->GetDataGrid().SetData(row, 1, atof(m_List1array.ElementAt (i*m_day+row-1).ElementAt (1)), 0);
  233. }
  234. pChart->Refresh();
  235. }
  236. OnRadio3();
  237. }
  238. void StoreInfoChart::OnRadio3()
  239. {
  240. // TODO: Add your control notification handler code here
  241. UpdateData();
  242. if(m_radio1==0)
  243. {
  244. for(int i=0; i<m_pChartArray.GetSize (); i++)
  245. {
  246. CMSChart *pChart=m_pChartArray.ElementAt (i);
  247. pChart->SetChartType(3);
  248. }
  249. }
  250. else if(m_radio1==1)
  251. {
  252. for(int i=0; i<m_pChartArray.GetSize (); i++)
  253. {
  254. CMSChart *pChart=m_pChartArray.ElementAt (i);
  255. pChart->SetChartType(1);
  256. }
  257. }
  258. else if(m_radio1==2)
  259. {
  260. for(int i=0; i<m_pChartArray.GetSize (); i++)
  261. {
  262. CMSChart *pChart=m_pChartArray.ElementAt (i);
  263. pChart->SetChartType(14);
  264. }
  265. }
  266. }
  267. void StoreInfoChart::OnRadio4()
  268. {
  269. // TODO: Add your control notification handler code here
  270. OnRadio3();
  271. }
  272. void StoreInfoChart::OnRadio5()
  273. {
  274. // TODO: Add your control notification handler code here
  275. OnRadio3();
  276. }
  277. void StoreInfoChart::SetChartStyle(CMSChart *pChart)
  278. {
  279. pChart->SetColumnCount(1);
  280. pChart->SetColumn(1);
  281. // pChart->SetColumnLabel((LPCTSTR)"全部");
  282. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  283. // 线宽(对点线图有效)
  284. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  285. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  286. // 0: 不显示 1: 显示在柱状图外
  287. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  288. pChart->GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  289. }
  290. void StoreInfoChart::InitChartStyle(CMSChart *pChart)
  291. {
  292. VARIANT var;
  293. pChart->GetBackdrop().GetFill().SetStyle(1);
  294. pChart->GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  295. pChart->SetShowLegend(false);
  296. pChart->SetChartType(3);
  297. // 栈模式
  298. pChart->SetStacking(FALSE);
  299. pChart->GetPlot().GetAxis(1,var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度
  300. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  301. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  302. pChart->GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  303. }
  304. void StoreInfoChart::OnDestroy()
  305. {
  306. for(int i=0; i<m_pChartArray.GetSize (); i++)
  307. {
  308. CMSChart *pChart=m_pChartArray.ElementAt (i);
  309. pChart->DestroyWindow ();
  310. delete pChart;
  311. }
  312. m_pChartArray.RemoveAll ();
  313. MyFormView::OnDestroy();
  314. }
  315. BOOL StoreInfoChart::PreTranslateMessage(MSG* pMsg)
  316. {
  317. // TODO: Add your specialized code here and/or call the base class
  318. try
  319. {
  320. if(pMsg->message==WM_KEYDOWN)
  321. {
  322. switch (pMsg->wParam)
  323. {
  324. case 0x43: // copy
  325. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  326. {
  327. GetFocus()->SendMessage(WM_COPY);
  328. return TRUE;
  329. }
  330. break;
  331. case 0x56: //Ctrl + V:
  332. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  333. {
  334. GetFocus()->SendMessage(WM_PASTE);
  335. return TRUE;
  336. }
  337. break;
  338. case 0x58: // cut
  339. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  340. {
  341. GetFocus()->SendMessage(WM_CUT);
  342. return TRUE;
  343. }
  344. break;
  345. case 0x5A: //undo
  346. case 0x59: //redo
  347. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  348. {
  349. GetFocus()->SendMessage(WM_UNDO);
  350. return TRUE;
  351. }
  352. break;
  353. }
  354. }
  355. return MyFormView::PreTranslateMessage(pMsg);
  356. }
  357. catch(...)
  358. {
  359. }
  360. }