PhotoPrintFrom2.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. ON_WM_CTLCOLOR()
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // PhotoPrintFrom2 diagnostics
  63. #ifdef _DEBUG
  64. void PhotoPrintFrom2::AssertValid() const
  65. {
  66. CDialog::AssertValid();
  67. }
  68. void PhotoPrintFrom2::Dump(CDumpContext& dc) const
  69. {
  70. CDialog::Dump(dc);
  71. }
  72. #endif //_DEBUG
  73. /////////////////////////////////////////////////////////////////////////////
  74. // PhotoPrintFrom2 message handlers
  75. extern BOOL CALLBACK EnumChildProc2(HWND hwnd, LPARAM lParam);
  76. BOOL PhotoPrintFrom2::OnInitDialog()
  77. {
  78. CDialog::OnInitDialog();
  79. // TODO: Add your specialized code here and/or call the base class
  80. if (g_bAllBranch)
  81. {
  82. GetDlgItem(IDC_STATIC12)->ShowWindow(SW_SHOW);
  83. GetDlgItem(IDC_COMBObranch)->ShowWindow(SW_SHOW);
  84. // m_combobranch.AddString ("");
  85. for (int i = 0; i < g_brancharray.GetSize(); i++)
  86. {
  87. m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
  88. }
  89. }
  90. CRect rc2;
  91. GetWindowRect(rc2);
  92. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  93. g_WidthScale2 = (float)g_rc.Width() / (float)rc2.Width(); // new/Old
  94. g_HeightScale2 = (float)g_rc.Height() / (float)rc2.Height();
  95. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc2, 0);
  96. #if defined(VC70) || defined(VC80)
  97. m_combobranch.GetWindowRect(rc2);
  98. rc2.bottom += 200;
  99. ScreenToClient(rc2);
  100. m_combobranch.MoveWindow(rc2);
  101. m_combo1.GetWindowRect(rc2);
  102. rc2.bottom += 200;
  103. ScreenToClient(rc2);
  104. m_combo1.MoveWindow(rc2);
  105. #endif
  106. CString str = AfxGetApp()->GetProfileString(LYFZVERSION, "printprice", "20");
  107. SetDlgItemText(IDC_EDITmoney2, str);
  108. m_static1.SetFont(&g_titlefont);
  109. #ifdef CHILD_VERSION
  110. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  111. #else
  112. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;相片名称,100;数量,100;面积m2,100;是否发出,100;发出日期,100;是否回来,100;回来日期,100");
  113. #endif
  114. //m_List1.m_bSortSupport=0;
  115. m_List1.LoadColumnInfo(178);
  116. m_spinyear.SetRange(1900, 3000);
  117. m_spinmonth.SetRange(1, 12);
  118. m_spinday.SetRange(1, 31);
  119. g_sendhead.bsql = 0;
  120. g_sendhead.code[0] = 9;
  121. g_sendhead.tabcount = 1;
  122. CString sql;
  123. g_pMainWnd->ProcessChatMessageRequest2(1);
  124. if (g_bSendOK == 0)
  125. {
  126. CDialog::OnOK();
  127. return 0;
  128. }
  129. DataToArray(&g_List1array);
  130. if (m_combo1.GetCount() == 0)
  131. {
  132. m_combo1.ResetContent(); m_combo1.AddString("全部");
  133. for (int i = 0; i < g_List1array.GetSize(); i++)
  134. {
  135. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  136. }
  137. m_combo1.SetCurSel(0);
  138. }
  139. m_bInit = 1;
  140. DateChange();
  141. return TRUE; // return TRUE unless you set the focus to a control
  142. // EXCEPTION: OCX Property Pages should return FALSE
  143. }
  144. void PhotoPrintFrom2::FillGrid()
  145. {
  146. CString splb = "全部";
  147. int pos = m_combo1.GetCurSel();
  148. if (pos != -1)
  149. {
  150. m_combo1.GetLBText(pos, splb);
  151. }
  152. m_List1.DeleteAllItems2();
  153. int ii = 0;
  154. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  155. int count = 0;
  156. int sum1 = 0;
  157. float sum2 = 0;
  158. if (splb == "全部")
  159. {
  160. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  161. {
  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. else
  168. {
  169. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  170. {
  171. if (m_List1array.ElementAt(ii).ElementAt(6).GetLength() < 4)continue;
  172. if (m_List1array.ElementAt(ii).ElementAt(6).Right(m_List1array.ElementAt(ii).ElementAt(6).GetLength() - 4) != splb)continue;
  173. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  174. sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
  175. sum2 += atoi(m_List1array.ElementAt(ii).ElementAt(4))*atof(m_List1array.ElementAt(ii).ElementAt(5));
  176. }
  177. }
  178. m_List1.m_arLabels.SetSize(count, 1);
  179. ii = count;
  180. m_List1.m_LabelCount = ii;
  181. m_List1.SetItemCountEx(ii);
  182. CString str;
  183. str.Format("单数:%d", ii);
  184. SetDlgItemText(IDC_STATIC2, str);
  185. str.Format("%d", sum1);
  186. SetDlgItemText(IDC_EDITmoney1, str);
  187. str.Format("%0.5f", sum2);
  188. SetDlgItemText(IDC_EDITmoney5, str);
  189. OnChangeEDITmoney2();
  190. }
  191. void PhotoPrintFrom2::OnBUTclose()
  192. {
  193. // TODO: Add your control notification handler code here
  194. CDialog::OnCancel();
  195. }
  196. void PhotoPrintFrom2::OnChangeEDITyear()
  197. {
  198. // TODO: If this is a RICHEDIT control, the control will not
  199. // send this notification unless you override the CDialog::OnInitDialog()
  200. // function and call CRichEditCtrl().SetEventMask()
  201. // with the ENM_CHANGE flag ORed into the mask.
  202. DateChange();
  203. // TODO: Add your control notification handler code here
  204. }
  205. void PhotoPrintFrom2::OnChangeEDITmonth()
  206. {
  207. // TODO: If this is a RICHEDIT control, the control will not
  208. // send this notification unless you override the CDialog::OnInitDialog()
  209. // function and call CRichEditCtrl().SetEventMask()
  210. // with the ENM_CHANGE flag ORed into the mask.
  211. DateChange();
  212. // TODO: Add your control notification handler code here
  213. }
  214. void PhotoPrintFrom2::OnChangeEDITday()
  215. {
  216. // TODO: If this is a RICHEDIT control, the control will not
  217. // send this notification unless you override the CDialog::OnInitDialog()
  218. // function and call CRichEditCtrl().SetEventMask()
  219. // with the ENM_CHANGE flag ORed into the mask.
  220. // DateChange();
  221. // TODO: Add your control notification handler code here
  222. }
  223. void PhotoPrintFrom2::DateChange()
  224. {
  225. if (m_bInit == 0)return;
  226. m_spinyear.EnableWindow(0);
  227. m_spinmonth.EnableWindow(0);
  228. m_spinday.EnableWindow(0);
  229. UpdateData();
  230. if (m_branch != "")
  231. {
  232. g_pMainWnd->OnDisconnect();
  233. g_branchip = GetIP(m_branch);
  234. g_pMainWnd->OnDisconnect();
  235. g_branchname = m_branch;
  236. g_bBranchModify = 1;
  237. }
  238. int i;
  239. int g_nYearposTemp = g_nYearpos;
  240. BOOL bLastYear = 0;
  241. BOOL bThisYear = 0;
  242. #if JEFF_TEST_ON // 2015开始禁用跨年数据;
  243. int g_nYearposPre = -1;
  244. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  245. {
  246. g_nYearpos = -1;
  247. bThisYear = 1;
  248. if (m_year == 2014)
  249. {
  250. g_nYearposPre = GetYearPos(m_year - 1);
  251. }
  252. }
  253. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  254. {
  255. g_nYearpos = GetYearPos(m_year);
  256. if (g_nYearpos != -1)
  257. g_nYearposPre = GetYearPos(m_year - 1);
  258. bLastYear = 1;
  259. }
  260. #else
  261. if (m_year == atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  262. bThisYear = 1;
  263. else if (m_year <= atoi(g_date.Left(4)) - 1 && g_hisyeararray.GetSize())
  264. bLastYear = 1;
  265. g_nYearpos = GetYearPos(m_year);
  266. int g_nYearposPre = GetYearPos(m_year - 1);
  267. #endif
  268. g_sendhead.bsql = 0;
  269. g_sendhead.code[0] = 147;
  270. g_sendhead.tabcount = 1;
  271. CString sql, strdate, strdate2;
  272. strdate.Format("%04d-%02d-%02d", m_year, m_month, 1);
  273. strdate2.Format("%04d-%02d-%02d", m_year, m_month, 31);
  274. m_static1.SetWindowText(strdate.Left(7) + "冲印资料");
  275. if (m_radio1 == 0)
  276. sql.Format("[time1]>='" + strdate + "' and [time1]<='" + strdate2 + "'");
  277. else
  278. sql.Format("[time2]>='" + strdate + "' and [time2]<='" + strdate2 + "'");
  279. g_pMainWnd->ProcessChatMessageRequest2(sql);
  280. if (g_bSendOK == 0)
  281. {
  282. m_spinyear.EnableWindow(1);
  283. m_spinmonth.EnableWindow(1);
  284. m_spinday.EnableWindow(1);
  285. g_nYearpos = g_nYearposTemp;
  286. return;
  287. }
  288. DataToArray(&m_List1array);
  289. if (bLastYear)//如果是去年, 则加今年的补款
  290. {
  291. g_nYearpos = -1;//今年
  292. g_sendhead.bsql = 0;
  293. g_sendhead.code[0] = 147;
  294. g_sendhead.tabcount = 1;
  295. g_pMainWnd->ProcessChatMessageRequest2(sql);
  296. if (g_bSendOK == 0)
  297. {
  298. m_spinyear.EnableWindow(1);
  299. m_spinmonth.EnableWindow(1);
  300. m_spinday.EnableWindow(1);
  301. g_nYearpos = g_nYearposTemp;
  302. return;
  303. }
  304. CArray<CStringArray, CStringArray>ThisYearList1array;
  305. DataToArray(&ThisYearList1array);
  306. int oldsize = m_List1array.GetSize();
  307. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  308. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  309. {
  310. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  311. }
  312. }
  313. if (g_nYearposPre != -1)//如果是今年, 则加去年的补款
  314. {
  315. g_nYearpos = g_nYearposPre;//去年
  316. g_sendhead.bsql = 0;
  317. g_sendhead.code[0] = 147;
  318. g_sendhead.tabcount = 1;
  319. g_pMainWnd->ProcessChatMessageRequest2(sql);
  320. if (g_bSendOK == 0)
  321. {
  322. m_spinyear.EnableWindow(1);
  323. m_spinmonth.EnableWindow(1);
  324. m_spinday.EnableWindow(1);
  325. g_nYearpos = g_nYearposTemp;
  326. return;
  327. }
  328. CArray<CStringArray, CStringArray>ThisYearList1array;
  329. DataToArray(&ThisYearList1array);
  330. int oldsize = m_List1array.GetSize();
  331. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  332. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  333. {
  334. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  335. }
  336. }
  337. g_nYearpos = g_nYearposTemp;
  338. FillGrid();
  339. m_spinyear.EnableWindow(1);
  340. m_spinmonth.EnableWindow(1);
  341. m_spinday.EnableWindow(1);
  342. }
  343. void PhotoPrintFrom2::OnRadio3()
  344. {
  345. // TODO: Add your control notification handler code here
  346. UpdateData();
  347. DateChange();
  348. }
  349. void PhotoPrintFrom2::OnRadio4()
  350. {
  351. // TODO: Add your control notification handler code here
  352. UpdateData();
  353. DateChange();
  354. }
  355. void PhotoPrintFrom2::OnChangeEDITmoney2()
  356. {
  357. // TODO: If this is a RICHEDIT control, the control will not
  358. // send this notification unless you override the CDialog::OnInitDialog()
  359. // function and call CRichEditCtrl().SetEventMask()
  360. // with the ENM_CHANGE flag ORed into the mask.
  361. if (m_bInit == 0)return;
  362. CString str, str2;
  363. GetDlgItem(IDC_EDITmoney5)->GetWindowText(str);
  364. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str2);
  365. str.Format("%0.5f", atof(str)*atof(str2));
  366. SetDlgItemText(IDC_EDITmoney3, str);
  367. // TODO: Add your control notification handler code here
  368. }
  369. void PhotoPrintFrom2::OnDestroy()
  370. {
  371. // TODO: Add your message handler code here
  372. CString str;
  373. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str);
  374. AfxGetApp()->WriteProfileString(LYFZVERSION, "printprice", str);
  375. if (g_bAllBranch)
  376. {
  377. g_pMainWnd->OnDisconnect();
  378. g_bBranchModify = 0; g_branchip = g_branchname = "";
  379. }
  380. CDialog::OnDestroy();
  381. }
  382. void PhotoPrintFrom2::OnSelchangeCombo6()
  383. {
  384. // TODO: Add your control notification handler code here
  385. FillGrid();
  386. }
  387. void PhotoPrintFrom2::OnSelchangeCOMBObranch()
  388. {
  389. // TODO: Add your control notification handler code here
  390. int pos = m_combobranch.GetCurSel();
  391. if (pos == -1)return;
  392. m_combobranch.GetLBText(pos, m_branch);
  393. DateChange();
  394. m_combo1.ResetContent();
  395. g_sendhead.bsql = 0;
  396. g_sendhead.code[0] = 9;
  397. g_sendhead.tabcount = 1;
  398. CString sql;
  399. g_pMainWnd->ProcessChatMessageRequest2(1);
  400. if (g_bSendOK == 0)
  401. {
  402. return;
  403. }
  404. DataToArray(&g_List1array);
  405. if (m_combo1.GetCount() == 0)
  406. {
  407. m_combo1.ResetContent(); m_combo1.AddString("全部");
  408. for (int i = 0; i < g_List1array.GetSize(); i++)
  409. {
  410. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  411. }
  412. m_combo1.SetCurSel(0);
  413. }
  414. }
  415. HBRUSH PhotoPrintFrom2::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  416. {
  417. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  418. // TODO: 在此更改 DC 的任何属性
  419. if ( nCtlColor == CTLCOLOR_DLG )
  420. return g_dlgBrush;
  421. else if ( nCtlColor == CTLCOLOR_STATIC )
  422. {
  423. //pDC->SetBkColor(g_bkcol);
  424. pDC->SetBkMode(TRANSPARENT);
  425. hbr=(HBRUSH)g_dlgBrush;
  426. }
  427. // TODO: 如果默认的不是所需画笔,则返回另一个画笔
  428. return hbr;
  429. }