// YearFormBranch2.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "YearFormBranch2.h" #include "MyMdi.H" #include "VcPlot.h" #include "VcAxis.h" #include "VcValueScale.h" #include "VcSeriesCollection.h" #include "VcSeries.h" #include "VcPen.h" #include "VcCategoryScale.h" #include "VcColor.h" #include "VcDataGrid.h" #include "VcBackdrop.h" #include "VcFill.h" #include "VcBrush.h" #include "VcDataPoints.h" #include "VcDataPoint.h" #include "VcDataPointLabel.h" #include "VcAxisTitle.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // YearFormBranch2 g_bDrawLogin extern BOOL g_bDrawLogin; IMPLEMENT_DYNCREATE(YearFormBranch2, MyFormView) YearFormBranch2::YearFormBranch2() : MyFormView(YearFormBranch2::IDD) { //{{AFX_DATA_INIT(YearFormBranch2) m_year = atoi(g_date.Mid (0,4)); m_month = atoi(g_date.Mid (5,2)); m_day = atoi(g_date.Mid (8,2)); m_radio1 = 1; m_bInit=0; g_bDrawLogin=0; //}}AFX_DATA_INIT } YearFormBranch2::~YearFormBranch2() { g_bDrawLogin=1; } void YearFormBranch2::DoDataExchange(CDataExchange* pDX) { MyFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(YearFormBranch2) DDX_Control(pDX, IDC_COMBO1, m_combomonth); DDX_Control(pDX, IDC_SPIN3, m_spinday); DDX_Control(pDX, IDC_SPIN2, m_spinmonth); DDX_Control(pDX, IDC_SPIN1, m_spinyear); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_Text(pDX, IDC_EDITyear, m_year); DDV_MinMaxUInt(pDX, m_year, 1900, 3000); DDX_Text(pDX, IDC_EDITmonth, m_month); DDV_MinMaxUInt(pDX, m_month, 1, 12); DDX_Text(pDX, IDC_EDITday, m_day); DDV_MinMaxUInt(pDX, m_day, 1, 31); DDX_Control(pDX, IDC_MSCHART3, m_Chart3); DDX_Radio(pDX, IDC_RADIO3, m_radio1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(YearFormBranch2, MyFormView) //{{AFX_MSG_MAP(YearFormBranch2) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear) ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth) ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_BN_CLICKED(IDC_RADIO4, OnRadio4) ON_BN_CLICKED(IDC_RADIO5, OnRadio5) ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // YearFormBranch2 diagnostics #ifdef _DEBUG void YearFormBranch2::AssertValid() const { MyFormView::AssertValid(); } void YearFormBranch2::Dump(CDumpContext& dc) const { MyFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // YearFormBranch2 message handlers void YearFormBranch2::OnInitialUpdate() { MyFormView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CMyMdi Mdi; Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this); // Here we create the outbar control using the splitter as its parent // and setting its id to the first pane. CRect rc2; GetWindowRect(rc2); ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE); EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0); m_static1.SetFont (&g_titlefont); m_spinyear.SetRange (1900, 3000); m_spinmonth.SetRange (1, 12); m_spinday.SetRange (1, 31); m_Chart3.GetBackdrop().GetFill().SetStyle(1); m_Chart3.GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255); m_Chart3.SetShowLegend(TRUE); VARIANT var; m_Chart3.SetChartType(1); // 栈模式 m_Chart3.SetStacking(FALSE); m_Chart3.GetPlot().GetAxis(1,var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度 m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度 m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注 m_Chart3.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线 m_Chart3.SetColumnCount(6); m_Chart3.SetColumn(1); m_Chart3.SetColumnLabel((LPCTSTR)"全部"); m_Chart3.SetColumn(2); m_Chart3.SetColumnLabel((LPCTSTR)"婚纱照"); m_Chart3.SetColumn(3); m_Chart3.SetColumnLabel((LPCTSTR)"写真照"); m_Chart3.SetColumn(4); m_Chart3.SetColumnLabel((LPCTSTR)"宝宝照"); m_Chart3.SetColumn(5); m_Chart3.SetColumnLabel((LPCTSTR)"全家福"); m_Chart3.SetColumn(6); m_Chart3.SetColumnLabel((LPCTSTR)"情侣照"); m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 0); m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 0); m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 0, 255); m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(0, 255, 255); m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 255, 0); m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetDataPoints ().GetItem(-1).GetBrush ().GetFillColor ().Set(255, 0, 255); // 线宽(对点线图有效) m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30); m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(30); m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetPen().SetWidth(30); m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetPen().SetWidth(30); m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetPen().SetWidth(30); m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetPen().SetWidth(30); // 数据点类型显示数据值的模式(对柱柱状图和点线图有效) // 0: 不显示 1: 显示在柱状图外 // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方 m_Chart3.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); m_Chart3.GetPlot().GetSeriesCollection().GetItem(2).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); m_Chart3.GetPlot().GetSeriesCollection().GetItem(3).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); m_Chart3.GetPlot().GetSeriesCollection().GetItem(4).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); m_Chart3.GetPlot().GetSeriesCollection().GetItem(5).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); m_Chart3.GetPlot().GetSeriesCollection().GetItem(6).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1); //////////////// GetDlgItem(IDC_STATIC2)->GetWindowRect(rc2); ScreenToClient(rc2); m_Chart3.MoveWindow (rc2); m_combomonth.AddString ("1 月"); m_combomonth.AddString ("2 月"); m_combomonth.AddString ("3 月"); m_combomonth.AddString ("4 月"); m_combomonth.AddString ("5 月"); m_combomonth.AddString ("6 月"); m_combomonth.AddString ("7 月"); m_combomonth.AddString ("8 月"); m_combomonth.AddString ("9 月"); m_combomonth.AddString ("10 月"); m_combomonth.AddString ("11 月"); m_combomonth.AddString ("12 月"); m_combomonth.AddString ("全年"); m_combomonth.SetCurSel (12); m_combomonth.GetWindowRect(rc2); ScreenToClient(rc2);rc2.bottom +=200; m_combomonth.MoveWindow (rc2); m_bInit=1; DateChange(); } void YearFormBranch2::FillGrid() { } void YearFormBranch2::OnBUTclose() { // TODO: Add your control notification handler code here GetParent()->SendMessage(WM_CLOSE); } void YearFormBranch2::OnChangeEDITyear() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the MyFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. DateChange(); // TODO: Add your control notification handler code here } void YearFormBranch2::OnChangeEDITmonth() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the MyFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // DateChange(); // TODO: Add your control notification handler code here } void YearFormBranch2::OnChangeEDITday() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the MyFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // DateChange(); // TODO: Add your control notification handler code here } void YearFormBranch2::DateChange() { if(m_bInit==0)return; m_spinyear.EnableWindow(0); m_spinmonth.EnableWindow(0); m_spinday.EnableWindow(0); UpdateData(); for(int aa=0; aa<=g_menubranchname.GetSize (); aa++) { if(aa==0) g_bNoConnDlg=0; else g_bNoConnDlg=1; if(aa*List2array=&(m_List2array[aa]); int i; int g_nYearposTemp=g_nYearpos; BOOL bLastYear=0; BOOL bThisYear=0; #if JEFF_TEST_ON // 2015开始禁用跨年数据; int g_nYearposPre = -1; if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize()) { g_nYearpos = -1; bThisYear = 1; if (m_year == 2014) { g_nYearposPre = GetYearPos(m_year - 1); } } else if (m_year <= 2013 && g_hisyeararray.GetSize()) { g_nYearpos = GetYearPos(m_year); if (g_nYearpos != -1) g_nYearposPre = GetYearPos(m_year - 1); bLastYear = 1; } #else if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () ) bThisYear=1; else if(m_year<=atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ()) bLastYear=1; g_nYearpos=GetYearPos(m_year); int g_nYearposPre=GetYearPos(m_year-1); #endif g_sendhead.bsql=0; g_sendhead.code[0]=181; g_sendhead.tabcount=1; CString sql,strdate,strdate2; strdate.Format ("%04d-%02d-%02d", m_year, 1, 1); strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31); m_static1.SetWindowText (strdate.Left (4)+"年订单图表"); sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'"); g_pMainWnd->ProcessChatMessageRequest2(sql); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; m_spinyear.EnableWindow(1); m_spinmonth.EnableWindow(1); m_spinday.EnableWindow(1); g_bNoConnDlg=0; g_branchname.Empty (); return; } DataToArray(List2array); if(bLastYear)//如果是去年, 则加今年的补款 { g_nYearpos=-1;//今年 g_sendhead.bsql=0; g_sendhead.code[0]=181; g_sendhead.tabcount=1; CString sql,strdate,strdate2; strdate.Format ("%04d-%02d-%02d", m_year, 1, 1); strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31); sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'"); g_pMainWnd->ProcessChatMessageRequest2(sql); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; m_spinyear.EnableWindow(1); m_spinmonth.EnableWindow(1); m_spinday.EnableWindow(1); g_bNoConnDlg=0; g_branchname.Empty (); return; } CArrayThisYearList2array; DataToArray(&ThisYearList2array); int oldsize=List2array->GetSize (); int newsize=ThisYearList2array.GetSize (); List2array->SetSize(oldsize+ThisYearList2array.GetSize ()); for(i=oldsize; iElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize)); } } if(g_nYearposPre!=-1)//如果是今年, 则加去年的补款 { g_nYearpos=g_nYearposPre;//去年 g_sendhead.bsql=0; g_sendhead.code[0]=181; g_sendhead.tabcount=1; CString sql,strdate,strdate2; strdate.Format ("%04d-%02d-%02d", m_year, 1, 1); strdate2.Format ("%04d-%02d-%02d", m_year, 12, 31); sql.Format ("time1>='"+strdate+"' and time1<='"+strdate2+"'"); g_pMainWnd->ProcessChatMessageRequest2(sql); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; m_spinyear.EnableWindow(1); m_spinmonth.EnableWindow(1); m_spinday.EnableWindow(1); g_bNoConnDlg=0; g_branchname.Empty (); return; } CArrayThisYearList2array; DataToArray(&ThisYearList2array); int oldsize=List2array->GetSize (); int newsize=ThisYearList2array.GetSize (); List2array->SetSize(oldsize+ThisYearList2array.GetSize ()); for(i=oldsize; iElementAt (i).Copy(ThisYearList2array.ElementAt (i-oldsize)); } } g_nYearpos=g_nYearposTemp; } g_bNoConnDlg=0; g_branchname.Empty (); KindChange(); m_spinyear.EnableWindow(1); m_spinmonth.EnableWindow(1); m_spinday.EnableWindow(1); } void YearFormBranch2::KindChange() { UpdateData(); int month=m_combomonth.GetCurSel (); if(month==-1) month=13; else month++; int i=0; int dindandata[30]={0}; int dindandata1[30]={0}; int dindandata2[30]={0}; int dindandata3[30]={0}; int dindandata4[30]={0}; int dindandata5[30]={0}; CString stryear[30]={""}; int nRowCount=g_menubranchname.GetSize ()+1; for(int aa=0; aa<=g_menubranchname.GetSize (); aa++) { if(aa*List2array=&(m_List2array[aa]); for( i=0; iGetSize (); i++) { if(month!=13 && month!=atoi(List2array->ElementAt (i).ElementAt (12).Mid (5, 2))) continue; if(List2array->ElementAt (i).ElementAt (3)=="婚纱照") dindandata1[aa]++; else if(List2array->ElementAt (i).ElementAt (3)=="写真照") dindandata2[aa]++; else if(List2array->ElementAt (i).ElementAt (3)=="宝宝照") dindandata3[aa]++; else if(List2array->ElementAt (i).ElementAt (3)=="全家福") dindandata4[aa]++; else if(List2array->ElementAt (i).ElementAt (3)=="情侣照") dindandata5[aa]++; } } m_Chart3.SetRowCount(nRowCount); for(int row = 1; row <= nRowCount; ++row) { m_Chart3.SetRow(row); m_Chart3.SetRowLabel(stryear[row-1]); m_Chart3.GetDataGrid().SetData(row, 1, dindandata1[row-1]+dindandata2[row-1]+dindandata3[row-1]+dindandata4[row-1]+dindandata5[row-1], 0); m_Chart3.GetDataGrid().SetData(row, 2, dindandata1[row-1], 0); m_Chart3.GetDataGrid().SetData(row, 3, dindandata2[row-1], 0); m_Chart3.GetDataGrid().SetData(row, 4, dindandata3[row-1], 0); m_Chart3.GetDataGrid().SetData(row, 5, dindandata4[row-1], 0); m_Chart3.GetDataGrid().SetData(row, 6, dindandata5[row-1], 0); } m_Chart3.Refresh(); } void YearFormBranch2::OnRadio3() { // TODO: Add your control notification handler code here UpdateData(); if(m_radio1==0) { m_Chart3.SetChartType(3); } else if(m_radio1==1) { m_Chart3.SetChartType(1); } else if(m_radio1==2) { m_Chart3.SetChartType(14); } } void YearFormBranch2::OnRadio4() { // TODO: Add your control notification handler code here OnRadio3(); } void YearFormBranch2::OnRadio5() { // TODO: Add your control notification handler code here OnRadio3(); } void YearFormBranch2::OnSelchangeCombo1() { // TODO: Add your control notification handler code here KindChange(); }