YearForm.cpp 15 KB

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