PhotoPrintFrom2.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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 (m_year == atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  233. bThisYear = 1;
  234. else if (m_year <= atoi(g_date.Left(4)) - 1 && g_hisyeararray.GetSize())
  235. bLastYear = 1;
  236. g_nYearpos = GetYearPos(m_year);
  237. int g_nYearposPre = GetYearPos(m_year - 1);
  238. g_sendhead.bsql = 0;
  239. g_sendhead.code[0] = 147;
  240. g_sendhead.tabcount = 1;
  241. CString sql, strdate, strdate2;
  242. strdate.Format("%04d-%02d-%02d", m_year, m_month, 1);
  243. strdate2.Format("%04d-%02d-%02d", m_year, m_month, 31);
  244. m_static1.SetWindowText(strdate.Left(7) + "冲印资料");
  245. if (m_radio1 == 0)
  246. sql.Format("[time1]>='" + strdate + "' and [time1]<='" + strdate2 + "'");
  247. else
  248. sql.Format("[time2]>='" + strdate + "' and [time2]<='" + strdate2 + "'");
  249. g_pMainWnd->ProcessChatMessageRequest2(sql);
  250. if (g_bSendOK == 0)
  251. {
  252. m_spinyear.EnableWindow(1);
  253. m_spinmonth.EnableWindow(1);
  254. m_spinday.EnableWindow(1);
  255. g_nYearpos = g_nYearposTemp;
  256. return;
  257. }
  258. DataToArray(&m_List1array);
  259. if (bLastYear)//如果是去年, 则加今年的补款
  260. {
  261. g_nYearpos = -1;//今年
  262. g_sendhead.bsql = 0;
  263. g_sendhead.code[0] = 147;
  264. g_sendhead.tabcount = 1;
  265. g_pMainWnd->ProcessChatMessageRequest2(sql);
  266. if (g_bSendOK == 0)
  267. {
  268. m_spinyear.EnableWindow(1);
  269. m_spinmonth.EnableWindow(1);
  270. m_spinday.EnableWindow(1);
  271. g_nYearpos = g_nYearposTemp;
  272. return;
  273. }
  274. CArray<CStringArray, CStringArray>ThisYearList1array;
  275. DataToArray(&ThisYearList1array);
  276. int oldsize = m_List1array.GetSize();
  277. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  278. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  279. {
  280. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  281. }
  282. }
  283. if (g_nYearposPre != -1)//如果是今年, 则加去年的补款
  284. {
  285. g_nYearpos = g_nYearposPre;//去年
  286. g_sendhead.bsql = 0;
  287. g_sendhead.code[0] = 147;
  288. g_sendhead.tabcount = 1;
  289. g_pMainWnd->ProcessChatMessageRequest2(sql);
  290. if (g_bSendOK == 0)
  291. {
  292. m_spinyear.EnableWindow(1);
  293. m_spinmonth.EnableWindow(1);
  294. m_spinday.EnableWindow(1);
  295. g_nYearpos = g_nYearposTemp;
  296. return;
  297. }
  298. CArray<CStringArray, CStringArray>ThisYearList1array;
  299. DataToArray(&ThisYearList1array);
  300. int oldsize = m_List1array.GetSize();
  301. m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
  302. for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
  303. {
  304. m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
  305. }
  306. }
  307. g_nYearpos = g_nYearposTemp;
  308. FillGrid();
  309. m_spinyear.EnableWindow(1);
  310. m_spinmonth.EnableWindow(1);
  311. m_spinday.EnableWindow(1);
  312. }
  313. void PhotoPrintFrom2::OnRadio3()
  314. {
  315. // TODO: Add your control notification handler code here
  316. UpdateData();
  317. DateChange();
  318. }
  319. void PhotoPrintFrom2::OnRadio4()
  320. {
  321. // TODO: Add your control notification handler code here
  322. UpdateData();
  323. DateChange();
  324. }
  325. void PhotoPrintFrom2::OnChangeEDITmoney2()
  326. {
  327. // TODO: If this is a RICHEDIT control, the control will not
  328. // send this notification unless you override the CDialog::OnInitDialog()
  329. // function and call CRichEditCtrl().SetEventMask()
  330. // with the ENM_CHANGE flag ORed into the mask.
  331. if (m_bInit == 0)return;
  332. CString str, str2;
  333. GetDlgItem(IDC_EDITmoney5)->GetWindowText(str);
  334. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str2);
  335. str.Format("%0.5f", atof(str)*atof(str2));
  336. SetDlgItemText(IDC_EDITmoney3, str);
  337. // TODO: Add your control notification handler code here
  338. }
  339. void PhotoPrintFrom2::OnDestroy()
  340. {
  341. // TODO: Add your message handler code here
  342. CString str;
  343. GetDlgItem(IDC_EDITmoney2)->GetWindowText(str);
  344. CString version = _T("Version 1.0");
  345. AfxGetApp()->WriteProfileString(version, "printprice", str);
  346. if (g_bAllBranch)
  347. {
  348. g_pMainWnd->OnDisconnect();
  349. g_bBranchModify = 0; g_branchip = g_branchname = "";
  350. }
  351. CDialog::OnDestroy();
  352. }
  353. void PhotoPrintFrom2::OnSelchangeCombo6()
  354. {
  355. // TODO: Add your control notification handler code here
  356. FillGrid();
  357. }
  358. void PhotoPrintFrom2::OnSelchangeCOMBObranch()
  359. {
  360. // TODO: Add your control notification handler code here
  361. int pos = m_combobranch.GetCurSel();
  362. if (pos == -1)return;
  363. m_combobranch.GetLBText(pos, m_branch);
  364. DateChange();
  365. m_combo1.ResetContent();
  366. g_sendhead.bsql = 0;
  367. g_sendhead.code[0] = 9;
  368. g_sendhead.tabcount = 1;
  369. CString sql;
  370. g_pMainWnd->ProcessChatMessageRequest2(1);
  371. if (g_bSendOK == 0)
  372. {
  373. return;
  374. }
  375. DataToArray(&g_List1array);
  376. if (m_combo1.GetCount() == 0)
  377. {
  378. m_combo1.ResetContent(); m_combo1.AddString("全部");
  379. for (int i = 0; i < g_List1array.GetSize(); i++)
  380. {
  381. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  382. }
  383. m_combo1.SetCurSel(0);
  384. }
  385. }