PayOutInput.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. extern void SaveImageToFile2(Image *img, CString path, ULONG quality);
  487. void PayOutInput::OnBUTload()
  488. {
  489. // TODO: Add your control notification handler code here
  490. POSITION pos;
  491. pos = m_List1.GetFirstSelectedItemPosition();
  492. if (pos == NULL)
  493. {
  494. return;
  495. }
  496. int iItem = m_List1.GetNextSelectedItem(pos);
  497. m_id = m_List1.GetItemText(iItem, 0);
  498. CFileDialog fdlg(true, NULL, "", OFN_HIDEREADONLY, "jpg files(*jpg)|*.jpg||");
  499. if (fdlg.DoModal() != IDOK)return;
  500. CString path = fdlg.GetPathName();
  501. if (m_pImg)delete m_pImg; m_pImg = NULL;
  502. ::LoadImageFromBuf(&m_pImg, path);
  503. if (m_pImg == NULL)
  504. {
  505. AfxMessageBox("无效图片文件!"); return;
  506. }
  507. CFile fp;
  508. if (!fp.Open(path, CFile::modeRead))
  509. {
  510. AfxMessageBox("文件打开失败!");
  511. return;
  512. }
  513. DWORD length = fp.GetLength();
  514. if (length > 1024 * 200)
  515. {
  516. // AfxMessageBox("文件太大,请上传小于200K的图片!");
  517. fp.Close();
  518. // return;
  519. Image *simg2 = NULL;
  520. CRect rc2(0, 0, 1000, 1000);
  521. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
  522. simg2 = m_pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
  523. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  524. graphic2.Clear(Color(255, 255, 255, 255));
  525. graphic2.DrawImage(m_pImg, 0, 0, simg2->GetWidth(), simg2->GetHeight());
  526. if (m_pImg)delete m_pImg; m_pImg = NULL;
  527. path = g_mainpath + "\\1.jpg";
  528. ::SaveImageToFile2(simg2, path, 40);
  529. m_pImg = simg2;
  530. if (!fp.Open(path, CFile::modeRead))
  531. {
  532. AfxMessageBox("文件打开失败!");
  533. return;
  534. }
  535. length = fp.GetLength();
  536. }
  537. BYTE *m_pData = new BYTE[length + 100];
  538. fp.Read(m_pData, length);
  539. fp.Close();
  540. char no[100];
  541. memset(no, 0, 100);
  542. strcpy(no, m_id);
  543. memcpy(m_pData + length, no, 100);
  544. g_nSendCode = 35;
  545. g_pMainWnd->ProcessChatMessageRequest2(m_pData, length + 100);
  546. g_nSendCode = 0;
  547. delete[]m_pData;
  548. if (g_bSendOK == 0)
  549. {
  550. if (m_pImg)delete m_pImg; m_pImg = NULL;
  551. return;
  552. }
  553. AfxMessageBox("上传成功!");
  554. CRect rc;
  555. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  556. ScreenToClient(rc);
  557. InvalidateRect(rc);
  558. }
  559. void PayOutInput::OnBUTdel2()
  560. {
  561. // TODO: Add your control notification handler code here
  562. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  563. UpdateData();
  564. char no[100];
  565. memset(no, 0, 100);
  566. strcpy(no, m_id);
  567. g_nSendCode = 35;
  568. g_pMainWnd->ProcessChatMessageRequest2((BYTE*)no, 100);
  569. g_nSendCode = 0;
  570. if (g_bSendOK == 0)
  571. {
  572. return;
  573. }
  574. if (m_pImg)delete m_pImg; m_pImg = NULL;
  575. CRect rc;
  576. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  577. ScreenToClient(rc);
  578. InvalidateRect(rc);
  579. }
  580. void PayOutInput::OnPaint()
  581. {
  582. CPaintDC dc(this); // device context for painting
  583. // TODO: Add your message handler code here
  584. if (m_pImg)
  585. {
  586. CRect rc;
  587. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  588. ScreenToClient(rc);
  589. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
  590. Graphics dcgraph(dc.GetSafeHdc());
  591. Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
  592. dcgraph.DrawImage(m_pImg, destinationRect, 0, 0, m_pImg->GetWidth(), m_pImg->GetHeight(), UnitPixel);
  593. }
  594. // Do not call MyFormView::OnPaint() for painting messages
  595. }
  596. extern void SaveImageToFile(Image *img, CString path);
  597. void PayOutInput::OnLButtonDown(UINT nFlags, CPoint point)
  598. {
  599. // TODO: Add your message handler code here and/or call default
  600. CRect rc;
  601. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  602. ScreenToClient(rc);
  603. if (rc.PtInRect(point) && m_pImg)
  604. {
  605. // ShowPhoto dlg;
  606. // dlg.m_pImg=m_pImg;
  607. // dlg.DoModal();
  608. CString path = g_mainpath + "\\1.jpg";
  609. ::DeleteFile(path); // 删除1.jpg文件;
  610. ::SaveImageToFile(m_pImg, path);
  611. ShellExecute(NULL, _T("open"), path, NULL, NULL, SW_SHOWMAXIMIZED);
  612. }
  613. MyFormView::OnLButtonDown(nFlags, point);
  614. }
  615. void PayOutInput::OnButton2()
  616. {
  617. // TODO: Add your control notification handler code here
  618. g_pMainWnd->OnOutbarNotify("支出报表");
  619. }