PayOutInput.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. // PayOutInput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "PayOutInput.h"
  6. #include "MyMdi.H"
  7. #include "Login2.h"
  8. #include "ShowPhoto.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // PayOutInput
  16. IMPLEMENT_DYNCREATE(PayOutInput, MyFormView)
  17. PayOutInput::PayOutInput()
  18. : MyFormView(PayOutInput::IDD)
  19. {
  20. //{{AFX_DATA_INIT(PayOutInput)
  21. m_bz = _T("");
  22. m_date = g_date;
  23. m_money = _T("");
  24. m_name = _T("");
  25. m_renyuan2 = g_user.name;
  26. m_renyuan1 = _T("");
  27. m_year = atoi(g_date.Mid (0,4));
  28. m_month = atoi(g_date.Mid (5,2));
  29. m_day = atoi(g_date.Mid (8,2));
  30. m_bInit=0;
  31. m_pImg=NULL;
  32. //}}AFX_DATA_INIT
  33. }
  34. PayOutInput::~PayOutInput()
  35. {
  36. if(m_pImg)delete m_pImg;
  37. }
  38. void PayOutInput::DoDataExchange(CDataExchange* pDX)
  39. {
  40. MyFormView::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(PayOutInput)
  42. DDX_Control(pDX, IDC_EDITdate, m_datectrl);
  43. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  44. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  45. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  46. DDX_Control(pDX, IDC_COMBOrenyuan1, m_comborenyuan);
  47. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  48. DDX_Control(pDX, IDC_LIST1, m_list2);
  49. DDX_Control(pDX, IDC_LIST2, m_List1);
  50. DDX_Control(pDX, IDC_STATIC1, m_static1);
  51. DDX_Text(pDX, IDC_EDITbz, m_bz);
  52. DDV_MaxChars(pDX, m_bz, 1000);
  53. DDX_Text(pDX, IDC_EDITdate, m_date);
  54. DDX_Text(pDX, IDC_EDITmoney, m_money);
  55. DDX_Text(pDX, IDC_EDITname, m_name);
  56. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  57. DDX_CBString(pDX, IDC_COMBOrenyuan1, m_renyuan1);
  58. DDX_Text(pDX, IDC_EDITday, m_day);
  59. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  60. DDX_Text(pDX, IDC_EDITmonth, m_month);
  61. DDV_MinMaxUInt(pDX, m_month, 1, 31);
  62. DDX_Text(pDX, IDC_EDITyear, m_year);
  63. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(PayOutInput, MyFormView)
  67. //{{AFX_MSG_MAP(PayOutInput)
  68. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  69. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  70. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  71. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  72. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  73. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  74. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  75. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  76. ON_BN_CLICKED(IDC_BUTprint, OnBUTprint)
  77. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  78. ON_BN_CLICKED(IDC_BUTload, OnBUTload)
  79. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  80. ON_WM_PAINT()
  81. ON_WM_LBUTTONDOWN()
  82. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  83. //}}AFX_MSG_MAP
  84. END_MESSAGE_MAP()
  85. /////////////////////////////////////////////////////////////////////////////
  86. // PayOutInput diagnostics
  87. #ifdef _DEBUG
  88. void PayOutInput::AssertValid() const
  89. {
  90. MyFormView::AssertValid();
  91. }
  92. void PayOutInput::Dump(CDumpContext& dc) const
  93. {
  94. MyFormView::Dump(dc);
  95. }
  96. #endif //_DEBUG
  97. /////////////////////////////////////////////////////////////////////////////
  98. // PayOutInput message handlers
  99. void PayOutInput::OnInitialUpdate()
  100. {
  101. MyFormView::OnInitialUpdate();
  102. // TODO: Add your specialized code here and/or call the base class
  103. CMyMdi Mdi;
  104. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  105. // Here we create the outbar control using the splitter as its parent
  106. // and setting its id to the first pane.
  107. CRect rc2;
  108. GetWindowRect(rc2);
  109. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  110. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  111. m_comborenyuan.RefDroppedWidth();
  112. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(49));
  113. m_static1.SetFont (&g_titlefont);
  114. m_List1.SetHeadings("id,0;费用项目, 130;金额, 60;日期, 90;取款人,100;经手人,100;备注,110" );
  115. m_List1.LoadColumnInfo (105);
  116. g_sendhead.bsql=0;
  117. g_sendhead.code[0]=12;
  118. g_sendhead.tabcount=1;
  119. g_pMainWnd->ProcessChatMessageRequest2(12);if(g_bSendOK==0)return;
  120. DataToArray(&g_List1array);
  121. for(int i=0; i<g_userarray.GetSize (); i++)
  122. m_comborenyuan.AddString (g_userarray.ElementAt (i).ElementAt (1));
  123. m_comborenyuan.GetWindowRect (rc2);
  124. ScreenToClient(rc2);
  125. rc2.bottom +=200;
  126. m_comborenyuan.MoveWindow (rc2);
  127. for(int ii=0; ii<g_List1array.GetSize (); ii++)
  128. {
  129. m_list2.AddString (g_List1array.ElementAt (ii).ElementAt(0));
  130. }
  131. m_spinyear.SetRange (1900, 3000);
  132. m_spinmonth.SetRange (1, 12);
  133. m_spinday.SetRange (1, 31);
  134. m_bInit=1;
  135. GetData();
  136. }
  137. void PayOutInput::FillGrid()
  138. {
  139. m_List1.DeleteAllItems2 ();
  140. int ii=0;
  141. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  142. int count=0;
  143. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  144. {
  145. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  146. }
  147. m_List1.m_arLabels.SetSize(count, 1);
  148. ii=count;
  149. m_List1.m_LabelCount=ii;
  150. m_List1.SetItemCountEx (ii);
  151. }
  152. void PayOutInput::OnBUTclose()
  153. {
  154. // TODO: Add your control notification handler code here
  155. GetParent()->SendMessage(WM_CLOSE);
  156. }
  157. void PayOutInput::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  158. {
  159. // TODO: Add your control notification handler code here
  160. ListSelChange();
  161. *pResult = 0;
  162. }
  163. void PayOutInput::ListSelChange()
  164. {
  165. POSITION pos;
  166. pos=m_List1.GetFirstSelectedItemPosition();
  167. if(pos==NULL)
  168. {
  169. ClearCtrl();
  170. return;
  171. }
  172. int iItem=m_List1.GetNextSelectedItem(pos);
  173. m_id=m_List1.GetItemText (iItem, 0);
  174. for(int ii=0; ii<m_List1array.GetSize (); ii++)
  175. {
  176. if(m_List1array.ElementAt (ii).ElementAt (0)==m_id)
  177. {
  178. GetDlgItem(IDC_BUTload)->EnableWindow(1);
  179. GetDlgItem(IDC_BUTdel2)->EnableWindow(1);
  180. CString bm;
  181. m_name = m_List1array.ElementAt (ii).ElementAt (1);
  182. m_money = m_List1array.ElementAt (ii).ElementAt (2);
  183. m_date = m_List1array.ElementAt (ii).ElementAt (3);
  184. m_renyuan1 = m_List1array.ElementAt (ii).ElementAt (4);
  185. m_renyuan2 = m_List1array.ElementAt (ii).ElementAt (5);
  186. m_bz = m_List1arrayBak.ElementAt (ii).ElementAt (6);
  187. UpdateData(false);
  188. char no[100];
  189. memset(no, 0, 100);
  190. strcpy(no, m_id);
  191. g_nSendCode=36;
  192. g_pMainWnd->ProcessChatMessageRequest2((BYTE*)no, 100);
  193. g_nSendCode=0;
  194. if(g_bSendOK==0)
  195. {
  196. return;
  197. }
  198. if(m_pImg)delete m_pImg;m_pImg=NULL;
  199. ::LoadImageFromBuf (&m_pImg, g_pData, g_nLeng);
  200. if(m_pImg==NULL)
  201. {
  202. AfxMessageBox("无效图片文件!");return;
  203. }
  204. CRect rc;
  205. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  206. ScreenToClient(rc);
  207. InvalidateRect(rc);
  208. break;
  209. }
  210. }
  211. GetDlgItem(IDC_BUTsave)->EnableWindow(0);
  212. }
  213. void PayOutInput::OnBUTsave()
  214. {
  215. // TODO: Add your control notification handler code here
  216. UpdateData();
  217. if(!CheckDateOK(m_date))return;
  218. if(g_nYearpos!=-1)
  219. {
  220. AfxMessageBox("当前为历史数据查看状态,不能更改历史数据!", MB_ICONSTOP);
  221. return;
  222. }
  223. m_name.TrimRight ();
  224. if(m_name.IsEmpty () || m_money.IsEmpty () )
  225. {
  226. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  227. return;
  228. }
  229. CString sql;
  230. sql.Format ("insert into gudingfeiyong([name],[money],[dat],[renyuan1],[renyuan2],[bz],[time])values('%s','%s','%s','%s','%s','%s','curtimereplace')",m_name,m_money,m_date,m_renyuan1,m_renyuan2,m_bz);
  231. sql+=GDFY_REF;
  232. g_sendhead.bsql=1;
  233. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  234. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  235. GetData();
  236. }
  237. void PayOutInput::OnBUTdel()
  238. {
  239. // TODO: Add your control notification handler code here
  240. if(IsHasRights2new(49)==0)return;
  241. POSITION pos;
  242. pos=m_List1.GetFirstSelectedItemPosition();
  243. if(pos==NULL)
  244. {
  245. return;
  246. }
  247. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  248. int iItem=m_List1.GetNextSelectedItem(pos);
  249. CString id=m_List1.GetItemText (iItem, 0);
  250. CString bz=m_List1.GetItemText (iItem, 1);
  251. CString money=m_List1.GetItemText (iItem, 2);
  252. CString date=m_List1.GetItemText (iItem, 3);
  253. CString sql;
  254. sql.Format ("delete from gudingfeiyong where id=%d ", atoi(id));
  255. g_sendhead.bsql=1;
  256. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  257. GetData();
  258. CString str;
  259. str="删除费用";
  260. str+=bz;
  261. str+="金额:";
  262. str+=money;
  263. str+="日期:";
  264. str+=date;
  265. WriteLog(str);
  266. }
  267. void PayOutInput::GetData()
  268. {
  269. if(m_bInit==0)return;
  270. m_spinyear.EnableWindow(0);
  271. m_spinmonth.EnableWindow(0);
  272. m_spinday.EnableWindow(0);
  273. UpdateData();
  274. CString sql,strdate;
  275. strdate.Format ("%04d-%02d-%02d", m_year, m_month, m_day);
  276. sql.Format ("dat='"+strdate+"'");
  277. g_sendhead.bsql=0;
  278. g_sendhead.code[0]=13;
  279. g_sendhead.tabcount=1;
  280. g_pMainWnd->ProcessChatMessageRequest2(sql);
  281. if(g_bSendOK==0)
  282. {
  283. m_spinyear.EnableWindow(1);
  284. m_spinmonth.EnableWindow(1);
  285. m_spinday.EnableWindow(1);
  286. return;
  287. }
  288. DataToArray(&m_List1array);
  289. m_List1arrayBak.SetSize(m_List1array.GetSize ());
  290. for(int i=0; i<m_List1array.GetSize (); i++)
  291. {
  292. m_List1arrayBak.ElementAt (i).Copy (m_List1array.ElementAt (i));
  293. if(m_List1array.ElementAt (i).ElementAt (6).GetLength ()>256)
  294. m_List1array.ElementAt (i).SetAt (6, m_List1array.ElementAt (i).ElementAt (6).Left (256)+"..");
  295. }
  296. FillGrid();
  297. m_spinyear.EnableWindow(1);
  298. m_spinmonth.EnableWindow(1);
  299. m_spinday.EnableWindow(1);
  300. }
  301. void PayOutInput::ClearCtrl()
  302. {
  303. UpdateData();
  304. m_date=g_date;
  305. m_bz = _T("");
  306. m_money = _T("");
  307. m_id = _T("");
  308. m_renyuan1 = _T("");
  309. m_renyuan2 = g_user.name;
  310. UpdateData(false);
  311. GetDlgItem(IDC_BUTsave)->EnableWindow(1);
  312. GetDlgItem(IDC_BUTload)->EnableWindow(0);
  313. GetDlgItem(IDC_BUTdel2)->EnableWindow(0);
  314. if(m_pImg)delete m_pImg;m_pImg=NULL;
  315. CRect rc;
  316. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  317. ScreenToClient(rc);
  318. InvalidateRect(rc);
  319. }
  320. void PayOutInput::OnSelchangeList1()
  321. {
  322. // TODO: Add your control notification handler code here
  323. int pos=m_list2.GetCurSel ();
  324. if(pos==-1)return;
  325. CString str;
  326. m_list2.GetText (pos, str);
  327. m_name=str;
  328. UpdateData(false);
  329. ClearCtrl();
  330. }
  331. void PayOutInput::OnChangeEDITyear()
  332. {
  333. // TODO: If this is a RICHEDIT control, the control will not
  334. // send this notification unless you override the MyFormView::OnInitDialog()
  335. // function and call CRichEditCtrl().SetEventMask()
  336. // with the ENM_CHANGE flag ORed into the mask.
  337. GetData();
  338. // TODO: Add your control notification handler code here
  339. }
  340. void PayOutInput::OnChangeEDITmonth()
  341. {
  342. // TODO: If this is a RICHEDIT control, the control will not
  343. // send this notification unless you override the MyFormView::OnInitDialog()
  344. // function and call CRichEditCtrl().SetEventMask()
  345. // with the ENM_CHANGE flag ORed into the mask.
  346. GetData();
  347. // TODO: Add your control notification handler code here
  348. }
  349. void PayOutInput::OnChangeEDITday()
  350. {
  351. // TODO: If this is a RICHEDIT control, the control will not
  352. // send this notification unless you override the MyFormView::OnInitDialog()
  353. // function and call CRichEditCtrl().SetEventMask()
  354. // with the ENM_CHANGE flag ORed into the mask.
  355. GetData();
  356. // TODO: Add your control notification handler code here
  357. }
  358. BOOL PayOutInput::PreTranslateMessage(MSG* pMsg)
  359. {
  360. // TODO: Add your specialized code here and/or call the base class
  361. try
  362. {
  363. if(pMsg->message==WM_KEYDOWN)
  364. {
  365. switch (pMsg->wParam)
  366. {
  367. case 0x43: // copy
  368. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  369. {
  370. GetFocus()->SendMessage(WM_COPY);
  371. return TRUE;
  372. }
  373. break;
  374. case 0x56: //Ctrl + V:
  375. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  376. {
  377. GetFocus()->SendMessage(WM_PASTE);
  378. return TRUE;
  379. }
  380. break;
  381. case 0x58: // cut
  382. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  383. {
  384. GetFocus()->SendMessage(WM_CUT);
  385. return TRUE;
  386. }
  387. break;
  388. case 0x5A: //undo
  389. case 0x59: //redo
  390. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  391. {
  392. GetFocus()->SendMessage(WM_UNDO);
  393. return TRUE;
  394. }
  395. break;
  396. }
  397. }
  398. return MyFormView::PreTranslateMessage(pMsg);
  399. }
  400. catch(...)
  401. {
  402. }
  403. }
  404. void PayOutInput::OnBUTprint()
  405. {
  406. // TODO: Add your control notification handler code here
  407. POSITION pos;
  408. pos=m_List1.GetFirstSelectedItemPosition();
  409. if(pos==NULL)
  410. {
  411. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  412. return;
  413. }
  414. int iItem;
  415. iItem = m_List1.GetNextSelectedItem(pos);
  416. CStringArray array;
  417. array.Add ("");
  418. array.Add (g_cominfoarray.ElementAt (0).ElementAt (10)+"支出单");
  419. array.Add ("");
  420. CString str="地址:"+g_cominfoarray.ElementAt (0).ElementAt (12);
  421. str+=" 电话:"+g_cominfoarray.ElementAt (0).ElementAt (11);
  422. array.Add (str);
  423. CString name=m_List1.GetItemText (iItem, 4);
  424. array.Add ("支款人:"+name);
  425. array.Add ("");
  426. CString date;
  427. date.Format ("日期:%s年%s月%s日", g_date.Mid (0,4), g_date.Mid (5,2), g_date.Mid (8,2));
  428. array.Add (date);
  429. array.Add (" 支 出 项 目 ");
  430. array.Add (" 金 额 ");
  431. array.Add (" 支款人 ");
  432. int count=0;
  433. float money=0;
  434. // while (pos)
  435. {
  436. count++;
  437. // if(count>4)break;
  438. array.Add (m_List1.GetItemText (iItem, 1));
  439. array.Add (m_List1.GetItemText (iItem, 2));
  440. money+=atof(m_List1.GetItemText (iItem, 2));
  441. array.Add ("");
  442. }
  443. while(array.GetSize ()<22)
  444. array.Add ("");
  445. CString smoney;
  446. smoney.Format ("%0.1f", money);
  447. if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  448. {
  449. str="支出情况 总额:"+smoney;
  450. str+=" 实付:"+smoney;
  451. str+=" ";
  452. }
  453. else
  454. {
  455. str="支出情况 总额:"+smoney;
  456. str+=" 实付:"+smoney;
  457. str+=" ";
  458. }
  459. array.Add (str);
  460. if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  461. {
  462. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\
  463. GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney)));
  464. }
  465. else
  466. {
  467. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\
  468. GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney)));
  469. }
  470. array.Add (str);
  471. array.Add (g_cominfoarray.ElementAt (0).ElementAt (120));
  472. array.Add ("收银:"+g_user.name);
  473. array.Add ("支出签名:");
  474. array.Add ("第\r\n一\r\n联\r\n存\r\n根\r\n∧\r\n白\r\n∨\r\n第\r\n二\r\n联\r\n财\r\n务\r\n∧\r\n黄\r\n∨\r\n第\r\n三\r\n联\r\n客\r\n户\r\n∧\r\n红\r\n∨");
  475. g_pMainWnd->PrintReceipt2(&array); // 支出,不使用PrintReceipt_01,不需要显示支付方式 Jeff
  476. }
  477. void PayOutInput::OnButton1()
  478. {
  479. // TODO: Add your control notification handler code here
  480. Login2 dlg;
  481. dlg.m_mode=3;
  482. if(dlg.DoModal ()!=IDOK)return;
  483. if(IsHasRightsnew2(49, dlg.m_rights)==0)return;
  484. ((CEdit*)GetDlgItem(IDC_EDITdate))->SetReadOnly (0);
  485. }
  486. void PayOutInput::OnBUTload()
  487. {
  488. // TODO: Add your control notification handler code here
  489. POSITION pos;
  490. pos=m_List1.GetFirstSelectedItemPosition();
  491. if(pos==NULL)
  492. {
  493. return;
  494. }
  495. int iItem=m_List1.GetNextSelectedItem(pos);
  496. m_id=m_List1.GetItemText (iItem, 0);
  497. CFileDialog fdlg(true, NULL,"", OFN_HIDEREADONLY, "jpg files(*jpg)|*.jpg||");
  498. if(fdlg.DoModal ()!=IDOK)return;
  499. CString path=fdlg.GetPathName();
  500. if(m_pImg)delete m_pImg;m_pImg=NULL;
  501. ::LoadImageFromBuf (&m_pImg, path);
  502. if(m_pImg==NULL)
  503. {
  504. AfxMessageBox("无效图片文件!");return;
  505. }
  506. CFile fp;
  507. if(!fp.Open(path, CFile::modeRead))
  508. {
  509. AfxMessageBox("文件打开失败!");
  510. return;
  511. }
  512. DWORD length=fp.GetLength();
  513. if(length>1024*200)
  514. {
  515. // AfxMessageBox("文件太大,请上传小于200K的图片!");
  516. fp.Close();
  517. // return;
  518. Image *simg2=NULL;
  519. CRect rc2(0,0,1000,1000);
  520. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
  521. simg2=m_pImg->GetThumbnailImage(rc2.Width (), rc2.Height (), NULL, NULL);
  522. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  523. graphic2.Clear(Color(255,255,255,255));
  524. graphic2.DrawImage(m_pImg, 0,0,simg2->GetWidth(), simg2->GetHeight() );
  525. if(m_pImg)delete m_pImg;m_pImg=NULL;
  526. path=g_mainpath+"\\1.jpg";
  527. ::SaveImageToFile2 (simg2, path, 40);
  528. m_pImg=simg2;
  529. if(!fp.Open(path, CFile::modeRead))
  530. {
  531. AfxMessageBox("文件打开失败!");
  532. return;
  533. }
  534. length=fp.GetLength();
  535. }
  536. BYTE *m_pData=new BYTE[length+100];
  537. fp.Read(m_pData, length);
  538. fp.Close();
  539. char no[100];
  540. memset(no, 0, 100);
  541. strcpy(no, m_id);
  542. memcpy(m_pData+length, no, 100);
  543. g_nSendCode=35;
  544. g_pMainWnd->ProcessChatMessageRequest2(m_pData, length+100);
  545. g_nSendCode=0;
  546. delete []m_pData;
  547. if(g_bSendOK==0)
  548. {
  549. if(m_pImg)delete m_pImg;m_pImg=NULL;
  550. return;
  551. }
  552. AfxMessageBox("上传成功!");
  553. CRect rc;
  554. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  555. ScreenToClient(rc);
  556. InvalidateRect(rc);
  557. }
  558. void PayOutInput::OnBUTdel2()
  559. {
  560. // TODO: Add your control notification handler code here
  561. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  562. UpdateData();
  563. char no[100];
  564. memset(no, 0, 100);
  565. strcpy(no, m_id);
  566. g_nSendCode=35;
  567. g_pMainWnd->ProcessChatMessageRequest2((BYTE*)no, 100);
  568. g_nSendCode=0;
  569. if(g_bSendOK==0)
  570. {
  571. return;
  572. }
  573. if(m_pImg)delete m_pImg;m_pImg=NULL;
  574. CRect rc;
  575. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  576. ScreenToClient(rc);
  577. InvalidateRect(rc);
  578. }
  579. void PayOutInput::OnPaint()
  580. {
  581. CPaintDC dc(this); // device context for painting
  582. // TODO: Add your message handler code here
  583. if(m_pImg)
  584. {
  585. CRect rc;
  586. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  587. ScreenToClient(rc);
  588. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
  589. Graphics dcgraph(dc.GetSafeHdc());
  590. Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
  591. dcgraph.DrawImage(m_pImg, destinationRect, 0,0,m_pImg->GetWidth(), m_pImg->GetHeight(),UnitPixel);
  592. }
  593. // Do not call MyFormView::OnPaint() for painting messages
  594. }
  595. void PayOutInput::OnLButtonDown(UINT nFlags, CPoint point)
  596. {
  597. // TODO: Add your message handler code here and/or call default
  598. CRect rc;
  599. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  600. ScreenToClient(rc);
  601. if(rc.PtInRect(point) && m_pImg)
  602. {
  603. // ShowPhoto dlg;
  604. // dlg.m_pImg=m_pImg;
  605. // dlg.DoModal();
  606. CString path=g_mainpath+"\\1.jpg"; ::DeleteFile(path);
  607. ::SaveImageToFile(m_pImg, path);
  608. ShellExecute(NULL, _T("open"), path, NULL, NULL, SW_SHOWMAXIMIZED);
  609. }
  610. MyFormView::OnLButtonDown(nFlags, point);
  611. }
  612. void PayOutInput::OnButton2()
  613. {
  614. // TODO: Add your control notification handler code here
  615. g_pMainWnd->OnOutbarNotify("支出报表");
  616. }