PhotoPrintFrom2.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 str = AfxGetApp()->GetProfileString(LYFZVERSION, "printprice", "20");
  96. SetDlgItemText(IDC_EDITmoney2, str);
  97. m_static1.SetFont(&g_titlefont);
  98. #ifdef CHILD_VERSION
  99. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  100. #else
  101. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  102. #endif
  103. //m_List1.m_bSortSupport=0;
  104. m_List1.LoadColumnInfo(178);
  105. m_spinyear.SetRange(1900, 3000);
  106. m_spinmonth.SetRange(1, 12);
  107. m_spinday.SetRange(1, 31);
  108. g_sendhead.bsql = 0;
  109. g_sendhead.code[0] = 9;
  110. g_sendhead.tabcount = 1;
  111. CString sql;
  112. g_pMainWnd->ProcessChatMessageRequest2(1);
  113. if (g_bSendOK == 0)
  114. {
  115. CDialog::OnOK();
  116. return 0;
  117. }
  118. DataToArray(&g_List1array);
  119. if (m_combo1.GetCount() == 0)
  120. {
  121. m_combo1.ResetContent(); m_combo1.AddString("全部");
  122. for (int i = 0; i < g_List1array.GetSize(); i++)
  123. {
  124. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  125. }
  126. m_combo1.SetCurSel(0);
  127. }
  128. m_bInit = 1;
  129. DateChange();
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. // EXCEPTION: OCX Property Pages should return FALSE
  132. }
  133. void PhotoPrintFrom2::FillGrid()
  134. {
  135. CString splb = "全部";
  136. int pos = m_combo1.GetCurSel();
  137. if (pos != -1)
  138. {
  139. m_combo1.GetLBText(pos, splb);
  140. }
  141. m_List1.DeleteAllItems2();
  142. int ii = 0;
  143. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  144. int count = 0;
  145. int sum1 = 0;
  146. float sum2 = 0;
  147. if (splb == "全部")
  148. {
  149. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  150. {
  151. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  152. sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
  153. sum2 += atoi(m_List1array.ElementAt(ii).ElementAt(4))*atof(m_List1array.ElementAt(ii).ElementAt(5));
  154. }
  155. }
  156. else
  157. {
  158. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  159. {
  160. if (m_List1array.ElementAt(ii).ElementAt(6).GetLength() < 4)continue;
  161. if (m_List1array.ElementAt(ii).ElementAt(6).Right(m_List1array.ElementAt(ii).ElementAt(6).GetLength() - 4) != splb)continue;
  162. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  163. sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
  164. sum2 += atoi(m_List1array.ElementAt(ii).ElementAt(4))*atof(m_List1array.ElementAt(ii).ElementAt(5));
  165. }
  166. }
  167. m_List1.m_arLabels.SetSize(count, 1);
  168. ii = count;
  169. m_List1.m_LabelCount = ii;
  170. m_List1.SetItemCountEx(ii);
  171. CString str;
  172. str.Format("单数:%d", ii);
  173. SetDlgItemText(IDC_STATIC2, str);
  174. str.Format("%d", sum1);
  175. SetDlgItemText(IDC_EDITmoney1, str);
  176. str.Format("%0.5f", sum2);
  177. SetDlgItemText(IDC_EDITmoney5, str);
  178. OnChangeEDITmoney2();
  179. }
  180. void PhotoPrintFrom2::OnBUTclose()
  181. {
  182. // TODO: Add your control notification handler code here
  183. CDialog::OnCancel();
  184. }
  185. void PhotoPrintFrom2::OnChangeEDITyear()
  186. {
  187. // TODO: If this is a RICHEDIT control, the control will not
  188. // send this notification unless you override the CDialog::OnInitDialog()
  189. // function and call CRichEditCtrl().SetEventMask()
  190. // with the ENM_CHANGE flag ORed into the mask.
  191. DateChange();
  192. // TODO: Add your control notification handler code here
  193. }
  194. void PhotoPrintFrom2::OnChangeEDITmonth()
  195. {
  196. // TODO: If this is a RICHEDIT control, the control will not
  197. // send this notification unless you override the CDialog::OnInitDialog()
  198. // function and call CRichEditCtrl().SetEventMask()
  199. // with the ENM_CHANGE flag ORed into the mask.
  200. DateChange();
  201. // TODO: Add your control notification handler code here
  202. }
  203. void PhotoPrintFrom2::OnChangeEDITday()
  204. {
  205. // TODO: If this is a RICHEDIT control, the control will not
  206. // send this notification unless you override the CDialog::OnInitDialog()
  207. // function and call CRichEditCtrl().SetEventMask()
  208. // with the ENM_CHANGE flag ORed into the mask.
  209. // DateChange();
  210. // TODO: Add your control notification handler code here
  211. }
  212. void PhotoPrintFrom2::DateChange()
  213. {
  214. if (m_bInit == 0)return;
  215. m_spinyear.EnableWindow(0);
  216. m_spinmonth.EnableWindow(0);
  217. m_spinday.EnableWindow(0);
  218. UpdateData();
  219. if (m_branch != "")
  220. {
  221. g_pMainWnd->OnDisconnect();
  222. g_branchip = GetIP(m_branch);
  223. g_pMainWnd->OnDisconnect();
  224. g_branchname = m_branch;
  225. g_bBranchModify = 1;
  226. }
  227. int i;
  228. int g_nYearposTemp = g_nYearpos;
  229. BOOL bLastYear = 0;
  230. BOOL bThisYear = 0;
  231. #if JEFF_TEST_ON // 2015开始禁用跨年数据;
  232. int g_nYearposPre = -1;
  233. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  234. {
  235. g_nYearpos = -1;
  236. bThisYear = 1;
  237. if (m_year == 2014)
  238. {
  239. g_nYearposPre = GetYearPos(m_year - 1);
  240. }
  241. }
  242. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  243. {
  244. g_nYearpos = GetYearPos(m_year);
  245. if (g_nYearpos != -1)
  246. g_nYearposPre = GetYearPos(m_year - 1);
  247. bLastYear = 1;
  248. }
  249. #else
  250. if (m_year == atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  251. bThisYear = 1;
  252. else if (m_year <= atoi(g_date.Left(4)) - 1 && g_hisyeararray.GetSize())
  253. bLastYear = 1;
  254. g_nYearpos = GetYearPos(m_year);
  255. int g_nYearposPre = GetYearPos(m_year - 1);
  256. #endif
  257. g_sendhead.bsql = 0;
  258. g_sendhead.code[0] = 147;
  259. g_sendhead.tabcount = 1;
  260. CString sql, strdate, strdate2;
  261. strdate.Format("%04d-%02d-%02d", m_year, m_month, 1);
  262. strdate2.Format("%04d-%02d-%02d", m_year, m_month, 31);
  263. m_static1.SetWindowText(strdate.Left(7) + "冲印资料");
  264. if (m_radio1 == 0)
  265. sql.Format("[time1]>='" + strdate + "' and [time1]<='" + strdate2 + "'");
  266. else
  267. sql.Format("[time2]>='" + strdate + "' and [time2]<='" + strdate2 + "'");
  268. g_pMainWnd->ProcessChatMessageRequest2(sql);
  269. if (g_bSendOK == 0)
  270. {
  271. m_spinyear.EnableWindow(1);
  272. m_spinmonth.EnableWindow(1);
  273. m_spinday.EnableWindow(1);
  274. g_nYearpos = g_nYearposTemp;
  275. return;
  276. }
  277. DataToArray(&m_List1array);
  278. if (bLastYear)//如果是去年, 则加今年的补款
  279. {
  280. g_nYearpos = -1;//今年
  281. g_sendhead.bsql = 0;
  282. g_sendhead.code[0] = 147;
  283. g_sendhead.tabcount = 1;
  284. g_pMainWnd->ProcessChatMessageRequest2(sql);
  285. if (g_bSendOK == 0)
  286. {
  287. m_spinyear.EnableWindow(1);
  288. m_spinmonth.EnableWindow(1);
  289. m_spinday.EnableWindow(1);
  290. g_nYearpos = g_nYearposTemp;
  291. return;
  292. }
  293. CArray<CStringArray, CStringArray>ThisYearList1array;
  294. DataToArray(&ThisYearList1array);
  295. int oldsize = m_List1array.GetSize();
  296. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  297. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  298. {
  299. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  300. }
  301. }
  302. if (g_nYearposPre != -1)//如果是今年, 则加去年的补款
  303. {
  304. g_nYearpos = g_nYearposPre;//去年
  305. g_sendhead.bsql = 0;
  306. g_sendhead.code[0] = 147;
  307. g_sendhead.tabcount = 1;
  308. g_pMainWnd->ProcessChatMessageRequest2(sql);
  309. if (g_bSendOK == 0)
  310. {
  311. m_spinyear.EnableWindow(1);
  312. m_spinmonth.EnableWindow(1);
  313. m_spinday.EnableWindow(1);
  314. g_nYearpos = g_nYearposTemp;
  315. return;
  316. }
  317. CArray<CStringArray, CStringArray>ThisYearList1array;
  318. DataToArray(&ThisYearList1array);
  319. int oldsize = m_List1array.GetSize();
  320. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  321. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  322. {
  323. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  324. }
  325. }
  326. g_nYearpos = g_nYearposTemp;
  327. FillGrid();
  328. m_spinyear.EnableWindow(1);
  329. m_spinmonth.EnableWindow(1);
  330. m_spinday.EnableWindow(1);
  331. }
  332. void PhotoPrintFrom2::OnRadio3()
  333. {
  334. // TODO: Add your control notification handler code here
  335. UpdateData();
  336. DateChange();
  337. }
  338. void PhotoPrintFrom2::OnRadio4()
  339. {
  340. // TODO: Add your control notification handler code here
  341. UpdateData();
  342. DateChange();
  343. }
  344. void PhotoPrintFrom2::OnChangeEDITmoney2()
  345. {
  346. // TODO: If this is a RICHEDIT control, the control will not
  347. // send this notification unless you override the CDialog::OnInitDialog()
  348. // function and call CRichEditCtrl().SetEventMask()
  349. // with the ENM_CHANGE flag ORed into the mask.
  350. if (m_bInit == 0)return;
  351. CString str, str2;
  352. GetDlgItem(IDC_EDITmoney5)->GetWindowText(str);
  353. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str2);
  354. str.Format("%0.5f", atof(str)*atof(str2));
  355. SetDlgItemText(IDC_EDITmoney3, str);
  356. // TODO: Add your control notification handler code here
  357. }
  358. void PhotoPrintFrom2::OnDestroy()
  359. {
  360. // TODO: Add your message handler code here
  361. CString str;
  362. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str);
  363. AfxGetApp()->WriteProfileString(LYFZVERSION, "printprice", str);
  364. if (g_bAllBranch)
  365. {
  366. g_pMainWnd->OnDisconnect();
  367. g_bBranchModify = 0; g_branchip = g_branchname = "";
  368. }
  369. CDialog::OnDestroy();
  370. }
  371. void PhotoPrintFrom2::OnSelchangeCombo6()
  372. {
  373. // TODO: Add your control notification handler code here
  374. FillGrid();
  375. }
  376. void PhotoPrintFrom2::OnSelchangeCOMBObranch()
  377. {
  378. // TODO: Add your control notification handler code here
  379. int pos = m_combobranch.GetCurSel();
  380. if (pos == -1)return;
  381. m_combobranch.GetLBText(pos, m_branch);
  382. DateChange();
  383. m_combo1.ResetContent();
  384. g_sendhead.bsql = 0;
  385. g_sendhead.code[0] = 9;
  386. g_sendhead.tabcount = 1;
  387. CString sql;
  388. g_pMainWnd->ProcessChatMessageRequest2(1);
  389. if (g_bSendOK == 0)
  390. {
  391. return;
  392. }
  393. DataToArray(&g_List1array);
  394. if (m_combo1.GetCount() == 0)
  395. {
  396. m_combo1.ResetContent(); m_combo1.AddString("全部");
  397. for (int i = 0; i < g_List1array.GetSize(); i++)
  398. {
  399. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  400. }
  401. m_combo1.SetCurSel(0);
  402. }
  403. }