CostCal.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. // CostCal.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "CostCal.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #include "ImportPhoto.h"
  10. #include "ImportPhoto.h"
  11. #include "outsourcingDlg.h"
  12. #include "outsourcingDlg2.h"
  13. #include "outsourcing2.h"
  14. #include "outsourcing3.h"
  15. #include "outsourcing4.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. #pragma comment(lib, "Shlwapi.lib")
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CostCal
  24. IMPLEMENT_DYNCREATE(CostCal, MyFormView)
  25. CostCal::CostCal()
  26. : MyFormView(CostCal::IDD)
  27. {
  28. //{{AFX_DATA_INIT(CostCal)
  29. m_filter = _T("");
  30. m_date2 = GetTmFromStr(g_date);
  31. m_date1 = m_date2-CTimeSpan(30, 0, 0, 0);
  32. //}}AFX_DATA_INIT
  33. } //m_date1 = m_date2-CTimeSpan(30, 0, 0, 0);
  34. CostCal::~CostCal()
  35. {
  36. }
  37. void CostCal::DoDataExchange(CDataExchange* pDX)
  38. {
  39. MyFormView::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CostCal)
  41. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  42. DDX_Control(pDX, IDC_LIST2, m_List1);
  43. DDX_Control(pDX, IDC_STATIC1, m_static1);
  44. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  45. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_date1);
  46. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_date2);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CostCal, MyFormView)
  50. //{{AFX_MSG_MAP(CostCal)
  51. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  52. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  53. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  54. ON_WM_TIMER()
  55. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  56. ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnDatetimechangeDatetimepicker1)
  57. ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER2, OnDatetimechangeDatetimepicker2)
  58. //}}AFX_MSG_MAP
  59. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CostCal diagnostics
  63. #ifdef _DEBUG
  64. void CostCal::AssertValid() const
  65. {
  66. MyFormView::AssertValid();
  67. }
  68. void CostCal::Dump(CDumpContext& dc) const
  69. {
  70. MyFormView::Dump(dc);
  71. }
  72. #endif //_DEBUG
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CostCal message handlers
  75. void CostCal::OnInitialUpdate()
  76. {
  77. MyFormView::OnInitialUpdate();
  78. // TODO: Add your specialized code here and/or call the base class
  79. CMyMdi Mdi;
  80. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  81. // Here we create the outbar control using the splitter as its parent
  82. // and setting its id to the first pane.
  83. CRect rc2;
  84. GetWindowRect(rc2);
  85. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  86. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  87. m_static1.SetFont (&g_titlefont);
  88. #ifdef CHILD_VERSION
  89. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;接单人,100;售价,100;成本,100;商品名称,100;单价,100;数量,100" );
  90. #else
  91. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;接单人,100;售价,100;成本,100;商品名称,100;单价,100;数量,100" );
  92. #endif
  93. m_List1.LoadColumnInfo (321);
  94. m_List1.m_bSortSupport=0;
  95. GetData(); // 与服务器通信,获取信息;
  96. for(int i=0; i<g_userarray.GetSize (); i++)
  97. {
  98. m_combo1.AddString (g_userarray.ElementAt (i).ElementAt (1) );
  99. }
  100. m_combo1.GetWindowRect (rc2);
  101. ScreenToClient(rc2);
  102. rc2.bottom +=200;
  103. m_combo1.MoveWindow (rc2);
  104. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  105. SetComboHei(&m_combo1, rc2.Height ());
  106. }
  107. void CostCal::FillGrid()
  108. {
  109. m_List1.DeleteAllItems2 ();
  110. int ii=0;
  111. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  112. int count=0;
  113. if(m_filter.IsEmpty ())
  114. {
  115. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  116. {
  117. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  118. }
  119. }
  120. else
  121. {
  122. BOOL bFinded=0;
  123. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  124. {
  125. if(bFinded && m_List1array.ElementAt (ii).ElementAt (0).IsEmpty ())
  126. {
  127. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  128. continue;
  129. }
  130. if(m_List1array.ElementAt (ii).ElementAt (3)==m_filter )
  131. {
  132. bFinded=1;
  133. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  134. }
  135. else
  136. {
  137. bFinded=0;
  138. }
  139. }
  140. }
  141. m_List1.m_arLabels.SetSize(count, 1);
  142. ii=count;
  143. m_List1.m_LabelCount=ii;
  144. m_List1.SetItemCountEx (ii);
  145. double fsumcost=0;
  146. double fsumsale=0;
  147. float fcost=0;
  148. float fprice=0;
  149. int cot=0;
  150. CString scost;
  151. for(int i=m_List1.m_arLabels.GetSize ()-1; i>=0; i--)
  152. {
  153. fprice=GetSPPriceFromName(m_List1.m_arLabels.ElementAt (i).ElementAt (6));
  154. fcost+=atof(m_List1.m_arLabels.ElementAt (i).ElementAt (8))*fprice;
  155. scost.Format ("%0.2f", fprice);
  156. if(m_List1.m_arLabels.ElementAt (i).ElementAt (0)!="")
  157. {
  158. fsumcost+=fcost;
  159. fsumsale+=atof(m_List1.m_arLabels.ElementAt (i).ElementAt (4));
  160. scost.Format ("%0.2f", fcost);fcost=0;
  161. cot++;
  162. }
  163. }
  164. scost.Format ("%d", (int)fsumsale);
  165. SetDlgItemText(IDC_EDITmoney2, scost);
  166. scost.Format ("%d", (int)fsumcost);
  167. SetDlgItemText(IDC_EDITmoney3, scost);
  168. scost.Format ("%d", (int)(fsumsale-fsumcost));
  169. SetDlgItemText(IDC_EDITmoney4, scost);
  170. scost.Format ("%d", (int)(fsumsale/cot));
  171. SetDlgItemText(IDC_EDITmoney5, scost);
  172. scost.Format ("%d", (int)(fsumcost/cot));
  173. SetDlgItemText(IDC_EDITmoney6, scost);
  174. scost.Format ("%d", (int)((fsumsale-fsumcost)/cot));
  175. SetDlgItemText(IDC_EDITmoney7, scost);
  176. scost.Format ("%d", cot);
  177. SetDlgItemText(IDC_EDIT1, scost);
  178. ///////////////////////////////////////////////
  179. CString srate;
  180. if(fsumsale>0.1)
  181. {
  182. srate.Format("%0.1f", 100.0*(fsumsale-fsumcost)/fsumsale);
  183. srate+="%";
  184. }
  185. else
  186. srate="100%";
  187. scost.Format ("单数:%d 总售价:%d 总成本:%d 毛利:%d 毛利率:%s 平均售价:%d 平均成本:%d 平均毛利:%d",
  188. cot, (int)fsumsale, (int)fsumcost, (int)(fsumsale-fsumcost), srate,(int)(fsumsale/cot), (int)(fsumcost/cot), (int)((fsumsale-fsumcost)/cot));
  189. SetDlgItemText(IDC_EDIT1, scost);
  190. if(!g_id.IsEmpty ())
  191. {
  192. for(int i=0; i<m_List1.GetItemCount (); i++)
  193. {
  194. if(g_id==m_List1.GetItemText (i, 0))
  195. {
  196. m_List1.SetItemState(i,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
  197. m_List1.EnsureVisible(i,FALSE);
  198. break;
  199. }
  200. }
  201. }
  202. }
  203. void CostCal::OnBUTclose()
  204. {
  205. // TODO: Add your control notification handler code here
  206. GetParent()->SendMessage(WM_CLOSE);
  207. }
  208. void CostCal::OnButton1()
  209. {
  210. // TODO: Add your control notification handler code here
  211. UpdateData();
  212. m_filter.TrimLeft ();
  213. m_filter.TrimRight ();
  214. FillGrid();
  215. }
  216. void CostCal::OnSelchangeCombo1()
  217. {
  218. // TODO: Add your control notification handler code here
  219. SetTimer(1, 100, NULL);
  220. }
  221. void CostCal::OnTimer(UINT nIDEvent)
  222. {
  223. // TODO: Add your message handler code here and/or call default
  224. KillTimer(nIDEvent);
  225. OnButton1();
  226. }
  227. BOOL CostCal::PreTranslateMessage(MSG* pMsg)
  228. {
  229. // TODO: Add your specialized code here and/or call the base class
  230. try
  231. {
  232. if(pMsg->message==WM_KEYDOWN)
  233. {
  234. switch (pMsg->wParam)
  235. {
  236. case VK_RETURN:
  237. OnButton1();
  238. return 1;
  239. case 0x43: // copy
  240. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  241. {
  242. GetFocus()->SendMessage(WM_COPY);
  243. return TRUE;
  244. }
  245. break;
  246. case 0x56: //Ctrl + V:
  247. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  248. {
  249. GetFocus()->SendMessage(WM_PASTE);
  250. return TRUE;
  251. }
  252. break;
  253. case 0x58: // cut
  254. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  255. {
  256. GetFocus()->SendMessage(WM_CUT);
  257. return TRUE;
  258. }
  259. break;
  260. case 0x5A: //undo
  261. case 0x59: //redo
  262. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  263. {
  264. GetFocus()->SendMessage(WM_UNDO);
  265. return TRUE;
  266. }
  267. break;
  268. }
  269. }
  270. return MyFormView::PreTranslateMessage(pMsg);
  271. }
  272. catch(...)
  273. {
  274. }
  275. }
  276. void CostCal::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  277. {
  278. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  279. // Take the default processing unless we set this to something else below.
  280. *pResult = 0;
  281. // First thing - check the draw stage. If it's the control's prepaint
  282. // stage, then tell Windows we want messages for every item.
  283. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  284. {
  285. *pResult = CDRF_NOTIFYITEMDRAW;
  286. }
  287. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  288. {
  289. // This is the prepaint stage for an item. Here's where we set the
  290. // item's text color. Our return value will tell Windows to draw the
  291. // item itself, but it will use the new color we set here.
  292. // We'll cycle the colors through red, green, and light blue.
  293. COLORREF crText;
  294. int pos=pLVCD->nmcd.dwItemSpec;
  295. if(pos%2)
  296. pLVCD->clrTextBk = g_gridcol1;
  297. else
  298. pLVCD->clrTextBk = g_gridcol2;
  299. while(m_List1.m_arLabels.ElementAt (pos).ElementAt (0).IsEmpty ())
  300. {
  301. pos--;
  302. if(pos<1)break;
  303. }
  304. if(atof(m_List1.m_arLabels.ElementAt (pos).ElementAt (5))>atof(m_List1.m_arLabels.ElementAt (pos).ElementAt (4)))
  305. crText = RGB(220,0,0);
  306. else
  307. crText = RGB(20,133,20);
  308. // Store the color back in the NMLVCUSTOMDRAW struct.
  309. pLVCD->clrText = crText;
  310. // Tell Windows to paint the control itself.
  311. *pResult = CDRF_DODEFAULT;
  312. }
  313. }
  314. void CostCal::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  315. {
  316. // TODO: Add your control notification handler code here
  317. POSITION pos;
  318. pos=m_List1.GetFirstSelectedItemPosition();
  319. if(pos==NULL)
  320. {
  321. return;
  322. }
  323. int iItem=m_List1.GetNextSelectedItem(pos);
  324. g_id=m_List1.GetItemText (iItem, 0);
  325. while(g_id=="")
  326. {
  327. iItem--;
  328. g_id=m_List1.GetItemText (iItem, 0);
  329. }
  330. *pResult = 0;
  331. }
  332. void CostCal::GetData()
  333. {
  334. UpdateData();
  335. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(0);
  336. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(0);
  337. CString date1,date2;
  338. date1=m_date1.Format("%Y-%m-%d");
  339. date2=m_date2.Format("%Y-%m-%d");
  340. int g_nYearposTemp=g_nYearpos;
  341. int g_nYearposPre=-1;
  342. BOOL bNeedThisYear=0;
  343. if(g_nYearpos==-1 && g_hisyeararray.GetSize ())
  344. g_nYearposPre=0;
  345. if(g_nYearpos!=-1)
  346. bNeedThisYear=1;
  347. if(m_sparray.GetSize ()==0)
  348. {
  349. g_sendhead.bsql=0;
  350. g_sendhead.code[0]=224;
  351. g_sendhead.code[1]=4;
  352. g_sendhead.tabcount=2;
  353. CString filter="time1>='"+date1+"' and time1<='"+date2+"';";
  354. g_pMainWnd->ProcessChatMessageRequest2(filter);
  355. if(g_bSendOK==0)
  356. {
  357. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  358. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  359. g_nYearpos=g_nYearposTemp;
  360. return;
  361. }
  362. DataToArray(&m_List1array,&m_sparray);
  363. }
  364. else
  365. {
  366. g_sendhead.bsql=0;
  367. g_sendhead.code[0]=224;
  368. g_sendhead.tabcount=1;
  369. CString filter="time1>='"+date1+"' and time1<='"+date2+"'";
  370. g_pMainWnd->ProcessChatMessageRequest2(filter);
  371. if(g_bSendOK==0)
  372. {
  373. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  374. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  375. g_nYearpos=g_nYearposTemp;
  376. return;
  377. }
  378. DataToArray(&m_List1array);
  379. }
  380. if(bNeedThisYear)//加今年
  381. {
  382. g_nYearpos=-1;//今年
  383. CArray<CStringArray, CStringArray>ThisYearList1array;
  384. if(m_sparray.GetSize ()==0)
  385. {
  386. g_sendhead.bsql=0;
  387. g_sendhead.code[0]=224;
  388. g_sendhead.code[1]=4;
  389. g_sendhead.tabcount=2;
  390. CString filter="time1>='"+date1+"' and time1<='"+date2+"';";
  391. g_pMainWnd->ProcessChatMessageRequest2(filter);
  392. if(g_bSendOK==0)
  393. {
  394. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  395. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  396. g_nYearpos=g_nYearposTemp;
  397. return;
  398. }
  399. DataToArray(&ThisYearList1array,&m_sparray);
  400. }
  401. else
  402. {
  403. g_sendhead.bsql=0;
  404. g_sendhead.code[0]=224;
  405. g_sendhead.tabcount=1;
  406. CString filter="time1>='"+date1+"' and time1<='"+date2+"'";
  407. g_pMainWnd->ProcessChatMessageRequest2(filter);
  408. if(g_bSendOK==0)
  409. {
  410. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  411. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  412. g_nYearpos=g_nYearposTemp;
  413. return;
  414. }
  415. DataToArray(&ThisYearList1array);
  416. }
  417. int oldsize=m_List1array.GetSize ();
  418. m_List1array.SetSize(oldsize+ThisYearList1array.GetSize ());
  419. for(int i=oldsize; i<oldsize+ThisYearList1array.GetSize (); i++)
  420. {
  421. m_List1array.ElementAt (i).Copy(ThisYearList1array.ElementAt (i-oldsize));
  422. }
  423. }
  424. if(g_nYearposPre!=-1)//加去年
  425. {
  426. g_nYearpos=g_nYearposPre;
  427. CArray<CStringArray, CStringArray>ThisYearList1array;
  428. g_sendhead.bsql=0;
  429. g_sendhead.code[0]=224;
  430. g_sendhead.tabcount=1;
  431. CString filter="time1>='"+date1+"' and time1<='"+date2+"'";
  432. g_pMainWnd->ProcessChatMessageRequest2(filter);
  433. if(g_bSendOK==0)
  434. {
  435. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  436. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  437. g_nYearpos=g_nYearposTemp;
  438. return;
  439. }
  440. DataToArray(&ThisYearList1array);
  441. int oldsize=m_List1array.GetSize ();
  442. m_List1array.SetSize(oldsize+ThisYearList1array.GetSize ());
  443. for(int i=oldsize; i<oldsize+ThisYearList1array.GetSize (); i++)
  444. {
  445. m_List1array.ElementAt (i).Copy(ThisYearList1array.ElementAt (i-oldsize));
  446. }
  447. }
  448. g_nYearpos=g_nYearposTemp;
  449. // double fsumcost=0;
  450. // double fsumsale=0;
  451. float fcost=0;
  452. float fprice=0;
  453. // int cot=0;
  454. CString scost,name;
  455. for(int i=m_List1array.GetSize ()-1; i>=0; i--)
  456. {
  457. name=m_List1array.ElementAt (i).ElementAt (6);
  458. // name.MakeLower ();
  459. if(name.GetLength ()>2)
  460. {
  461. if(name.Right (2)=="x2"||name.Right (2)=="x3"||name.Right (2)=="x4"||name.Right (2)=="x5"||name.Right (2)=="x6"||name.Right (2)=="x7"||name.Right (2)=="x8"||name.Right (2)=="x9")
  462. {
  463. scost=name.Right (2);
  464. scost.Delete (0);
  465. name=name.Left (name.GetLength ()-2);
  466. // m_List1array.ElementAt (i).SetAt (6, name);
  467. m_List1array.ElementAt (i).SetAt (8, scost);
  468. }
  469. if(name.Right (2)=="X2"||name.Right (2)=="X3"||name.Right (2)=="X4"||name.Right (2)=="X5"||name.Right (2)=="X6"||name.Right (2)=="X7"||name.Right (2)=="X8"||name.Right (2)=="X9")
  470. {
  471. scost=name.Right (2);
  472. scost.Delete (0);
  473. name=name.Left (name.GetLength ()-2);
  474. // m_List1array.ElementAt (i).SetAt (6, name);
  475. m_List1array.ElementAt (i).SetAt (8, scost);
  476. }
  477. if(name.Right (3)=="X10")
  478. {
  479. scost=name.Right (3);
  480. scost.Delete (0);
  481. name=name.Left (name.GetLength ()-3);
  482. // m_List1array.ElementAt (i).SetAt (6, name);
  483. m_List1array.ElementAt (i).SetAt (8, scost);
  484. }
  485. if(name.Right (3)=="x10")
  486. {
  487. scost=name.Right (3);
  488. scost.Delete (0);
  489. name=name.Left (name.GetLength ()-3);
  490. // m_List1array.ElementAt (i).SetAt (6, name);
  491. m_List1array.ElementAt (i).SetAt (8, scost);
  492. }
  493. }
  494. fprice=GetSPPriceFromName(name);
  495. fcost+=atof(m_List1array.ElementAt (i).ElementAt (8))*fprice;
  496. scost.Format ("%0.2f", fprice);
  497. m_List1array.ElementAt (i).SetAt (7, scost);
  498. if(m_List1array.ElementAt (i).ElementAt (0)!="")
  499. {
  500. // fsumcost+=fcost;
  501. // fsumsale+=atof(m_List1array.ElementAt (i).ElementAt (4));
  502. scost.Format ("%0.2f", fcost);fcost=0;
  503. m_List1array.ElementAt (i).SetAt (5, scost);
  504. // cot++;
  505. }
  506. }
  507. /* scost.Format ("%d", (int)fsumsale);
  508. SetDlgItemText(IDC_EDITmoney2, scost);
  509. scost.Format ("%d", (int)fsumcost);
  510. SetDlgItemText(IDC_EDITmoney3, scost);
  511. scost.Format ("%d", (int)(fsumsale-fsumcost));
  512. SetDlgItemText(IDC_EDITmoney4, scost);
  513. scost.Format ("%d", (int)(fsumsale/cot));
  514. SetDlgItemText(IDC_EDITmoney5, scost);
  515. scost.Format ("%d", (int)(fsumcost/cot));
  516. SetDlgItemText(IDC_EDITmoney6, scost);
  517. scost.Format ("%d", (int)((fsumsale-fsumcost)/cot));
  518. SetDlgItemText(IDC_EDITmoney7, scost);
  519. scost.Format ("%d", cot);
  520. SetDlgItemText(IDC_EDIT1, scost);*/
  521. FillGrid();
  522. GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1);
  523. GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1);
  524. }
  525. float CostCal::GetSPPriceFromName(CString name)
  526. {
  527. int pos=name.Find (",");
  528. if(pos!=-1)
  529. {
  530. float fret=0.0;
  531. while(pos!=-1)
  532. {
  533. fret+=GetSPPriceFromName(name.Left (pos));
  534. name=name.Right (name.GetLength ()-pos-1);
  535. pos=name.Find (",");
  536. }
  537. fret+=GetSPPriceFromName(name);
  538. return fret;
  539. }
  540. for(int i=0; i<m_sparray.GetSize (); i++)
  541. {
  542. if(name==m_sparray.ElementAt (i).ElementAt (1))
  543. return atof(m_sparray.ElementAt (i).ElementAt (3));
  544. }
  545. return 0;
  546. }
  547. void CostCal::OnDatetimechangeDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
  548. {
  549. // TODO: Add your control notification handler code here
  550. GetData();
  551. *pResult = 0;
  552. }
  553. void CostCal::OnDatetimechangeDatetimepicker2(NMHDR* pNMHDR, LRESULT* pResult)
  554. {
  555. // TODO: Add your control notification handler code here
  556. GetData();
  557. *pResult = 0;
  558. }