Singleincomemoney.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. // Singleincomemoney.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Singleincomemoney.h"
  6. #include "InputMemberno.h"
  7. #include "SelPayType.h"
  8. #include "Login2.h"
  9. #include "SelExpendType.h"
  10. #include "DlgPaymentMethod.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // Singleincomemoney dialog IDC_EDIT3
  18. Singleincomemoney::Singleincomemoney(CWnd* pParent /*=NULL*/)
  19. : CDialog(Singleincomemoney::IDD, pParent)
  20. {
  21. //{{AFX_DATA_INIT(Singleincomemoney)
  22. m_money = _T("");
  23. m_time1 = g_date;
  24. m_ren2 = g_user.name;
  25. m_money1 = _T("");
  26. m_money2 = _T("");
  27. m_money3 = _T("");
  28. m_phone = _T("");
  29. m_sitem = _T("");
  30. m_id = _T("");
  31. m_name = _T("");
  32. //}}AFX_DATA_INIT
  33. }
  34. void Singleincomemoney::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(Singleincomemoney)
  38. DDX_Control(pDX, IDC_LIST1, m_List1);
  39. DDX_Control(pDX, IDC_EDIT2, m_editdate1);
  40. DDX_Control(pDX, IDC_EDIT1, m_editctrl1);
  41. DDX_Text(pDX, IDC_EDIT1, m_money);
  42. DDX_Text(pDX, IDC_EDIT2, m_time1);
  43. DDX_Text(pDX, IDC_EDITren2, m_ren2);
  44. DDX_Text(pDX, IDC_EDITmoney2, m_money1);
  45. DDX_Text(pDX, IDC_EDITmoney3, m_money2);
  46. DDX_Text(pDX, IDC_EDITmoney5, m_money3);
  47. DDX_Text(pDX, IDC_EDITphone, m_phone);
  48. DDX_Text(pDX, IDC_EDITsitem, m_sitem);
  49. DDX_Text(pDX, IDC_EDITid, m_id);
  50. DDX_Text(pDX, IDC_EDITname1, m_name);
  51. //}}AFX_DATA_MAP
  52. }
  53. BEGIN_MESSAGE_MAP(Singleincomemoney, CDialog)
  54. //{{AFX_MSG_MAP(Singleincomemoney)
  55. ON_WM_LBUTTONDOWN()
  56. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  57. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  58. ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // Singleincomemoney message handlers
  63. BOOL Singleincomemoney::OnInitDialog()
  64. {
  65. CDialog::OnInitDialog();
  66. GetDlgItem(IDC_BUTTON1)->EnableWindow(IsHasRights2new(49));
  67. // if(IsHasRights2new(49)==0)((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly ();
  68. // else
  69. ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly();
  70. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  71. m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120;接单点,80");
  72. else
  73. m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120");
  74. m_List1.LoadColumnInfo(300);
  75. // TODO: Add extra initialization here
  76. g_sendhead.bsql = 0;
  77. g_sendhead.code[0] = 197;
  78. g_sendhead.tabcount = 1;
  79. CString filter = "id='" + m_id + "'";
  80. g_pMainWnd->ProcessChatMessageRequest2(filter);
  81. if (g_bSendOK == 0)
  82. {
  83. CDialog::OnCancel();
  84. return 0;
  85. }
  86. DataToArray(&m_List1array);
  87. CenterWindow(g_pMainWnd);
  88. FillGrid();
  89. return TRUE; // return TRUE unless you set the focus to a control
  90. // EXCEPTION: OCX Property Pages should return FALSE
  91. }
  92. void Singleincomemoney::OnOK()
  93. {
  94. // TODO: Add extra validation here
  95. UpdateData();
  96. if (m_money.IsEmpty())
  97. {
  98. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  99. return;
  100. }
  101. if (!CheckDateOK(m_time1))return;
  102. CString m_date = m_time1;
  103. BOOL bexist1 = 0;
  104. BOOL bexist2 = 0;
  105. if (bexist1 == 0)
  106. {
  107. for (int i = 0; i < m_List1array.GetSize(); i++)
  108. {
  109. if (m_List1array.ElementAt(i).ElementAt(0) == m_money)
  110. {
  111. bexist1 = 1;
  112. break;
  113. }
  114. }
  115. }
  116. if (bexist2 == 0)
  117. {
  118. for (int i = 0; i < m_List1array.GetSize(); i++)
  119. {
  120. if (m_List1array.ElementAt(i).ElementAt(1) == m_time1)
  121. {
  122. bexist2 = 1;
  123. break;
  124. }
  125. }
  126. }
  127. if (bexist1 && bexist2)
  128. {
  129. if (AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)
  130. return;
  131. }
  132. CString sql;
  133. CString paytype;
  134. #if 0
  135. SelPayType seltype;
  136. seltype.m_paymoney = m_money;
  137. if (seltype.DoModal() != IDOK)return;
  138. if (seltype.m_radio1 == 0)
  139. paytype = "现金";
  140. else if (seltype.m_radio1 == 1)
  141. paytype = "POS机刷卡";
  142. else if (seltype.m_radio1 == 2)
  143. paytype = "储值卡扣款";
  144. else if (seltype.m_radio1 == 3)
  145. paytype = "积分兑换";
  146. else if (seltype.m_radio1 == 4)
  147. paytype = "银行转账";
  148. #else
  149. CDlgPaymentMethod dlg;
  150. if ( dlg.DoModal() != IDOK )
  151. return;
  152. paytype = dlg.m_strPaymentMethod;
  153. #endif
  154. CString jdd;
  155. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  156. {
  157. SelExpendType dlg;
  158. dlg.m_mode = 3;
  159. if (dlg.DoModal() == IDOK)
  160. jdd = dlg.m_sel;
  161. }
  162. sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s",
  163. m_id, m_money, m_date, m_ren2, paytype, jdd, m_id);
  164. CString m_id = "其它二销:" + m_sitem;
  165. g_sendhead.bsql = 1;
  166. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  167. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  168. GetData();
  169. // CDialog::OnOK();
  170. }
  171. HBRUSH Singleincomemoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  172. {
  173. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  174. // TODO: Change any attributes of the DC here
  175. if (nCtlColor == CTLCOLOR_STATIC)
  176. {
  177. pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
  178. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  179. }
  180. // TODO: Return a different brush if the default is not desired
  181. return hbr;
  182. }
  183. void Singleincomemoney::OnLButtonDown(UINT nFlags, CPoint point)
  184. {
  185. // TODO: Add your message handler code here and/or call default
  186. CDialog::OnLButtonDown(nFlags, point);
  187. }
  188. void Singleincomemoney::GetData()
  189. {
  190. g_sendhead.bsql = 0;
  191. g_sendhead.code[0] = 197;
  192. g_sendhead.tabcount = 1;
  193. CString filter = "id='" + m_id + "'";
  194. g_pMainWnd->ProcessChatMessageRequest2(filter);
  195. if (g_bSendOK == 0)return;
  196. DataToArray(&m_List1array);
  197. FillGrid();
  198. float payed = 0;
  199. for (int i = 0; i < m_List1.GetItemCount(); i++)
  200. {
  201. payed += atof(m_List1.GetItemText(i, 1));
  202. }
  203. m_money2.Format("%0.1f", payed);
  204. m_money3.Format("%0.1f", atof(m_money1) - atof(m_money2));
  205. UpdateData(0);
  206. }
  207. void Singleincomemoney::FillGrid()
  208. {
  209. m_List1.DeleteAllItems2();
  210. int ii = 0;
  211. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  212. int count = 0;
  213. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  214. {
  215. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  216. }
  217. m_List1.m_arLabels.SetSize(count, 1);
  218. ii = count;
  219. m_List1.m_LabelCount = ii;
  220. m_List1.SetItemCountEx(ii);
  221. }
  222. BOOL Singleincomemoney::PreTranslateMessage(MSG* pMsg)
  223. {
  224. // TODO: Add your specialized code here and/or call the base class
  225. if (pMsg->message == WM_KEYDOWN)
  226. {
  227. switch (pMsg->wParam)
  228. {
  229. case VK_RETURN:
  230. return 1;
  231. }
  232. }
  233. return CDialog::PreTranslateMessage(pMsg);
  234. }
  235. void Singleincomemoney::OnButton1()
  236. {
  237. // TODO: Add your control notification handler code here
  238. if (IsHasRights2new(49) == 0)return;
  239. // TODO: Add your control notification handler code here
  240. POSITION pos;
  241. pos = m_List1.GetFirstSelectedItemPosition();
  242. if (pos == NULL)
  243. {
  244. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  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 money = m_List1.GetItemText(iItem, 1);
  251. CString bz = m_List1.GetItemText(iItem, 2) + m_List1.GetItemText(iItem, 3);
  252. CString sql;
  253. sql.Format("delete from singleincomemoney where [autoid]=%d***refresh singleincomemoney%s", atol(id), m_id);
  254. g_sendhead.bsql = 1;
  255. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  256. GetData();
  257. CString str;
  258. str = m_List1.GetItemText(iItem, 3);
  259. str += "删除客人";
  260. str += m_name;
  261. str += m_List1.GetItemText(iItem, 2);
  262. str += "其它二销收款:";
  263. str += money;
  264. WriteLog(_T("普通日志"), _T("删除客人"), g_user.name, str);
  265. }
  266. void Singleincomemoney::OnButton3()
  267. {
  268. // TODO: Add your control notification handler code here
  269. Login2 dlg;
  270. dlg.m_mode = 3;
  271. if (dlg.DoModal() != IDOK)return;
  272. if (IsHasRightsnew2(49, dlg.m_rights) == 0)return;
  273. ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly(0);
  274. }
  275. void Singleincomemoney::OnButton8() // 其它二销打印;
  276. {
  277. // TODO: Add your control notification handler code here
  278. //AfxMessageBox("789");
  279. POSITION pos;
  280. pos = m_List1.GetFirstSelectedItemPosition();
  281. if (pos == NULL)
  282. {
  283. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  284. return;
  285. }
  286. int iItem;
  287. CStringArray array;
  288. array.Add("");
  289. array.Add(g_cominfoarray.ElementAt(0).ElementAt(48));
  290. array.Add("NO." + m_id);
  291. CString str = "地址:" + g_cominfoarray.ElementAt(0).ElementAt(12);
  292. str += " 电话:" + g_cominfoarray.ElementAt(0).ElementAt(11);
  293. array.Add(str);
  294. CString name = m_name;
  295. CString phone = m_phone;
  296. array.Add("客户姓名:" + name);
  297. if (IsHasRights2new(31) == 0)
  298. array.Add("");
  299. else
  300. array.Add("联系电话:" + phone);
  301. CString date;
  302. date.Format("日期:%s年%s月%s日", g_date.Mid(0, 4), g_date.Mid(5, 2), g_date.Mid(8, 2));
  303. array.Add(date);
  304. array.Add(" 收 款 项 目 ");
  305. #if 1 // Jeff 显示打印支付方式;
  306. array.Add(" 支付方式 ");
  307. #endif
  308. array.Add(" 金 额 ");
  309. array.Add(" 开单人 ");
  310. int count = 0;
  311. float money = 0;
  312. while (pos)
  313. {
  314. count++;
  315. if (m_bz != "" && count > 3)break;
  316. if (count > 4)break;
  317. iItem = m_List1.GetNextSelectedItem(pos);
  318. array.Add(m_sitem);
  319. #if 1 // 显示打印支付方式;
  320. array.Add(m_List1.GetItemText(iItem, 4)); // add by Jeff:添加支付方式;
  321. #endif
  322. array.Add(m_List1.GetItemText(iItem, 1));
  323. money += atof(m_List1.GetItemText(iItem, 1));
  324. array.Add(m_ren);
  325. }
  326. if (m_bz != "" && count == 1)
  327. {
  328. array.Add("");
  329. array.Add("");
  330. array.Add("");
  331. array.Add("");
  332. array.Add("");
  333. array.Add("");
  334. array.Add("");
  335. array.Add("");
  336. array.Add(m_bz);
  337. array.Add("");
  338. array.Add("");
  339. array.Add("");
  340. }
  341. if (m_bz != "" && count == 2)
  342. {
  343. array.Add("");
  344. array.Add("");
  345. array.Add("");
  346. array.Add("");
  347. array.Add(m_bz);
  348. array.Add("");
  349. array.Add("");
  350. array.Add("");
  351. }
  352. if (m_bz != "" && count == 3)
  353. {
  354. array.Add(m_bz);
  355. array.Add("");
  356. array.Add("");
  357. array.Add("");
  358. }
  359. if (m_bz != "" && count == 4)
  360. {
  361. array.Add(m_bz);
  362. array.Add("");
  363. array.Add("");
  364. array.Add("");
  365. }
  366. //while(array.GetSize ()<22) array.Add ("");
  367. while (array.GetSize() < 27) array.Add(""); // 显示打印支付方式;
  368. CString smoney;
  369. smoney.Format("%0.1f", money);
  370. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  371. {
  372. str = "付款情况 应付:" + m_money1;
  373. str += " 实付:" + m_money2;
  374. str += " 欠款:" + m_money3;
  375. }
  376. else
  377. {
  378. str = "付款情况 应付:" + m_money1;
  379. str += " 实付:" + m_money2;
  380. str += " 欠款:" + m_money3;
  381. }
  382. array.Add(str);
  383. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  384. {
  385. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  386. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  387. }
  388. else
  389. {
  390. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  391. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  392. }
  393. array.Add(str);
  394. array.Add(g_cominfoarray.ElementAt(0).ElementAt(120));
  395. array.Add(" 收银:" + g_user.name);
  396. array.Add("顾客签名:");
  397. 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∨");
  398. g_pMainWnd->PrintReceipt_02(&array); // 2销收入,应该使用PrintReceipt_01,需要显示支付方式 Jeff
  399. }
  400. /*
  401. insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype]) select [id],[money],[dat],[renyuan2],[paytype] from singleincome where payed is null***update [singleincome] set [payed]=(select sum(cast(money as float)) from [singleincomemoney] where [singleincome].[id]=[singleincomemoney].[id])***update [singleincome] set [balance]=cast(money as float)-cast(payed as float)
  402. */