CostCal.cpp 16 KB

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