YearForm.cpp 15 KB

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