YearFormBranch2.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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 JEFF_TEST_ON // 2015开始禁用跨年数据;
  237. int g_nYearposPre = -1;
  238. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  239. {
  240. g_nYearpos = -1;
  241. bThisYear = 1;
  242. if (m_year == 2014)
  243. {
  244. g_nYearposPre = GetYearPos(m_year - 1);
  245. }
  246. }
  247. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  248. {
  249. g_nYearpos = GetYearPos(m_year);
  250. if (g_nYearpos != -1)
  251. g_nYearposPre = GetYearPos(m_year - 1);
  252. bLastYear = 1;
  253. }
  254. #else
  255. if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () )
  256. bThisYear=1;
  257. else if(m_year<=atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ())
  258. bLastYear=1;
  259. g_nYearpos=GetYearPos(m_year);
  260. int g_nYearposPre=GetYearPos(m_year-1);
  261. #endif
  262. g_sendhead.bsql=0;
  263. g_sendhead.code[0]=181;
  264. g_sendhead.tabcount=1;
  265. CString sql,strdate,strdate2;
  266. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  267. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  268. m_static1.SetWindowText (strdate.Left (4)+"年订单图表");
  269. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  270. g_pMainWnd->ProcessChatMessageRequest2(sql);
  271. if(g_bSendOK==0)
  272. {
  273. g_nYearpos=g_nYearposTemp;
  274. m_spinyear.EnableWindow(1);
  275. m_spinmonth.EnableWindow(1);
  276. m_spinday.EnableWindow(1);
  277. g_bNoConnDlg=0;
  278. g_branchname.Empty ();
  279. return;
  280. }
  281. DataToArray(List2array);
  282. if(bLastYear)//如果是去年, 则加今年的补款
  283. {
  284. g_nYearpos=-1;//今年
  285. g_sendhead.bsql=0;
  286. g_sendhead.code[0]=181;
  287. g_sendhead.tabcount=1;
  288. CString sql,strdate,strdate2;
  289. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  290. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  291. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  292. g_pMainWnd->ProcessChatMessageRequest2(sql);
  293. if(g_bSendOK==0)
  294. {
  295. g_nYearpos=g_nYearposTemp;
  296. m_spinyear.EnableWindow(1);
  297. m_spinmonth.EnableWindow(1);
  298. m_spinday.EnableWindow(1);
  299. g_bNoConnDlg=0;
  300. g_branchname.Empty ();
  301. return;
  302. }
  303. CArray<CStringArray, CStringArray>ThisYearList2array;
  304. DataToArray(&ThisYearList2array);
  305. int oldsize=List2array->GetSize ();
  306. int newsize=ThisYearList2array.GetSize ();
  307. List2array->SetSize(oldsize+ThisYearList2array.GetSize ());
  308. for(i=oldsize; i<oldsize+ThisYearList2array.GetSize (); i++)
  309. {
  310. List2array->ElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize));
  311. }
  312. }
  313. if(g_nYearposPre!=-1)//如果是今年, 则加去年的补款
  314. {
  315. g_nYearpos=g_nYearposPre;//去年
  316. g_sendhead.bsql=0;
  317. g_sendhead.code[0]=181;
  318. g_sendhead.tabcount=1;
  319. CString sql,strdate,strdate2;
  320. strdate.Format ("%04d-%02d-%02d", m_year, 1, 1);
  321. strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31);
  322. sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'");
  323. g_pMainWnd->ProcessChatMessageRequest2(sql);
  324. if(g_bSendOK==0)
  325. {
  326. g_nYearpos=g_nYearposTemp;
  327. m_spinyear.EnableWindow(1);
  328. m_spinmonth.EnableWindow(1);
  329. m_spinday.EnableWindow(1);
  330. g_bNoConnDlg=0;
  331. g_branchname.Empty ();
  332. return;
  333. }
  334. CArray<CStringArray, CStringArray>ThisYearList2array;
  335. DataToArray(&ThisYearList2array);
  336. int oldsize=List2array->GetSize ();
  337. int newsize=ThisYearList2array.GetSize ();
  338. List2array->SetSize(oldsize+ThisYearList2array.GetSize ());
  339. for(i=oldsize; i<oldsize+ThisYearList2array.GetSize (); i++)
  340. {
  341. List2array->ElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize));
  342. }
  343. }
  344. g_nYearpos=g_nYearposTemp;
  345. }
  346. g_bNoConnDlg=0;
  347. g_branchname.Empty ();
  348. KindChange();
  349. m_spinyear.EnableWindow(1);
  350. m_spinmonth.EnableWindow(1);
  351. m_spinday.EnableWindow(1);
  352. }
  353. void YearFormBranch2::KindChange()
  354. {
  355. UpdateData();
  356. int month=m_combomonth.GetCurSel ();
  357. if(month==-1)
  358. month=13;
  359. else
  360. month++;
  361. int i=0;
  362. int dindandata[30]={0};
  363. int dindandata1[30]={0};
  364. int dindandata2[30]={0};
  365. int dindandata3[30]={0};
  366. int dindandata4[30]={0};
  367. int dindandata5[30]={0};
  368. CString stryear[30]={""};
  369. int nRowCount=g_menubranchname.GetSize ()+1;
  370. for(int aa=0; aa<=g_menubranchname.GetSize (); aa++)
  371. {
  372. if(aa<g_menubranchname.GetSize ())
  373. stryear[aa]=g_menubranchname.ElementAt (aa);
  374. else
  375. stryear[aa]=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  376. CArray<CStringArray, CStringArray>*List2array=&(m_List2array[aa]);
  377. for( i=0; i<List2array->GetSize (); i++)
  378. {
  379. if(month!=13 && month!=atoi(List2array->ElementAt (i).ElementAt (12).Mid (5, 2)))
  380. continue;
  381. if(List2array->ElementAt (i).ElementAt (3)=="婚纱照")
  382. dindandata1[aa]++;
  383. else if(List2array->ElementAt (i).ElementAt (3)=="写真照")
  384. dindandata2[aa]++;
  385. else if(List2array->ElementAt (i).ElementAt (3)=="宝宝照")
  386. dindandata3[aa]++;
  387. else if(List2array->ElementAt (i).ElementAt (3)=="全家福")
  388. dindandata4[aa]++;
  389. else if(List2array->ElementAt (i).ElementAt (3)=="情侣照")
  390. dindandata5[aa]++;
  391. }
  392. }
  393. m_Chart3.SetRowCount(nRowCount);
  394. for(int row = 1; row <= nRowCount; ++row)
  395. {
  396. m_Chart3.SetRow(row);
  397. m_Chart3.SetRowLabel(stryear[row-1]);
  398. m_Chart3.GetDataGrid().SetData(row, 1, dindandata1[row-1]+dindandata2[row-1]+dindandata3[row-1]+dindandata4[row-1]+dindandata5[row-1], 0);
  399. m_Chart3.GetDataGrid().SetData(row, 2, dindandata1[row-1], 0);
  400. m_Chart3.GetDataGrid().SetData(row, 3, dindandata2[row-1], 0);
  401. m_Chart3.GetDataGrid().SetData(row, 4, dindandata3[row-1], 0);
  402. m_Chart3.GetDataGrid().SetData(row, 5, dindandata4[row-1], 0);
  403. m_Chart3.GetDataGrid().SetData(row, 6, dindandata5[row-1], 0);
  404. }
  405. m_Chart3.Refresh();
  406. }
  407. void YearFormBranch2::OnRadio3()
  408. {
  409. // TODO: Add your control notification handler code here
  410. UpdateData();
  411. if(m_radio1==0)
  412. {
  413. m_Chart3.SetChartType(3);
  414. }
  415. else if(m_radio1==1)
  416. {
  417. m_Chart3.SetChartType(1);
  418. }
  419. else if(m_radio1==2)
  420. {
  421. m_Chart3.SetChartType(14);
  422. }
  423. }
  424. void YearFormBranch2::OnRadio4()
  425. {
  426. // TODO: Add your control notification handler code here
  427. OnRadio3();
  428. }
  429. void YearFormBranch2::OnRadio5()
  430. {
  431. // TODO: Add your control notification handler code here
  432. OnRadio3();
  433. }
  434. void YearFormBranch2::OnSelchangeCombo1()
  435. {
  436. // TODO: Add your control notification handler code here
  437. KindChange();
  438. }