CostCal.cpp 16 KB

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