MonthForm.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. // MonthForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "MonthForm.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // MonthForm
  14. IMPLEMENT_DYNCREATE(MonthForm, CFormView)
  15. MonthForm::MonthForm()
  16. : CFormView(MonthForm::IDD)
  17. {
  18. m_year = CTime::GetCurrentTime ().GetYear ();
  19. m_month = CTime::GetCurrentTime ().GetMonth ();
  20. m_day = CTime::GetCurrentTime ().GetDay ();
  21. m_bInit=0;
  22. m_timestmap=0;
  23. m_radio1 = 0;
  24. //}}AFX_DATA_INIT
  25. //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  26. }
  27. MonthForm::~MonthForm()
  28. {
  29. }
  30. void MonthForm::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CFormView::DoDataExchange(pDX);
  33. //--
  34. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  35. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  36. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  37. DDX_Control(pDX, IDC_LIST2, m_List1);
  38. DDX_Control(pDX, IDC_STATIC1, m_static1);
  39. DDX_Text(pDX, IDC_EDITyear, m_year);
  40. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  41. DDX_Text(pDX, IDC_EDITmonth, m_month);
  42. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  43. DDX_Text(pDX, IDC_EDITday, m_day);
  44. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  45. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(MonthForm, CFormView)
  49. //---
  50. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  51. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  52. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  53. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  54. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  55. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  56. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  57. ON_BN_CLICKED(IDC_RADIO6, OnRadio6)
  58. ON_BN_CLICKED(IDC_RADIO7, OnRadio7)
  59. ON_BN_CLICKED(IDC_RADIO8, OnRadio8)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // MonthForm diagnostics
  64. #ifdef _DEBUG
  65. void MonthForm::AssertValid() const
  66. {
  67. CFormView::AssertValid();
  68. }
  69. void MonthForm::Dump(CDumpContext& dc) const
  70. {
  71. CFormView::Dump(dc);
  72. }
  73. #endif //_DEBUG
  74. /////////////////////////////////////////////////////////////////////////////
  75. // MonthForm message handlers
  76. void MonthForm::OnInitialUpdate()
  77. {
  78. //AfxMessageBox("void MonthForm2::OnInitialUpdate()");
  79. LOG4C((LOG_NOTICE,"月财务报表::OnInitialUpdate"));
  80. CFormView::OnInitialUpdate();
  81. // TODO: Add your specialized code here and/or call the base class
  82. CMyMdi Mdi;
  83. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  84. // Here we create the outbar control using the splitter as its parent
  85. // and setting its id to the first pane.
  86. CRect rc2;
  87. GetWindowRect(rc2);
  88. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  89. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  90. m_static1.SetFont (&g_titlefont);
  91. m_List1.SetHeadings("项目名称,300;金额,100;项目类别,100;收入/支出,100;日期,100" );
  92. m_List1.LoadColumnInfo (107);
  93. m_spinyear.SetRange (1900, 3000);
  94. m_spinmonth.SetRange (1, 12);
  95. m_spinday.SetRange (1, 31);
  96. m_bInit=1;
  97. DateChange();
  98. }
  99. void MonthForm::FillGrid()
  100. {
  101. m_List1.DeleteAllItems2 ();
  102. int ii=0;
  103. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  104. int count=0;
  105. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  106. {
  107. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  108. }
  109. m_List1.m_arLabels.SetSize(count, 1);
  110. ii=count;
  111. m_List1.m_LabelCount=ii;
  112. m_List1.SetItemCountEx (ii);
  113. CString str;
  114. str.Format ("单数:%d", ii);
  115. SetDlgItemText(IDC_STATIC2, str);
  116. }
  117. void MonthForm::OnBUTclose()
  118. {
  119. // TODO: Add your control notification handler code here
  120. GetParent()->SendMessage(WM_CLOSE);
  121. }
  122. void MonthForm::OnChangeEDITyear()
  123. {
  124. // TODO: If this is a RICHEDIT control, the control will not
  125. // send this notification unless you override the CFormView::OnInitDialog()
  126. // function and call CRichEditCtrl().SetEventMask()
  127. // with the ENM_CHANGE flag ORed into the mask.
  128. DateChange();
  129. // TODO: Add your control notification handler code here
  130. }
  131. void MonthForm::OnChangeEDITmonth()
  132. {
  133. // TODO: If this is a RICHEDIT control, the control will not
  134. // send this notification unless you override the CFormView::OnInitDialog()
  135. // function and call CRichEditCtrl().SetEventMask()
  136. // with the ENM_CHANGE flag ORed into the mask.
  137. DateChange();
  138. // TODO: Add your control notification handler code here
  139. }
  140. void MonthForm::OnChangeEDITday()
  141. {
  142. // TODO: If this is a RICHEDIT control, the control will not
  143. // send this notification unless you override the CFormView::OnInitDialog()
  144. // function and call CRichEditCtrl().SetEventMask()
  145. // with the ENM_CHANGE flag ORed into the mask.
  146. // DateChange();
  147. // TODO: Add your control notification handler code here
  148. }
  149. extern int GetYearPos(int year);
  150. void MonthForm::DateChange()
  151. {
  152. LOG4C((LOG_NOTICE,"void MonthForm::DateChange"));
  153. if(m_bInit==0)
  154. return;
  155. // if(::GetTickCount ()-m_timestmap<500)return;
  156. // m_timestmap=::GetTickCount ();
  157. UpdateData();
  158. int i;
  159. int g_nYearposTemp=g_nYearpos;
  160. BOOL bLastYear=0;
  161. BOOL bThisYear=0;
  162. if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () )
  163. bThisYear=1;
  164. else if(m_year==atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ())
  165. bLastYear=1;
  166. g_nYearpos=GetYearPos(m_year);
  167. g_sendhead.bsql=0;
  168. g_sendhead.code[0]=14;
  169. g_sendhead.code[1]=13;
  170. g_sendhead.code[2]=16;
  171. g_sendhead.tabcount=3;
  172. CString sql,strdate,strdate2;
  173. strdate.Format ("%04d-%02d-%02d", m_year, m_month, 1);
  174. strdate2.Format ("%04d-%02d-%02d", m_year, m_month, 31);
  175. m_static1.SetWindowText (strdate.Left (7)+"月财务表");
  176. sql.Format ("dat>='"+strdate+"' and dat<='"+strdate2+"';dat>='"+strdate+"' and dat<='"+strdate2+"';date>='"+strdate+"' and date<='"+strdate2+"'");
  177. g_pMainWnd->ProcessChatMessageRequest2(sql);
  178. if(g_bSendOK==0)
  179. {
  180. g_nYearpos=g_nYearposTemp;
  181. return;
  182. }
  183. DataToArray(&List2array,&List3array,&List11array);
  184. if(bLastYear)//如果是去年, 则加今年的补款
  185. {
  186. g_nYearpos=-1;//今年
  187. g_sendhead.bsql=0;
  188. g_sendhead.code[0]=16;
  189. g_sendhead.tabcount=1;
  190. CString sql,strdate,strdate2;
  191. strdate.Format ("%04d-%02d-%02d", m_year, m_month, 1);
  192. strdate2.Format ("%04d-%02d-%02d", m_year, m_month, 31);
  193. sql.Format ("date>='"+strdate+"' and date<='"+strdate2+"'");
  194. g_pMainWnd->ProcessChatMessageRequest2(sql);
  195. if(g_bSendOK==0)
  196. {
  197. g_nYearpos=g_nYearposTemp;
  198. return;
  199. }
  200. CArray<CStringArray, CStringArray>ThisYearList11array;
  201. DataToArray(&ThisYearList11array);
  202. int oldsize=List11array.GetSize ();
  203. int newsize=ThisYearList11array.GetSize ();
  204. List11array.SetSize(oldsize+ThisYearList11array.GetSize ());
  205. for(i=oldsize; i<oldsize+ThisYearList11array.GetSize (); i++)
  206. {
  207. List11array.ElementAt (i).Copy(ThisYearList11array.ElementAt (i-oldsize));
  208. }
  209. }
  210. else if(bThisYear)//如果是今年, 则加去年的补款
  211. {
  212. g_nYearpos=0;//去年
  213. g_sendhead.bsql=0;
  214. g_sendhead.code[0]=16;
  215. g_sendhead.tabcount=1;
  216. CString sql,strdate,strdate2;
  217. strdate.Format ("%04d-%02d-%02d", m_year, m_month, 1);
  218. strdate2.Format ("%04d-%02d-%02d", m_year, m_month, 31);
  219. sql.Format ("date>='"+strdate+"' and date<='"+strdate2+"'");
  220. g_pMainWnd->ProcessChatMessageRequest2(sql);
  221. if(g_bSendOK==0)
  222. {
  223. g_nYearpos=g_nYearposTemp;
  224. return;
  225. }
  226. CArray<CStringArray, CStringArray>LastYearList11array;
  227. DataToArray(&LastYearList11array);
  228. int oldsize=List11array.GetSize ();
  229. int newsize=LastYearList11array.GetSize ();
  230. List11array.SetSize(oldsize+LastYearList11array.GetSize ());
  231. for(i=oldsize; i<oldsize+LastYearList11array.GetSize (); i++)
  232. {
  233. List11array.ElementAt (i).Copy(LastYearList11array.ElementAt (i-oldsize));
  234. }
  235. }
  236. g_nYearpos=g_nYearposTemp;
  237. KindChange();
  238. }
  239. void MonthForm::KindChange()
  240. {
  241. CString str;
  242. int pos=0;
  243. int dindanshu=0;
  244. float income=0;
  245. float payout=0;
  246. int count=List2array.GetSize ()+List3array.GetSize ()+List11array.GetSize ();
  247. m_List1array.RemoveAll ();
  248. m_List1array.SetSize(count);
  249. int i=0;
  250. if(m_radio1==0)
  251. {
  252. for( i=0; i<List11array.GetSize (); i++)
  253. {
  254. str=List11array.ElementAt (i).ElementAt (0);
  255. str+=";"+List11array.ElementAt (i).ElementAt (3);
  256. if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
  257. {
  258. str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
  259. if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
  260. str+=","+List11array.ElementAt (i).ElementAt (2);
  261. }
  262. else
  263. str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
  264. m_List1array.ElementAt (pos).Add(str);
  265. str=List11array.ElementAt (i).ElementAt (4);
  266. m_List1array.ElementAt (pos).Add(str);
  267. income+=atof(str);
  268. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
  269. m_List1array.ElementAt (pos).Add("收入");
  270. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
  271. if(List11array.ElementAt (i).ElementAt (5)=="预约收款")
  272. dindanshu++;
  273. pos++;
  274. }
  275. for( i=0; i<List2array.GetSize (); i++)
  276. {
  277. str=List2array.ElementAt (i).ElementAt (1)+";"+List2array.ElementAt (i).ElementAt (4)+";"+List2array.ElementAt (i).ElementAt (6);
  278. m_List1array.ElementAt (pos).Add(str);
  279. str=List2array.ElementAt (i).ElementAt (2);
  280. m_List1array.ElementAt (pos).Add(str);
  281. income+=atof(str);
  282. m_List1array.ElementAt (pos).Add("其它收入");
  283. m_List1array.ElementAt (pos).Add("收入");
  284. m_List1array.ElementAt (pos).Add(List2array.ElementAt (i).ElementAt (3));
  285. pos++;
  286. }
  287. for( i=0; i<List3array.GetSize (); i++)
  288. {
  289. str=List3array.ElementAt (i).ElementAt (1)+";"+List3array.ElementAt (i).ElementAt (4);
  290. m_List1array.ElementAt (pos).Add(str);
  291. str=List3array.ElementAt (i).ElementAt (2);
  292. m_List1array.ElementAt (pos).Add(str);
  293. payout+=atof(str);
  294. m_List1array.ElementAt (pos).Add("固定费用");
  295. m_List1array.ElementAt (pos).Add("支出");
  296. m_List1array.ElementAt (pos).Add(List3array.ElementAt (i).ElementAt (3));
  297. pos++;
  298. }
  299. }
  300. else if(m_radio1==1)//收入
  301. {
  302. for( i=0; i<List11array.GetSize (); i++)
  303. {
  304. str=List11array.ElementAt (i).ElementAt (0);
  305. str+=";"+List11array.ElementAt (i).ElementAt (3);
  306. if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
  307. {
  308. str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
  309. if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
  310. str+=","+List11array.ElementAt (i).ElementAt (2);
  311. }
  312. else
  313. str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
  314. m_List1array.ElementAt (pos).Add(str);
  315. str=List11array.ElementAt (i).ElementAt (4);
  316. m_List1array.ElementAt (pos).Add(str);
  317. income+=atof(str);
  318. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
  319. m_List1array.ElementAt (pos).Add("收入");
  320. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
  321. if(List11array.ElementAt (i).ElementAt (5)=="预约收款")
  322. dindanshu++;
  323. pos++;
  324. }
  325. for( i=0; i<List2array.GetSize (); i++)
  326. {
  327. str=List2array.ElementAt (i).ElementAt (1)+";"+List2array.ElementAt (i).ElementAt (4)+";"+List2array.ElementAt (i).ElementAt (6);
  328. m_List1array.ElementAt (pos).Add(str);
  329. str=List2array.ElementAt (i).ElementAt (2);
  330. m_List1array.ElementAt (pos).Add(str);
  331. income+=atof(str);
  332. m_List1array.ElementAt (pos).Add("其它收入");
  333. m_List1array.ElementAt (pos).Add("收入");
  334. m_List1array.ElementAt (pos).Add(List2array.ElementAt (i).ElementAt (3));
  335. pos++;
  336. }
  337. }
  338. else if(m_radio1==2)//支出
  339. {
  340. for( i=0; i<List3array.GetSize (); i++)
  341. {
  342. str=List3array.ElementAt (i).ElementAt (1)+";"+List3array.ElementAt (i).ElementAt (4);
  343. m_List1array.ElementAt (pos).Add(str);
  344. str=List3array.ElementAt (i).ElementAt (2);
  345. m_List1array.ElementAt (pos).Add(str);
  346. payout+=atof(str);
  347. m_List1array.ElementAt (pos).Add("固定费用");
  348. m_List1array.ElementAt (pos).Add("支出");
  349. m_List1array.ElementAt (pos).Add(List3array.ElementAt (i).ElementAt (3));
  350. pos++;
  351. }
  352. }
  353. else if(m_radio1==3)//定单
  354. {
  355. for( i=0; i<List11array.GetSize (); i++)
  356. {
  357. if(List11array.ElementAt (i).ElementAt (5)!="预约收款")continue;
  358. dindanshu++;
  359. str=List11array.ElementAt (i).ElementAt (0);
  360. str+=";"+List11array.ElementAt (i).ElementAt (3);
  361. if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
  362. {
  363. str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
  364. if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
  365. str+=","+List11array.ElementAt (i).ElementAt (2);
  366. }
  367. else
  368. str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
  369. m_List1array.ElementAt (pos).Add(str);
  370. str=List11array.ElementAt (i).ElementAt (4);
  371. m_List1array.ElementAt (pos).Add(str);
  372. income+=atof(str);
  373. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
  374. m_List1array.ElementAt (pos).Add("收入");
  375. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
  376. pos++;
  377. }
  378. }
  379. else if(m_radio1==4)//拍照加挑
  380. {
  381. for( i=0; i<List11array.GetSize (); i++)
  382. {
  383. if(List11array.ElementAt (i).ElementAt (5)!="拍照补款")continue;
  384. str=List11array.ElementAt (i).ElementAt (0);
  385. str+=";"+List11array.ElementAt (i).ElementAt (3);
  386. if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
  387. {
  388. str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
  389. if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
  390. str+=","+List11array.ElementAt (i).ElementAt (2);
  391. }
  392. else
  393. str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
  394. m_List1array.ElementAt (pos).Add(str);
  395. str=List11array.ElementAt (i).ElementAt (4);
  396. m_List1array.ElementAt (pos).Add(str);
  397. income+=atof(str);
  398. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
  399. m_List1array.ElementAt (pos).Add("收入");
  400. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
  401. pos++;
  402. }
  403. }
  404. else if(m_radio1==5)//选片加挑
  405. {
  406. for( i=0; i<List11array.GetSize (); i++)
  407. {
  408. if(List11array.ElementAt (i).ElementAt (5)!="选片补款")continue;
  409. str=List11array.ElementAt (i).ElementAt (0);
  410. str+=";"+List11array.ElementAt (i).ElementAt (3);
  411. if(!List11array.ElementAt (i).ElementAt (1).IsEmpty ())
  412. {
  413. str+=";客户:"+List11array.ElementAt (i).ElementAt (1);
  414. if(!List11array.ElementAt (i).ElementAt (2).IsEmpty ())
  415. str+=","+List11array.ElementAt (i).ElementAt (2);
  416. }
  417. else
  418. str+=";客户:"+List11array.ElementAt (i).ElementAt (2);
  419. m_List1array.ElementAt (pos).Add(str);
  420. str=List11array.ElementAt (i).ElementAt (4);
  421. m_List1array.ElementAt (pos).Add(str);
  422. income+=atof(str);
  423. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (5));
  424. m_List1array.ElementAt (pos).Add("收入");
  425. m_List1array.ElementAt (pos).Add(List11array.ElementAt (i).ElementAt (7));
  426. pos++;
  427. }
  428. }
  429. m_List1array.SetSize(pos);
  430. str.Format ("%f", income);
  431. ::ConvertToPrice (str);
  432. SetDlgItemText(IDC_EDITmoney1, str);
  433. str.Format ("%f", payout);
  434. ::ConvertToPrice (str);
  435. SetDlgItemText(IDC_EDITmoney2, str);
  436. str.Format ("%f", income-payout);
  437. ::ConvertToPrice (str);
  438. SetDlgItemText(IDC_EDITmoney3, str);
  439. str.Format ("%d", dindanshu);
  440. SetDlgItemText(IDC_EDITmoney4, str);
  441. FillGrid();
  442. }
  443. void MonthForm::OnRadio3()
  444. {
  445. // TODO: Add your control notification handler code here
  446. UpdateData();
  447. KindChange();
  448. }
  449. void MonthForm::OnRadio4()
  450. {
  451. // TODO: Add your control notification handler code here
  452. UpdateData();
  453. KindChange();
  454. }
  455. void MonthForm::OnRadio5()
  456. {
  457. // TODO: Add your control notification handler code here
  458. UpdateData();
  459. KindChange();
  460. }
  461. void MonthForm::OnRadio6()
  462. {
  463. // TODO: Add your control notification handler code here
  464. UpdateData();
  465. KindChange();
  466. }
  467. void MonthForm::OnRadio7()
  468. {
  469. // TODO: Add your control notification handler code here
  470. UpdateData();
  471. KindChange();
  472. }
  473. void MonthForm::OnRadio8()
  474. {
  475. // TODO: Add your control notification handler code here
  476. UpdateData();
  477. KindChange();
  478. }