PayOutInput.cpp 19 KB

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