PhotoPrintFrom2.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. // PhotoPrintFrom2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "PhotoPrintFrom2.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. // PhotoPrintFrom2
  14. PhotoPrintFrom2::PhotoPrintFrom2(CWnd* pParent /*=NULL*/)
  15. : CDialog(PhotoPrintFrom2::IDD)
  16. {
  17. //{{AFX_DATA_INIT(PhotoPrintFrom2)
  18. m_year = atoi(g_date.Mid(0, 4));
  19. m_month = atoi(g_date.Mid(5, 2));
  20. m_day = atoi(g_date.Mid(8, 2));
  21. m_bInit = 0;
  22. m_timestmap = 0;
  23. m_radio1 = 0;
  24. //}}AFX_DATA_INIT
  25. }
  26. void PhotoPrintFrom2::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(PhotoPrintFrom2)
  30. DDX_Control(pDX, IDC_COMBObranch, m_combobranch);
  31. DDX_Control(pDX, IDC_COMBO6, m_combo1);
  32. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  33. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  34. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  35. DDX_Control(pDX, IDC_LIST2, m_List1);
  36. DDX_Control(pDX, IDC_STATIC1, m_static1);
  37. DDX_Text(pDX, IDC_EDITyear, m_year);
  38. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  39. DDX_Text(pDX, IDC_EDITmonth, m_month);
  40. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  41. DDX_Text(pDX, IDC_EDITday, m_day);
  42. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  43. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(PhotoPrintFrom2, CDialog)
  47. //{{AFX_MSG_MAP(PhotoPrintFrom2)
  48. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  49. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  50. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  51. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  52. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  53. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  54. ON_EN_CHANGE(IDC_EDITmoney2, OnChangeEDITmoney2)
  55. ON_WM_DESTROY()
  56. ON_CBN_SELCHANGE(IDC_COMBO6, OnSelchangeCombo6)
  57. ON_CBN_SELCHANGE(IDC_COMBObranch, OnSelchangeCOMBObranch)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // PhotoPrintFrom2 diagnostics
  62. #ifdef _DEBUG
  63. void PhotoPrintFrom2::AssertValid() const
  64. {
  65. CDialog::AssertValid();
  66. }
  67. void PhotoPrintFrom2::Dump(CDumpContext& dc) const
  68. {
  69. CDialog::Dump(dc);
  70. }
  71. #endif //_DEBUG
  72. /////////////////////////////////////////////////////////////////////////////
  73. // PhotoPrintFrom2 message handlers
  74. extern BOOL CALLBACK EnumChildProc2(HWND hwnd, LPARAM lParam);
  75. BOOL PhotoPrintFrom2::OnInitDialog()
  76. {
  77. CDialog::OnInitDialog();
  78. // TODO: Add your specialized code here and/or call the base class
  79. if (g_bAllBranch)
  80. {
  81. GetDlgItem(IDC_STATIC12)->ShowWindow(SW_SHOW);
  82. GetDlgItem(IDC_COMBObranch)->ShowWindow(SW_SHOW);
  83. // m_combobranch.AddString ("");
  84. for (int i = 0; i < g_brancharray.GetSize(); i++)
  85. {
  86. m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
  87. }
  88. }
  89. CRect rc2;
  90. GetWindowRect(rc2);
  91. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  92. g_WidthScale2 = (float)g_rc.Width() / (float)rc2.Width(); // new/Old
  93. g_HeightScale2 = (float)g_rc.Height() / (float)rc2.Height();
  94. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc2, 0);
  95. CString version = _T("Version 1.0");
  96. CString str = AfxGetApp()->GetProfileString(version, "printprice", "20");
  97. SetDlgItemText(IDC_EDITmoney2, str);
  98. m_static1.SetFont(&g_titlefont);
  99. #ifdef CHILD_VERSION
  100. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  101. #else
  102. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  103. #endif
  104. //m_List1.m_bSortSupport=0;
  105. m_List1.LoadColumnInfo(178);
  106. m_spinyear.SetRange(1900, 3000);
  107. m_spinmonth.SetRange(1, 12);
  108. m_spinday.SetRange(1, 31);
  109. g_sendhead.bsql = 0;
  110. g_sendhead.code[0] = 9;
  111. g_sendhead.tabcount = 1;
  112. CString sql;
  113. g_pMainWnd->ProcessChatMessageRequest2(1);
  114. if (g_bSendOK == 0)
  115. {
  116. CDialog::OnOK();
  117. return 0;
  118. }
  119. DataToArray(&g_List1array);
  120. if (m_combo1.GetCount() == 0)
  121. {
  122. m_combo1.ResetContent(); m_combo1.AddString("全部");
  123. for (int i = 0; i < g_List1array.GetSize(); i++)
  124. {
  125. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  126. }
  127. m_combo1.SetCurSel(0);
  128. }
  129. m_bInit = 1;
  130. DateChange();
  131. return TRUE; // return TRUE unless you set the focus to a control
  132. // EXCEPTION: OCX Property Pages should return FALSE
  133. }
  134. void PhotoPrintFrom2::FillGrid()
  135. {
  136. CString splb = "全部";
  137. int pos = m_combo1.GetCurSel();
  138. if (pos != -1)
  139. {
  140. m_combo1.GetLBText(pos, splb);
  141. }
  142. m_List1.DeleteAllItems2();
  143. int ii = 0;
  144. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  145. int count = 0;
  146. int sum1 = 0;
  147. float sum2 = 0;
  148. if (splb == "全部")
  149. {
  150. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  151. {
  152. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  153. sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
  154. sum2 += atoi(m_List1array.ElementAt(ii).ElementAt(4))*atof(m_List1array.ElementAt(ii).ElementAt(5));
  155. }
  156. }
  157. else
  158. {
  159. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  160. {
  161. if (m_List1array.ElementAt(ii).ElementAt(6).GetLength() < 4)continue;
  162. if (m_List1array.ElementAt(ii).ElementAt(6).Right(m_List1array.ElementAt(ii).ElementAt(6).GetLength() - 4) != splb)continue;
  163. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  164. sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
  165. sum2 += atoi(m_List1array.ElementAt(ii).ElementAt(4))*atof(m_List1array.ElementAt(ii).ElementAt(5));
  166. }
  167. }
  168. m_List1.m_arLabels.SetSize(count, 1);
  169. ii = count;
  170. m_List1.m_LabelCount = ii;
  171. m_List1.SetItemCountEx(ii);
  172. CString str;
  173. str.Format("单数:%d", ii);
  174. SetDlgItemText(IDC_STATIC2, str);
  175. str.Format("%d", sum1);
  176. SetDlgItemText(IDC_EDITmoney1, str);
  177. str.Format("%0.5f", sum2);
  178. SetDlgItemText(IDC_EDITmoney5, str);
  179. OnChangeEDITmoney2();
  180. }
  181. void PhotoPrintFrom2::OnBUTclose()
  182. {
  183. // TODO: Add your control notification handler code here
  184. CDialog::OnCancel();
  185. }
  186. void PhotoPrintFrom2::OnChangeEDITyear()
  187. {
  188. // TODO: If this is a RICHEDIT control, the control will not
  189. // send this notification unless you override the CDialog::OnInitDialog()
  190. // function and call CRichEditCtrl().SetEventMask()
  191. // with the ENM_CHANGE flag ORed into the mask.
  192. DateChange();
  193. // TODO: Add your control notification handler code here
  194. }
  195. void PhotoPrintFrom2::OnChangeEDITmonth()
  196. {
  197. // TODO: If this is a RICHEDIT control, the control will not
  198. // send this notification unless you override the CDialog::OnInitDialog()
  199. // function and call CRichEditCtrl().SetEventMask()
  200. // with the ENM_CHANGE flag ORed into the mask.
  201. DateChange();
  202. // TODO: Add your control notification handler code here
  203. }
  204. void PhotoPrintFrom2::OnChangeEDITday()
  205. {
  206. // TODO: If this is a RICHEDIT control, the control will not
  207. // send this notification unless you override the CDialog::OnInitDialog()
  208. // function and call CRichEditCtrl().SetEventMask()
  209. // with the ENM_CHANGE flag ORed into the mask.
  210. // DateChange();
  211. // TODO: Add your control notification handler code here
  212. }
  213. void PhotoPrintFrom2::DateChange()
  214. {
  215. if (m_bInit == 0)return;
  216. m_spinyear.EnableWindow(0);
  217. m_spinmonth.EnableWindow(0);
  218. m_spinday.EnableWindow(0);
  219. UpdateData();
  220. if (m_branch != "")
  221. {
  222. g_pMainWnd->OnDisconnect();
  223. g_branchip = GetIP(m_branch);
  224. g_pMainWnd->OnDisconnect();
  225. g_branchname = m_branch;
  226. g_bBranchModify = 1;
  227. }
  228. int i;
  229. int g_nYearposTemp = g_nYearpos;
  230. BOOL bLastYear = 0;
  231. BOOL bThisYear = 0;
  232. #if JEFF_TEST_ON // 2015开始禁用跨年数据;
  233. int g_nYearposPre = -1;
  234. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  235. {
  236. g_nYearpos = -1;
  237. bThisYear = 1;
  238. if (m_year == 2014)
  239. {
  240. g_nYearposPre = GetYearPos(m_year - 1);
  241. }
  242. }
  243. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  244. {
  245. g_nYearpos = GetYearPos(m_year);
  246. if (g_nYearpos != -1)
  247. g_nYearposPre = GetYearPos(m_year - 1);
  248. bLastYear = 1;
  249. }
  250. #else
  251. if (m_year == atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  252. bThisYear = 1;
  253. else if (m_year <= atoi(g_date.Left(4)) - 1 && g_hisyeararray.GetSize())
  254. bLastYear = 1;
  255. g_nYearpos = GetYearPos(m_year);
  256. int g_nYearposPre = GetYearPos(m_year - 1);
  257. #endif
  258. g_sendhead.bsql = 0;
  259. g_sendhead.code[0] = 147;
  260. g_sendhead.tabcount = 1;
  261. CString sql, strdate, strdate2;
  262. strdate.Format("%04d-%02d-%02d", m_year, m_month, 1);
  263. strdate2.Format("%04d-%02d-%02d", m_year, m_month, 31);
  264. m_static1.SetWindowText(strdate.Left(7) + "冲印资料");
  265. if (m_radio1 == 0)
  266. sql.Format("[time1]>='" + strdate + "' and [time1]<='" + strdate2 + "'");
  267. else
  268. sql.Format("[time2]>='" + strdate + "' and [time2]<='" + strdate2 + "'");
  269. g_pMainWnd->ProcessChatMessageRequest2(sql);
  270. if (g_bSendOK == 0)
  271. {
  272. m_spinyear.EnableWindow(1);
  273. m_spinmonth.EnableWindow(1);
  274. m_spinday.EnableWindow(1);
  275. g_nYearpos = g_nYearposTemp;
  276. return;
  277. }
  278. DataToArray(&m_List1array);
  279. if (bLastYear)//如果是去年, 则加今年的补款
  280. {
  281. g_nYearpos = -1;//今年
  282. g_sendhead.bsql = 0;
  283. g_sendhead.code[0] = 147;
  284. g_sendhead.tabcount = 1;
  285. g_pMainWnd->ProcessChatMessageRequest2(sql);
  286. if (g_bSendOK == 0)
  287. {
  288. m_spinyear.EnableWindow(1);
  289. m_spinmonth.EnableWindow(1);
  290. m_spinday.EnableWindow(1);
  291. g_nYearpos = g_nYearposTemp;
  292. return;
  293. }
  294. CArray<CStringArray, CStringArray>ThisYearList1array;
  295. DataToArray(&ThisYearList1array);
  296. int oldsize = m_List1array.GetSize();
  297. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  298. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  299. {
  300. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  301. }
  302. }
  303. if (g_nYearposPre != -1)//如果是今年, 则加去年的补款
  304. {
  305. g_nYearpos = g_nYearposPre;//去年
  306. g_sendhead.bsql = 0;
  307. g_sendhead.code[0] = 147;
  308. g_sendhead.tabcount = 1;
  309. g_pMainWnd->ProcessChatMessageRequest2(sql);
  310. if (g_bSendOK == 0)
  311. {
  312. m_spinyear.EnableWindow(1);
  313. m_spinmonth.EnableWindow(1);
  314. m_spinday.EnableWindow(1);
  315. g_nYearpos = g_nYearposTemp;
  316. return;
  317. }
  318. CArray<CStringArray, CStringArray>ThisYearList1array;
  319. DataToArray(&ThisYearList1array);
  320. int oldsize = m_List1array.GetSize();
  321. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  322. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  323. {
  324. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  325. }
  326. }
  327. g_nYearpos = g_nYearposTemp;
  328. FillGrid();
  329. m_spinyear.EnableWindow(1);
  330. m_spinmonth.EnableWindow(1);
  331. m_spinday.EnableWindow(1);
  332. }
  333. void PhotoPrintFrom2::OnRadio3()
  334. {
  335. // TODO: Add your control notification handler code here
  336. UpdateData();
  337. DateChange();
  338. }
  339. void PhotoPrintFrom2::OnRadio4()
  340. {
  341. // TODO: Add your control notification handler code here
  342. UpdateData();
  343. DateChange();
  344. }
  345. void PhotoPrintFrom2::OnChangeEDITmoney2()
  346. {
  347. // TODO: If this is a RICHEDIT control, the control will not
  348. // send this notification unless you override the CDialog::OnInitDialog()
  349. // function and call CRichEditCtrl().SetEventMask()
  350. // with the ENM_CHANGE flag ORed into the mask.
  351. if (m_bInit == 0)return;
  352. CString str, str2;
  353. GetDlgItem(IDC_EDITmoney5)->GetWindowText(str);
  354. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str2);
  355. str.Format("%0.5f", atof(str)*atof(str2));
  356. SetDlgItemText(IDC_EDITmoney3, str);
  357. // TODO: Add your control notification handler code here
  358. }
  359. void PhotoPrintFrom2::OnDestroy()
  360. {
  361. // TODO: Add your message handler code here
  362. CString str;
  363. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str);
  364. CString version = _T("Version 1.0");
  365. AfxGetApp()->WriteProfileString(version, "printprice", str);
  366. if (g_bAllBranch)
  367. {
  368. g_pMainWnd->OnDisconnect();
  369. g_bBranchModify = 0; g_branchip = g_branchname = "";
  370. }
  371. CDialog::OnDestroy();
  372. }
  373. void PhotoPrintFrom2::OnSelchangeCombo6()
  374. {
  375. // TODO: Add your control notification handler code here
  376. FillGrid();
  377. }
  378. void PhotoPrintFrom2::OnSelchangeCOMBObranch()
  379. {
  380. // TODO: Add your control notification handler code here
  381. int pos = m_combobranch.GetCurSel();
  382. if (pos == -1)return;
  383. m_combobranch.GetLBText(pos, m_branch);
  384. DateChange();
  385. m_combo1.ResetContent();
  386. g_sendhead.bsql = 0;
  387. g_sendhead.code[0] = 9;
  388. g_sendhead.tabcount = 1;
  389. CString sql;
  390. g_pMainWnd->ProcessChatMessageRequest2(1);
  391. if (g_bSendOK == 0)
  392. {
  393. return;
  394. }
  395. DataToArray(&g_List1array);
  396. if (m_combo1.GetCount() == 0)
  397. {
  398. m_combo1.ResetContent(); m_combo1.AddString("全部");
  399. for (int i = 0; i < g_List1array.GetSize(); i++)
  400. {
  401. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  402. }
  403. m_combo1.SetCurSel(0);
  404. }
  405. }