DailyForm.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. // DailyForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "DailyForm.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. // DailyForm
  14. IMPLEMENT_DYNCREATE(DailyForm, CFormView)
  15. DailyForm::DailyForm()
  16. : CFormView(DailyForm::IDD)
  17. {
  18. //{{AFX_DATA_INIT(DailyForm)
  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. DailyForm::~DailyForm()
  29. {
  30. }
  31. void DailyForm::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CFormView::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(DailyForm)
  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(DailyForm, CFormView)
  50. //{{AFX_MSG_MAP(DailyForm)
  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. // DailyForm diagnostics
  65. #ifdef _DEBUG
  66. void DailyForm::AssertValid() const
  67. {
  68. CFormView::AssertValid();
  69. }
  70. void DailyForm::Dump(CDumpContext& dc) const
  71. {
  72. CFormView::Dump(dc);
  73. }
  74. #endif //_DEBUG
  75. /////////////////////////////////////////////////////////////////////////////
  76. // DailyForm message handlers
  77. void DailyForm::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 DailyForm::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 DailyForm::OnBUTclose()
  117. {
  118. // TODO: Add your control notification handler code here
  119. GetParent()->SendMessage(WM_CLOSE);
  120. }
  121. void DailyForm::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 DailyForm::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 DailyForm::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 DailyForm::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, m_month, m_day);
  171. m_static1.SetWindowText (strdate+"日财务表");
  172. sql.Format ("dat='"+strdate+"';dat='"+strdate+"';date='"+strdate+"'");
  173. g_pMainWnd->ProcessChatMessageRequest2(sql);
  174. if(g_bSendOK==0)
  175. {
  176. g_nYearpos=g_nYearposTemp;
  177. return;
  178. }
  179. DataToArray(&List2array,&List3array,&List11array);
  180. if(bLastYear)//如果是去年, 则加今年的补款
  181. {
  182. g_nYearpos=-1;//今年
  183. g_sendhead.bsql=0;
  184. g_sendhead.code[0]=16;
  185. g_sendhead.tabcount=1;
  186. CString sql,strdate,strdate2;
  187. strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
  188. sql.Format ("date='"+strdate+"'");
  189. g_pMainWnd->ProcessChatMessageRequest2(sql);
  190. if(g_bSendOK==0)
  191. {
  192. g_nYearpos=g_nYearposTemp;
  193. return;
  194. }
  195. CArray<CStringArray, CStringArray>ThisYearList11array;
  196. DataToArray(&ThisYearList11array);
  197. int oldsize=List11array.GetSize ();
  198. int newsize=ThisYearList11array.GetSize ();
  199. List11array.SetSize(oldsize+ThisYearList11array.GetSize ());
  200. for(i=oldsize; i<oldsize+ThisYearList11array.GetSize (); i++)
  201. {
  202. List11array.ElementAt (i).Copy(ThisYearList11array.ElementAt (i-oldsize));
  203. }
  204. }
  205. else if(bThisYear)//如果是今年, 则加去年的补款
  206. {
  207. g_nYearpos=0;//去年
  208. g_sendhead.bsql=0;
  209. g_sendhead.code[0]=16;
  210. g_sendhead.tabcount=1;
  211. CString sql,strdate,strdate2;
  212. strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
  213. sql.Format ("date='"+strdate+"'");
  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 DailyForm::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 DailyForm::OnRadio3()
  438. {
  439. // TODO: Add your control notification handler code here
  440. UpdateData();
  441. KindChange();
  442. }
  443. void DailyForm::OnRadio4()
  444. {
  445. // TODO: Add your control notification handler code here
  446. UpdateData();
  447. KindChange();
  448. }
  449. void DailyForm::OnRadio5()
  450. {
  451. // TODO: Add your control notification handler code here
  452. UpdateData();
  453. KindChange();
  454. }
  455. void DailyForm::OnRadio6()
  456. {
  457. // TODO: Add your control notification handler code here
  458. UpdateData();
  459. KindChange();
  460. }
  461. void DailyForm::OnRadio7()
  462. {
  463. // TODO: Add your control notification handler code here
  464. UpdateData();
  465. KindChange();
  466. }
  467. void DailyForm::OnRadio8()
  468. {
  469. // TODO: Add your control notification handler code here
  470. UpdateData();
  471. KindChange();
  472. }