123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- // DailyForm.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LYFZIPManage.h"
- #include "DailyForm.h"
- #include "MyMdi.H"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // DailyForm
- IMPLEMENT_DYNCREATE(DailyForm, CFormView)
- DailyForm::DailyForm()
- : CFormView(DailyForm::IDD)
- {
- //{{AFX_DATA_INIT(DailyForm)
- m_year = CTime::GetCurrentTime ().GetYear ();
- m_month = CTime::GetCurrentTime ().GetMonth ();
- m_day = CTime::GetCurrentTime ().GetDay ();
- m_bInit=0;
- m_timestmap=0;
- m_radio1 = 0;
- //}}AFX_DATA_INIT
- //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
- }
- DailyForm::~DailyForm()
- {
- }
- void DailyForm::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(DailyForm)
- 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_LIST2, m_List1);
- 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_Radio(pDX, IDC_RADIO3, m_radio1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(DailyForm, CFormView)
- //{{AFX_MSG_MAP(DailyForm)
- 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_BN_CLICKED(IDC_RADIO6, OnRadio6)
- ON_BN_CLICKED(IDC_RADIO7, OnRadio7)
- ON_BN_CLICKED(IDC_RADIO8, OnRadio8)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // DailyForm diagnostics
- #ifdef _DEBUG
- void DailyForm::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void DailyForm::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // DailyForm message handlers
- void DailyForm::OnInitialUpdate()
- {
- CFormView::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_List1.SetHeadings("项目名称,300;金额,100;项目类别,100;收入/支出,100;日期,100" );
- m_List1.LoadColumnInfo (107);
-
- m_spinyear.SetRange (1900, 3000);
- m_spinmonth.SetRange (1, 12);
- m_spinday.SetRange (1, 31);
-
- m_bInit=1;
- DateChange();
- }
- void DailyForm::FillGrid()
- {
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
- int count=0;
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
-
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
-
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- CString str;
- str.Format ("单数:%d", ii);
- SetDlgItemText(IDC_STATIC2, str);
- }
- void DailyForm::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
- void DailyForm::OnChangeEDITyear()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CFormView::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 DailyForm::OnChangeEDITmonth()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CFormView::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 DailyForm::OnChangeEDITday()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CFormView::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
- DateChange();
- // TODO: Add your control notification handler code here
-
- }
- extern int GetYearPos(int year);
- void DailyForm::DateChange()
- {
- if(m_bInit==0)return;
- // if(::GetTickCount ()-m_timestmap<500)return;
- // m_timestmap=::GetTickCount ();
- UpdateData();
- int i;
- int g_nYearposTemp=g_nYearpos;
- BOOL bLastYear=0;
- BOOL bThisYear=0;
- 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);
- g_sendhead.bsql=0;
- g_sendhead.code[0]=14;
- g_sendhead.code[1]=13;
- g_sendhead.code[2]=16;
- g_sendhead.tabcount=3;
- CString sql,strdate,strdate2;
- strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
- m_static1.SetWindowText (strdate+"日财务表");
- sql.Format ("dat='"+strdate+"';dat='"+strdate+"';date='"+strdate+"'");
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if(g_bSendOK==0)
- {
- g_nYearpos=g_nYearposTemp;
- return;
- }
- DataToArray(&List2array,&List3array,&List11array);
- if(bLastYear)//如果是去年, 则加今年的补款
- {
- g_nYearpos=-1;//今年
- g_sendhead.bsql=0;
- g_sendhead.code[0]=16;
- g_sendhead.tabcount=1;
- CString sql,strdate,strdate2;
- strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
- sql.Format ("date='"+strdate+"'");
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if(g_bSendOK==0)
- {
- g_nYearpos=g_nYearposTemp;
- return;
- }
- CArray<CStringArray, CStringArray>ThisYearList11array;
- DataToArray(&ThisYearList11array);
- int oldsize=List11array.GetSize ();
- int newsize=ThisYearList11array.GetSize ();
- List11array.SetSize(oldsize+ThisYearList11array.GetSize ());
- for(i=oldsize; i<oldsize+ThisYearList11array.GetSize (); i++)
- {
- List11array.ElementAt (i).Copy(ThisYearList11array.ElementAt (i-oldsize));
- }
- }
- else if(bThisYear)//如果是今年, 则加去年的补款
- {
- g_nYearpos=0;//去年
- g_sendhead.bsql=0;
- g_sendhead.code[0]=16;
- g_sendhead.tabcount=1;
- CString sql,strdate,strdate2;
- strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
- sql.Format ("date='"+strdate+"'");
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if(g_bSendOK==0)
- {
- g_nYearpos=g_nYearposTemp;
- return;
- }
- CArray<CStringArray, CStringArray>LastYearList11array;
- DataToArray(&LastYearList11array);
- int oldsize=List11array.GetSize ();
- int newsize=LastYearList11array.GetSize ();
- List11array.SetSize(oldsize+LastYearList11array.GetSize ());
- for(i=oldsize; i<oldsize+LastYearList11array.GetSize (); i++)
- {
- List11array.ElementAt (i).Copy(LastYearList11array.ElementAt (i-oldsize));
- }
- }
- g_nYearpos=g_nYearposTemp;
- KindChange();
- }
- void DailyForm::KindChange()
- {
- CString str;
- int pos=0;
- int dindanshu=0;
- float income=0;
- float payout=0;
- int count=List2array.GetSize ()+List3array.GetSize ()+List11array.GetSize ();
- m_List1array.RemoveAll ();
- m_List1array.SetSize(count);
- int i=0;
- if(m_radio1==0)
- {
- for( i=0; i<List11array.GetSize (); i++)
- {
- str=List11array.ElementAt (i).ElementAt (0);
- str+=";"+List11array.ElementAt (i).ElementAt (3);
- if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
- {
- str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
- if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
- str+=","+List11array.ElementAt (i).ElementAt (2);
- }
- else
- str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- str=List11array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
- if(List11array.ElementAt (i).ElementAt (5)=="预约收款")
- dindanshu++;
- pos++;
- }
- for( i=0; i<List2array.GetSize (); i++)
- {
- str=List2array.ElementAt (i).ElementAt (1)+";"+List2array.ElementAt (i).ElementAt (4)+";"+List2array.ElementAt (i).ElementAt (6);
- m_List1array.ElementAt (pos).Add(str);
- str=List2array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add("其它收入");
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List2array.ElementAt (i).ElementAt (3));
- pos++;
- }
- for( i=0; i<List3array.GetSize (); i++)
- {
- str=List3array.ElementAt (i).ElementAt (1)+";"+List3array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- str=List3array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- payout+=atof(str);
- m_List1array.ElementAt (pos).Add("固定费用");
- m_List1array.ElementAt (pos).Add("支出");
- m_List1array.ElementAt (pos).Add(List3array.ElementAt (i).ElementAt (3));
- pos++;
- }
- }
- else if(m_radio1==1)//收入
- {
- for( i=0; i<List11array.GetSize (); i++)
- {
- str=List11array.ElementAt (i).ElementAt (0);
- str+=";"+List11array.ElementAt (i).ElementAt (3);
- if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
- {
- str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
- if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
- str+=","+List11array.ElementAt (i).ElementAt (2);
- }
- else
- str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- str=List11array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
- if(List11array.ElementAt (i).ElementAt (5)=="预约收款")
- dindanshu++;
- pos++;
- }
- for( i=0; i<List2array.GetSize (); i++)
- {
- str=List2array.ElementAt (i).ElementAt (1)+";"+List2array.ElementAt (i).ElementAt (4)+";"+List2array.ElementAt (i).ElementAt (6);
- m_List1array.ElementAt (pos).Add(str);
- str=List2array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add("其它收入");
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List2array.ElementAt (i).ElementAt (3));
- pos++;
- }
- }
- else if(m_radio1==2)//支出
- {
- for( i=0; i<List3array.GetSize (); i++)
- {
- str=List3array.ElementAt (i).ElementAt (1)+";"+List3array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- str=List3array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- payout+=atof(str);
- m_List1array.ElementAt (pos).Add("固定费用");
- m_List1array.ElementAt (pos).Add("支出");
- m_List1array.ElementAt (pos).Add(List3array.ElementAt (i).ElementAt (3));
- pos++;
- }
- }
- else if(m_radio1==3)//定单
- {
- for( i=0; i<List11array.GetSize (); i++)
- {
- if(List11array.ElementAt (i).ElementAt (5)!="预约收款")continue;
- dindanshu++;
- str=List11array.ElementAt (i).ElementAt (0);
- str+=";"+List11array.ElementAt (i).ElementAt (3);
- if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
- {
- str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
- if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
- str+=","+List11array.ElementAt (i).ElementAt (2);
- }
- else
- str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- str=List11array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
- pos++;
- }
- }
- else if(m_radio1==4)//拍照加挑
- {
- for( i=0; i<List11array.GetSize (); i++)
- {
- if(List11array.ElementAt (i).ElementAt (5)!="拍照补款")continue;
- str=List11array.ElementAt (i).ElementAt (0);
- str+=";"+List11array.ElementAt (i).ElementAt (3);
- if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
- {
- str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
- if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
- str+=","+List11array.ElementAt (i).ElementAt (2);
- }
- else
- str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- str=List11array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
- pos++;
- }
- }
- else if(m_radio1==5)//选片加挑
- {
- for( i=0; i<List11array.GetSize (); i++)
- {
- if(List11array.ElementAt (i).ElementAt (5)!="选片补款")continue;
- str=List11array.ElementAt (i).ElementAt (0);
- str+=";"+List11array.ElementAt (i).ElementAt (3);
- if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
- {
- str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
- if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
- str+=","+List11array.ElementAt (i).ElementAt (2);
- }
- else
- str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
- m_List1array.ElementAt (pos).Add(str);
- str=List11array.ElementAt (i).ElementAt (4);
- m_List1array.ElementAt (pos).Add(str);
- income+=atof(str);
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
- m_List1array.ElementAt (pos).Add("收入");
- m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
- pos++;
- }
- }
- m_List1array.SetSize(pos);
- str.Format ("%f", income);
- ::ConvertToPrice (str);
- SetDlgItemText(IDC_EDITmoney1, str);
- str.Format ("%f", payout);
- ::ConvertToPrice (str);
- SetDlgItemText(IDC_EDITmoney2, str);
- str.Format ("%f", income-payout);
- ::ConvertToPrice (str);
- SetDlgItemText(IDC_EDITmoney3, str);
- str.Format ("%d", dindanshu);
- SetDlgItemText(IDC_EDITmoney4, str);
- FillGrid();
- }
- void DailyForm::OnRadio3()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
- void DailyForm::OnRadio4()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
- void DailyForm::OnRadio5()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
- void DailyForm::OnRadio6()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
- void DailyForm::OnRadio7()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
- void DailyForm::OnRadio8()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- KindChange();
- }
|