YearFormBranch2.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. // YearFormBranch2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "YearFormBranch2.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. // YearFormBranch2 g_bDrawLogin
  30. extern BOOL g_bDrawLogin;
  31. IMPLEMENT_DYNCREATE(YearFormBranch2, MyFormView)
  32. YearFormBranch2::YearFormBranch2()
  33. : MyFormView(YearFormBranch2::IDD)
  34. {
  35. //{{AFX_DATA_INIT(YearFormBranch2)
  36. m_year = atoi(g_date.Mid (0,4));
  37. m_month = atoi(g_date.Mid (5,2));
  38. m_day = atoi(g_date.Mid (8,2));
  39. m_radio1 = 1;
  40. m_bInit=0;
  41. g_bDrawLogin=0;
  42. //}}AFX_DATA_INIT
  43. }
  44. YearFormBranch2::~YearFormBranch2()
  45. {
  46. g_bDrawLogin=1;
  47. }
  48. void YearFormBranch2::DoDataExchange(CDataExchange* pDX)
  49. {
  50. MyFormView::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(YearFormBranch2)
  52. DDX_Control(pDX, IDC_COMBO1, m_combomonth);
  53. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  54. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  55. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  56. DDX_Control(pDX, IDC_STATIC1, m_static1);
  57. DDX_Text(pDX, IDC_EDITyear, m_year);
  58. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  59. DDX_Text(pDX, IDC_EDITmonth, m_month);
  60. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  61. DDX_Text(pDX, IDC_EDITday, m_day);
  62. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  63. DDX_Control(pDX, IDC_MSCHART3, m_Chart3);
  64. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(YearFormBranch2, MyFormView)
  68. //{{AFX_MSG_MAP(YearFormBranch2)
  69. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  70. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  71. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  72. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  73. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  74. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  75. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  76. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79. /////////////////////////////////////////////////////////////////////////////
  80. // YearFormBranch2 diagnostics
  81. #ifdef _DEBUG
  82. void YearFormBranch2::AssertValid() const
  83. {
  84. MyFormView::AssertValid();
  85. }
  86. void YearFormBranch2::Dump(CDumpContext& dc) const
  87. {
  88. MyFormView::Dump(dc);
  89. }
  90. #endif //_DEBUG
  91. /////////////////////////////////////////////////////////////////////////////
  92. // YearFormBranch2 message handlers
  93. void YearFormBranch2::OnInitialUpdate()
  94. {
  95. MyFormView::OnInitialUpdate();
  96. // TODO: Add your specialized code here and/or call the base class
  97. CMyMdi Mdi;
  98. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  99. // Here we create the outbar control using the splitter as its parent
  100. // and setting its id to the first pane.
  101. CRect rc2;
  102. GetWindowRect(rc2);
  103. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  104. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  105. m_static1.SetFont (&g_titlefont);
  106. m_spinyear.SetRange (1900, 3000);
  107. m_spinmonth.SetRange (1, 12);
  108. m_spinday.SetRange (1, 31);
  109. m_Chart3.GetBackdrop().GetFill().SetStyle(1);
  110. m_Chart3.GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  111. m_Chart3.SetShowLegend(TRUE);
  112. VARIANT var;
  113. m_Chart3.SetChartType(1);
  114. // 栈模式
  115. m_Chart3.SetStacking(FALSE);
  116. m_Chart3.GetPlot().GetAxis(1,var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度
  117. m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  118. m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  119. m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  120. m_Chart3.SetColumnCount(6);
  121. m_Chart3.SetColumn(1);
  122. m_Chart3.SetColumnLabel((LPCTSTR)"全部");
  123. m_Chart3.SetColumn(2);
  124. m_Chart3.SetColumnLabel((LPCTSTR)"婚纱照");
  125. m_Chart3.SetColumn(3);
  126. m_Chart3.SetColumnLabel((LPCTSTR)"写真照");
  127. m_Chart3.SetColumn(4);
  128. m_Chart3.SetColumnLabel((LPCTSTR)"宝宝照");
  129. m_Chart3.SetColumn(5);
  130. m_Chart3.SetColumnLabel((LPCTSTR)"全家福");
  131. m_Chart3.SetColumn(6);
  132. m_Chart3.SetColumnLabel((LPCTSTR)"情侣照");
  133. m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0);
  134. m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 0);
  135. m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 0, 255);
  136. m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 255);
  137. m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 255, 0);
  138. m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 255);
  139. // 线宽(对点线图有效)
  140. m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  141. m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(30);
  142. m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetPen().SetWidth(30);
  143. m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetPen().SetWidth(30);
  144. m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetPen().SetWidth(30);
  145. m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetPen().SetWidth(30);
  146. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  147. // 0: 不显示 1: 显示在柱状图外
  148. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  149. m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  150. m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  151. m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  152. m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  153. m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  154. m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  155. ////////////////
  156. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc2);
  157. ScreenToClient(rc2);
  158. m_Chart3.MoveWindow (rc2);
  159. m_combomonth.AddString ("1 月");
  160. m_combomonth.AddString ("2 月");
  161. m_combomonth.AddString ("3 月");
  162. m_combomonth.AddString ("4 月");
  163. m_combomonth.AddString ("5 月");
  164. m_combomonth.AddString ("6 月");
  165. m_combomonth.AddString ("7 月");
  166. m_combomonth.AddString ("8 月");
  167. m_combomonth.AddString ("9 月");
  168. m_combomonth.AddString ("10 月");
  169. m_combomonth.AddString ("11 月");
  170. m_combomonth.AddString ("12 月");
  171. m_combomonth.AddString ("全年");
  172. m_combomonth.SetCurSel (12);
  173. m_combomonth.GetWindowRect(rc2);
  174. ScreenToClient(rc2);rc2.bottom +=200;
  175. m_combomonth.MoveWindow (rc2);
  176. m_bInit=1;
  177. DateChange();
  178. }
  179. void YearFormBranch2::FillGrid()
  180. {
  181. }
  182. void YearFormBranch2::OnBUTclose()
  183. {
  184. // TODO: Add your control notification handler code here
  185. GetParent()->SendMessage(WM_CLOSE);
  186. }
  187. void YearFormBranch2::OnChangeEDITyear()
  188. {
  189. // TODO: If this is a RICHEDIT control, the control will not
  190. // send this notification unless you override the MyFormView::OnInitDialog()
  191. // function and call CRichEditCtrl().SetEventMask()
  192. // with the ENM_CHANGE flag ORed into the mask.
  193. DateChange();
  194. // TODO: Add your control notification handler code here
  195. }
  196. void YearFormBranch2::OnChangeEDITmonth()
  197. {
  198. // TODO: If this is a RICHEDIT control, the control will not
  199. // send this notification unless you override the MyFormView::OnInitDialog()
  200. // function and call CRichEditCtrl().SetEventMask()
  201. // with the ENM_CHANGE flag ORed into the mask.
  202. // DateChange();
  203. // TODO: Add your control notification handler code here
  204. }
  205. void YearFormBranch2::OnChangeEDITday()
  206. {
  207. // TODO: If this is a RICHEDIT control, the control will not
  208. // send this notification unless you override the MyFormView::OnInitDialog()
  209. // function and call CRichEditCtrl().SetEventMask()
  210. // with the ENM_CHANGE flag ORed into the mask.
  211. // DateChange();
  212. // TODO: Add your control notification handler code here
  213. }
  214. void YearFormBranch2::DateChange()
  215. {
  216. if(m_bInit==0)return;
  217. m_spinyear.EnableWindow(0);
  218. m_spinmonth.EnableWindow(0);
  219. m_spinday.EnableWindow(0);
  220. UpdateData();
  221. for(int aa=0; aa<=g_menubranchname.GetSize (); aa++)
  222. {
  223. if(aa==0)
  224. g_bNoConnDlg=0;
  225. else
  226. g_bNoConnDlg=1;
  227. if(aa<g_menubranchname.GetSize ())
  228. g_branchname=g_menubranchname.ElementAt (aa);
  229. else
  230. g_branchname.Empty ();
  231. CArray<CStringArray, CStringArray>*List2array=&(m_List2array[aa]);
  232. int i;
  233. int g_nYearposTemp=g_nYearpos;
  234. BOOL bLastYear=0;
  235. BOOL bThisYear=0;
  236. if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () )
  237. bThisYear=1;
  238. else if(m_year<=atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ())
  239. bLastYear=1;
  240. g_nYearpos=GetYearPos(m_year);
  241. int g_nYearposPre=GetYearPos(m_year-1);
  242. g_sendhead.bsql=0;
  243. g_sendhead.code[0]=181;
  244. g_sendhead.tabcount=1;
  245. CString sql,strdate,strdate2;
  246. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  247. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  248. m_static1.SetWindowText (strdate.Left (4)+"年订单图表");
  249. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  250. g_pMainWnd->ProcessChatMessageRequest2(sql);
  251. if(g_bSendOK==0)
  252. {
  253. g_nYearpos=g_nYearposTemp;
  254. m_spinyear.EnableWindow(1);
  255. m_spinmonth.EnableWindow(1);
  256. m_spinday.EnableWindow(1);
  257. g_bNoConnDlg=0;
  258. g_branchname.Empty ();
  259. return;
  260. }
  261. DataToArray(List2array);
  262. if(bLastYear)//如果是去年, 则加今年的补款
  263. {
  264. g_nYearpos=-1;//今年
  265. g_sendhead.bsql=0;
  266. g_sendhead.code[0]=181;
  267. g_sendhead.tabcount=1;
  268. CString sql,strdate,strdate2;
  269. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  270. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  271. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  272. g_pMainWnd->ProcessChatMessageRequest2(sql);
  273. if(g_bSendOK==0)
  274. {
  275. g_nYearpos=g_nYearposTemp;
  276. m_spinyear.EnableWindow(1);
  277. m_spinmonth.EnableWindow(1);
  278. m_spinday.EnableWindow(1);
  279. g_bNoConnDlg=0;
  280. g_branchname.Empty ();
  281. return;
  282. }
  283. CArray<CStringArray, CStringArray>ThisYearList2array;
  284. DataToArray(&ThisYearList2array);
  285. int oldsize=List2array->GetSize ();
  286. int newsize=ThisYearList2array.GetSize ();
  287. List2array->SetSize(oldsize+ThisYearList2array.GetSize ());
  288. for(i=oldsize; i<oldsize+ThisYearList2array.GetSize (); i++)
  289. {
  290. List2array->ElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize));
  291. }
  292. }
  293. if(g_nYearposPre!=-1)//如果是今年, 则加去年的补款
  294. {
  295. g_nYearpos=g_nYearposPre;//去年
  296. g_sendhead.bsql=0;
  297. g_sendhead.code[0]=181;
  298. g_sendhead.tabcount=1;
  299. CString sql,strdate,strdate2;
  300. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  301. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  302. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  303. g_pMainWnd->ProcessChatMessageRequest2(sql);
  304. if(g_bSendOK==0)
  305. {
  306. g_nYearpos=g_nYearposTemp;
  307. m_spinyear.EnableWindow(1);
  308. m_spinmonth.EnableWindow(1);
  309. m_spinday.EnableWindow(1);
  310. g_bNoConnDlg=0;
  311. g_branchname.Empty ();
  312. return;
  313. }
  314. CArray<CStringArray, CStringArray>ThisYearList2array;
  315. DataToArray(&ThisYearList2array);
  316. int oldsize=List2array->GetSize ();
  317. int newsize=ThisYearList2array.GetSize ();
  318. List2array->SetSize(oldsize+ThisYearList2array.GetSize ());
  319. for(i=oldsize; i<oldsize+ThisYearList2array.GetSize (); i++)
  320. {
  321. List2array->ElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize));
  322. }
  323. }
  324. g_nYearpos=g_nYearposTemp;
  325. }
  326. g_bNoConnDlg=0;
  327. g_branchname.Empty ();
  328. KindChange();
  329. m_spinyear.EnableWindow(1);
  330. m_spinmonth.EnableWindow(1);
  331. m_spinday.EnableWindow(1);
  332. }
  333. void YearFormBranch2::KindChange()
  334. {
  335. UpdateData();
  336. int month=m_combomonth.GetCurSel ();
  337. if(month==-1)
  338. month=13;
  339. else
  340. month++;
  341. int i=0;
  342. int dindandata[30]={0};
  343. int dindandata1[30]={0};
  344. int dindandata2[30]={0};
  345. int dindandata3[30]={0};
  346. int dindandata4[30]={0};
  347. int dindandata5[30]={0};
  348. CString stryear[30]={""};
  349. int nRowCount=g_menubranchname.GetSize ()+1;
  350. for(int aa=0; aa<=g_menubranchname.GetSize (); aa++)
  351. {
  352. if(aa<g_menubranchname.GetSize ())
  353. stryear[aa]=g_menubranchname.ElementAt (aa);
  354. else
  355. stryear[aa]=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  356. CArray<CStringArray, CStringArray>*List2array=&(m_List2array[aa]);
  357. for( i=0; i<List2array->GetSize (); i++)
  358. {
  359. if(month!=13 && month!=atoi(List2array->ElementAt (i).ElementAt (12).Mid (5, 2)))
  360. continue;
  361. if(List2array->ElementAt (i).ElementAt (3)=="婚纱照")
  362. dindandata1[aa]++;
  363. else if(List2array->ElementAt (i).ElementAt (3)=="写真照")
  364. dindandata2[aa]++;
  365. else if(List2array->ElementAt (i).ElementAt (3)=="宝宝照")
  366. dindandata3[aa]++;
  367. else if(List2array->ElementAt (i).ElementAt (3)=="全家福")
  368. dindandata4[aa]++;
  369. else if(List2array->ElementAt (i).ElementAt (3)=="情侣照")
  370. dindandata5[aa]++;
  371. }
  372. }
  373. m_Chart3.SetRowCount(nRowCount);
  374. for(int row = 1; row <= nRowCount; ++row)
  375. {
  376. m_Chart3.SetRow(row);
  377. m_Chart3.SetRowLabel(stryear[row-1]);
  378. m_Chart3.GetDataGrid().SetData(row, 1, dindandata1[row-1]+dindandata2[row-1]+dindandata3[row-1]+dindandata4[row-1]+dindandata5[row-1], 0);
  379. m_Chart3.GetDataGrid().SetData(row, 2, dindandata1[row-1], 0);
  380. m_Chart3.GetDataGrid().SetData(row, 3, dindandata2[row-1], 0);
  381. m_Chart3.GetDataGrid().SetData(row, 4, dindandata3[row-1], 0);
  382. m_Chart3.GetDataGrid().SetData(row, 5, dindandata4[row-1], 0);
  383. m_Chart3.GetDataGrid().SetData(row, 6, dindandata5[row-1], 0);
  384. }
  385. m_Chart3.Refresh();
  386. }
  387. void YearFormBranch2::OnRadio3()
  388. {
  389. // TODO: Add your control notification handler code here
  390. UpdateData();
  391. if(m_radio1==0)
  392. {
  393. m_Chart3.SetChartType(3);
  394. }
  395. else if(m_radio1==1)
  396. {
  397. m_Chart3.SetChartType(1);
  398. }
  399. else if(m_radio1==2)
  400. {
  401. m_Chart3.SetChartType(14);
  402. }
  403. }
  404. void YearFormBranch2::OnRadio4()
  405. {
  406. // TODO: Add your control notification handler code here
  407. OnRadio3();
  408. }
  409. void YearFormBranch2::OnRadio5()
  410. {
  411. // TODO: Add your control notification handler code here
  412. OnRadio3();
  413. }
  414. void YearFormBranch2::OnSelchangeCombo1()
  415. {
  416. // TODO: Add your control notification handler code here
  417. KindChange();
  418. }