PhotoPrintFrom2.cpp 12 KB

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