Singleincomemoney.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // Singleincomemoney dialog IDC_EDIT3
  17. Singleincomemoney::Singleincomemoney(CWnd* pParent /*=NULL*/)
  18. : CDialog(Singleincomemoney::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(Singleincomemoney)
  21. m_money = _T("");
  22. m_time1 = g_date;
  23. m_ren2 = g_user.name;
  24. m_money1 = _T("");
  25. m_money2 = _T("");
  26. m_money3 = _T("");
  27. m_phone = _T("");
  28. m_sitem = _T("");
  29. m_id = _T("");
  30. m_name = _T("");
  31. //}}AFX_DATA_INIT
  32. }
  33. void Singleincomemoney::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CDialog::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(Singleincomemoney)
  37. DDX_Control(pDX, IDC_LIST1, m_List1);
  38. DDX_Control(pDX, IDC_EDIT2, m_editdate1);
  39. DDX_Control(pDX, IDC_EDIT1, m_editctrl1);
  40. DDX_Text(pDX, IDC_EDIT1, m_money);
  41. DDX_Text(pDX, IDC_EDIT2, m_time1);
  42. DDX_Text(pDX, IDC_EDITren2, m_ren2);
  43. DDX_Text(pDX, IDC_EDITmoney2, m_money1);
  44. DDX_Text(pDX, IDC_EDITmoney3, m_money2);
  45. DDX_Text(pDX, IDC_EDITmoney5, m_money3);
  46. DDX_Text(pDX, IDC_EDITphone, m_phone);
  47. DDX_Text(pDX, IDC_EDITsitem, m_sitem);
  48. DDX_Text(pDX, IDC_EDITid, m_id);
  49. DDX_Text(pDX, IDC_EDITname1, m_name);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(Singleincomemoney, CDialog)
  53. //{{AFX_MSG_MAP(Singleincomemoney)
  54. ON_WM_LBUTTONDOWN()
  55. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  56. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  57. ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Singleincomemoney message handlers
  62. BOOL Singleincomemoney::OnInitDialog()
  63. {
  64. CDialog::OnInitDialog();
  65. GetDlgItem(IDC_BUTTON1)->EnableWindow(IsHasRights2new(49));
  66. // if(IsHasRights2new(49)==0)((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly ();
  67. // else
  68. ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly();
  69. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  70. m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120;接单点,80");
  71. else
  72. m_List1.SetHeadings("id,0;金额,80;日期,120;收款人,120;支付方式,120");
  73. m_List1.LoadColumnInfo(300);
  74. // TODO: Add extra initialization here
  75. g_sendhead.bsql = 0;
  76. g_sendhead.code[0] = 197;
  77. g_sendhead.tabcount = 1;
  78. CString filter = "id='" + m_id + "'";
  79. g_pMainWnd->ProcessChatMessageRequest2(filter);
  80. if (g_bSendOK == 0)
  81. {
  82. CDialog::OnCancel();
  83. return 0;
  84. }
  85. DataToArray(&m_List1array);
  86. CenterWindow(g_pMainWnd);
  87. FillGrid();
  88. return TRUE; // return TRUE unless you set the focus to a control
  89. // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91. void Singleincomemoney::OnOK() // 保存按钮 ;
  92. {
  93. UpdateData();
  94. if (m_money.IsEmpty())
  95. {
  96. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  97. return;
  98. }
  99. if (!CheckDateOK(m_time1))return;
  100. CString m_date = m_time1;
  101. BOOL bexist1 = 0;
  102. BOOL bexist2 = 0;
  103. if (bexist1 == 0)
  104. {
  105. for (int i = 0; i < m_List1array.GetSize(); i++)
  106. {
  107. if (m_List1array.ElementAt(i).ElementAt(0) == m_money)
  108. {
  109. bexist1 = 1;
  110. break;
  111. }
  112. }
  113. }
  114. if (bexist2 == 0)
  115. {
  116. for (int i = 0; i < m_List1array.GetSize(); i++)
  117. {
  118. if (m_List1array.ElementAt(i).ElementAt(1) == m_time1)
  119. {
  120. bexist2 = 1;
  121. break;
  122. }
  123. }
  124. }
  125. if (bexist1 && bexist2)
  126. {
  127. if (AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)
  128. return;
  129. }
  130. CString sql;
  131. CString paytype;
  132. SelPayType seltype;
  133. seltype.m_paymoney = m_money;
  134. if (seltype.DoModal() != IDOK)return;
  135. if (seltype.m_radio1 == 0)
  136. paytype = "现金";
  137. else if (seltype.m_radio1 == 1)
  138. paytype = "POS机刷卡";
  139. else if (seltype.m_radio1 == 2)
  140. paytype = "储值卡扣款";
  141. else if (seltype.m_radio1 == 3)
  142. paytype = "积分兑换";
  143. else if (seltype.m_radio1 == 4)
  144. paytype = "银行转账";
  145. #if JEFF_TEST_ON
  146. else if (seltype.m_radio1 == 5)
  147. paytype = "代金券";
  148. #endif
  149. else if(seltype.m_radio1 == 6)
  150. paytype = "支付宝";
  151. else if(seltype.m_radio1 == 7)
  152. paytype = "财付通";
  153. else if(seltype.m_radio1 == 8)
  154. paytype = "微信支付";
  155. else if(seltype.m_radio1 == 9)
  156. paytype = seltype.m_strCustomPayType;
  157. #if JEFF_DELETE_ON // old coding;
  158. CString jdd; // 接单点;
  159. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  160. {
  161. SelExpendType dlg;
  162. dlg.m_mode = 3;
  163. if (dlg.DoModal() == IDOK)
  164. jdd = dlg.m_sel;
  165. }
  166. sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s",
  167. m_id, m_money, m_date, m_ren2, paytype, jdd, m_id);
  168. CString m_id = "其它二销:" + m_sitem;
  169. if (paytype == "储值卡扣款")
  170. {
  171. if (seltype.m_bChildMoneyCard)
  172. {
  173. sql += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')";
  174. sql += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno;
  175. }
  176. else
  177. {
  178. sql += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')";
  179. sql += "***refresh balance memberreg3"; sql += seltype.m_cardno;
  180. }
  181. }
  182. else if (paytype == "积分兑换")
  183. {
  184. CString point;
  185. float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0;
  186. point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate));
  187. sql += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')";
  188. sql += "***refresh balance memberreg2";
  189. sql += seltype.m_cardno;
  190. }
  191. g_sendhead.bsql = 1;
  192. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  193. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  194. GetData();
  195. // CDialog::OnOK();
  196. #else
  197. CString strBranchName = seltype.m_branch; // 当前选择的分店名;
  198. CString strOurBranchName = GetNameFromDomain(g_domain); // 本店店名;
  199. // 无分店,非集团版;
  200. // 选择的分店与连接的分店相同;
  201. // 连接的分店空且分店名与本店名相同;
  202. // 使用集团版,但只有一家店;
  203. // 使用的数据和要保存的数据都属于一家分店的情况;
  204. if ( strBranchName == _T("") || strBranchName == g_branchname ||
  205. (g_branchname == "" && strBranchName == strOurBranchName))
  206. {
  207. CString jdd; // 接单点;
  208. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  209. {
  210. SelExpendType dlg;
  211. dlg.m_mode = 3;
  212. if (dlg.DoModal() == IDOK)
  213. jdd = dlg.m_sel;
  214. }
  215. sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s",
  216. m_id, m_money, m_date, m_ren2, paytype, jdd, m_id);
  217. CString m_id = "其它二销:" + m_sitem;
  218. if (paytype == "储值卡扣款")
  219. {
  220. if (seltype.m_bChildMoneyCard)
  221. {
  222. sql += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')";
  223. sql += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno;
  224. }
  225. else
  226. {
  227. sql += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + m_date + "')";
  228. sql += "***refresh balance memberreg3"; sql += seltype.m_cardno;
  229. }
  230. // 其他消费短信;
  231. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // 122=msgcheck16
  232. {
  233. CString content, timestamp;
  234. CString m_phone = seltype.m_phone;;
  235. content.Format("%s您好,您本次使用现金卡消费%s元,余额:%d元", seltype.m_name, m_money, seltype.m_money - atoi(m_money));
  236. timestamp = "msgtimestamp";
  237. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  238. {
  239. int count = GetLengthEx(content) / MSG_LENGTH;
  240. if (GetLengthEx(content) % MSG_LENGTH)
  241. count++;
  242. CString scount;
  243. scount.Format("%d", count);
  244. CString sql2 = _T("");
  245. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  246. sql += _T("***");
  247. sql += _T("***") + sql2;
  248. }
  249. }
  250. }
  251. else if (paytype == "积分兑换")
  252. {
  253. CString point;
  254. float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0;
  255. point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate));
  256. sql += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')";
  257. sql += "***refresh balance memberreg2";
  258. sql += seltype.m_cardno;
  259. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // msgcheck16
  260. {
  261. CString content, timestamp;
  262. CString m_phone = seltype.m_phone;;
  263. float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0;
  264. int point = (int)(atof(m_money) / rate + 0.5);
  265. content.Format("%s您好,您本次使用积分%d分,余额:%d分", seltype.m_name, point, seltype.m_point - point);
  266. timestamp = "msgtimestamp";
  267. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  268. {
  269. int count = GetLengthEx(content) / MSG_LENGTH;
  270. if (GetLengthEx(content) % MSG_LENGTH)
  271. count++;
  272. CString scount;
  273. scount.Format("%d", count);
  274. CString sql2 = _T("");
  275. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  276. sql += _T("***");
  277. sql += _T("***") + sql2;
  278. }
  279. }
  280. }
  281. g_sendhead.bsql = 1;
  282. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  283. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  284. GetData();
  285. }
  286. else
  287. {
  288. CString sql3;
  289. BOOL bBranchModifyBak = g_bBranchModify;
  290. CString strbranchnameBak = g_branchname;
  291. CString strbranchipBak = g_branchip;
  292. CString strCurbranch;
  293. if (g_branchname != "")
  294. strCurbranch = g_branchname;
  295. else
  296. strCurbranch = strOurBranchName;
  297. // 逻辑问题:这里不能显示接单点与id组合的字符串,因为表singleincome的是自增id;
  298. //CString m_id2 = strCurbranch + m_id;
  299. CString jdd; // 接单点;
  300. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  301. {
  302. SelExpendType dlg;
  303. dlg.m_mode = 3;
  304. if (dlg.DoModal() == IDOK)
  305. jdd = dlg.m_sel;
  306. }
  307. sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s",
  308. m_id, m_money, m_date, m_ren2, paytype, jdd, m_id);
  309. CString strSQL = _T("");
  310. CString id = strCurbranch + _T("其它二销:") + m_sitem;
  311. if (paytype == "储值卡扣款")
  312. {
  313. if (seltype.m_bChildMoneyCard)
  314. {
  315. strSQL += "***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + id + "','" + m_money + "','" + m_date + "')";
  316. strSQL += "***refresh balance memberreg4" + seltype.m_parentno + ";" + seltype.m_cardno;
  317. }
  318. else
  319. {
  320. strSQL += "***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('" + seltype.m_cardno + "','" + id + "','" + m_money + "','" + m_date + "')";
  321. strSQL += "***refresh balance memberreg3";
  322. strSQL += seltype.m_cardno;
  323. }
  324. // 其他消费短信;
  325. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // 122=msgcheck16
  326. {
  327. CString content, timestamp;
  328. CString m_phone = seltype.m_phone;;
  329. content.Format("%s您好,您本次使用现金卡消费%s元,余额:%d元", seltype.m_name, m_money, seltype.m_money - atoi(m_money));
  330. timestamp = "msgtimestamp";
  331. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  332. {
  333. int count = GetLengthEx(content) / MSG_LENGTH;
  334. if (GetLengthEx(content) % MSG_LENGTH)
  335. count++;
  336. CString scount;
  337. scount.Format("%d", count);
  338. CString sql2 = _T("");
  339. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  340. strSQL += _T("***");
  341. strSQL += _T("***") + sql2;
  342. }
  343. }
  344. }
  345. else if (paytype == "积分兑换")
  346. {
  347. CString point;
  348. float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0;
  349. point.Format("%d", (int)(atof(m_money)*GetPointScale2() / rate));
  350. strSQL += "***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + seltype.m_cardno + "','" + m_id + "','" + m_money + "','" + point + "','" + g_date + "')";
  351. strSQL += "***refresh balance memberreg2";
  352. strSQL += seltype.m_cardno;
  353. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122))) // msgcheck16
  354. {
  355. CString content, timestamp;
  356. CString m_phone = seltype.m_phone;;
  357. float rate = atof(g_cominfoarray.ElementAt(0).ElementAt(38)) / 100.0;
  358. int point = (int)(atof(m_money) / rate + 0.5);
  359. content.Format("%s您好,您本次使用积分%d分,余额:%d分", seltype.m_name, point, seltype.m_point - point);
  360. timestamp = "msgtimestamp";
  361. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  362. {
  363. int count = GetLengthEx(content) / MSG_LENGTH;
  364. if (GetLengthEx(content) % MSG_LENGTH)
  365. count++;
  366. CString scount;
  367. scount.Format("%d", count);
  368. CString sql2 = _T("");
  369. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  370. strSQL += _T("***");
  371. strSQL += _T("***") + sql2;
  372. }
  373. }
  374. }
  375. // 断开软件选择的分店连接,获取选择的接单点分店ip;
  376. // 连接接单点分店并写入数据到接单点数据库;
  377. g_pMainWnd->OnDisconnect();
  378. g_branchip = GetIP(strBranchName);
  379. g_pMainWnd->OnDisconnect();
  380. g_branchname = strBranchName;
  381. g_bBranchModify = 1;
  382. g_sendhead.bsql = 1;
  383. strSQL.TrimLeft("***");
  384. g_pMainWnd->ProcessChatMessageRequest2(strSQL);
  385. if (g_bSendOK == 0)return;
  386. // 恢复软件选择的分店连接;
  387. // 并写入数据;
  388. g_pMainWnd->OnDisconnect();
  389. g_bBranchModify = 0;
  390. g_branchip = g_branchname = "";
  391. g_bBranchModify = bBranchModifyBak;
  392. g_branchname = strbranchnameBak;
  393. g_branchip = strbranchipBak;
  394. g_sendhead.bsql = 1;
  395. g_pMainWnd->ProcessChatMessageRequest2(sql);
  396. if (g_bSendOK == 0)return;
  397. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  398. GetData();
  399. }
  400. #endif
  401. }
  402. HBRUSH Singleincomemoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  403. {
  404. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  405. // TODO: Change any attributes of the DC here
  406. if (nCtlColor == CTLCOLOR_STATIC)
  407. {
  408. pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
  409. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  410. }
  411. // TODO: Return a different brush if the default is not desired
  412. return hbr;
  413. }
  414. void Singleincomemoney::OnLButtonDown(UINT nFlags, CPoint point)
  415. {
  416. CDialog::OnLButtonDown(nFlags, point);
  417. }
  418. void Singleincomemoney::GetData()
  419. {
  420. g_sendhead.bsql = 0;
  421. g_sendhead.code[0] = 197;
  422. g_sendhead.tabcount = 1;
  423. CString filter = "id='" + m_id + "'";
  424. g_pMainWnd->ProcessChatMessageRequest2(filter);
  425. if (g_bSendOK == 0)return;
  426. DataToArray(&m_List1array);
  427. FillGrid();
  428. float payed = 0;
  429. for (int i = 0; i < m_List1.GetItemCount(); i++)
  430. {
  431. payed += atof(m_List1.GetItemText(i, 1));
  432. }
  433. m_money2.Format("%0.1f", payed);
  434. m_money3.Format("%0.1f", atof(m_money1) - atof(m_money2));
  435. UpdateData(0);
  436. }
  437. void Singleincomemoney::FillGrid()
  438. {
  439. m_List1.DeleteAllItems2();
  440. int ii = 0;
  441. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  442. int count = 0;
  443. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  444. {
  445. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  446. }
  447. m_List1.m_arLabels.SetSize(count, 1);
  448. ii = count;
  449. m_List1.m_LabelCount = ii;
  450. m_List1.SetItemCountEx(ii);
  451. }
  452. BOOL Singleincomemoney::PreTranslateMessage(MSG* pMsg)
  453. {
  454. if (pMsg->message == WM_KEYDOWN)
  455. {
  456. switch (pMsg->wParam)
  457. {
  458. case VK_RETURN:
  459. return 1;
  460. }
  461. }
  462. return CDialog::PreTranslateMessage(pMsg);
  463. }
  464. void Singleincomemoney::OnButton1() // 删除按钮;
  465. {
  466. if (IsHasRights2new(49) == 0)return;
  467. POSITION pos;
  468. pos = m_List1.GetFirstSelectedItemPosition();
  469. if (pos == NULL)
  470. {
  471. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  472. return;
  473. }
  474. if (AfxMessageBox("是否删除此项目?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  475. int iItem = m_List1.GetNextSelectedItem(pos);
  476. CString id = m_List1.GetItemText(iItem, 0);
  477. CString money = m_List1.GetItemText(iItem, 1);
  478. CString bz = m_List1.GetItemText(iItem, 2) + m_List1.GetItemText(iItem, 3);
  479. CString sql;
  480. sql.Format("delete from singleincomemoney where [autoid]=%d***refresh singleincomemoney%s", atol(id), m_id);
  481. g_sendhead.bsql = 1;
  482. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  483. GetData();
  484. CString str;
  485. str = m_List1.GetItemText(iItem, 3);
  486. str += "删除客人";
  487. str += m_name;
  488. str += m_List1.GetItemText(iItem, 2);
  489. str += "其它二销收款:";
  490. str += money;
  491. WriteLog(_T("其它二销"), str);
  492. }
  493. void Singleincomemoney::OnButton3() // 更改按钮;
  494. {
  495. // TODO: Add your control notification handler code here
  496. Login2 dlg;
  497. dlg.m_mode = 3;
  498. if (dlg.DoModal() != IDOK)return;
  499. if (IsHasRightsnew2(49, dlg.m_rights) == 0)return;
  500. ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly(0);
  501. }
  502. void Singleincomemoney::OnButton8() // 打单按钮;
  503. {
  504. // TODO: Add your control notification handler code here
  505. //AfxMessageBox("789");
  506. POSITION pos;
  507. pos = m_List1.GetFirstSelectedItemPosition();
  508. if (pos == NULL)
  509. {
  510. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  511. return;
  512. }
  513. int iItem;
  514. CStringArray array;
  515. array.Add("");
  516. array.Add(g_cominfoarray.ElementAt(0).ElementAt(48));
  517. array.Add("NO." + m_id);
  518. CString str = "地址:" + g_cominfoarray.ElementAt(0).ElementAt(12);
  519. str += " 电话:" + g_cominfoarray.ElementAt(0).ElementAt(11);
  520. array.Add(str);
  521. CString name = m_name;
  522. CString phone = m_phone;
  523. array.Add("客户姓名:" + name);
  524. if (IsHasRights2new(31) == 0)
  525. array.Add("");
  526. else
  527. array.Add("联系电话:" + phone);
  528. CString date;
  529. date.Format("日期:%s年%s月%s日", g_date.Mid(0, 4), g_date.Mid(5, 2), g_date.Mid(8, 2));
  530. array.Add(date);
  531. array.Add(" 收 款 项 目 ");
  532. // Jeff 显示打印支付方式;
  533. int isSmall = atoi(g_cominfoarray.ElementAt(0).ElementAt(87));//小单
  534. if(isSmall == 0)
  535. array.Add(" 支付方式 ");
  536. array.Add(" 金 额 ");
  537. array.Add(" 开单人 ");
  538. int count = 0;
  539. float money = 0;
  540. while (pos)
  541. {
  542. count++;
  543. if (m_bz != "" && count > 3)break;
  544. if (count > 4)break;
  545. iItem = m_List1.GetNextSelectedItem(pos);
  546. array.Add(m_sitem);
  547. // 显示打印支付方式;
  548. if(isSmall == 0)
  549. array.Add(m_List1.GetItemText(iItem, 4)); // add by Jeff:添加支付方式;
  550. array.Add(m_List1.GetItemText(iItem, 1));
  551. money += atof(m_List1.GetItemText(iItem, 1));
  552. array.Add(m_ren);
  553. }
  554. if (m_bz != "" && count == 1)
  555. {
  556. array.Add("");
  557. array.Add("");
  558. array.Add("");
  559. array.Add("");
  560. array.Add("");
  561. array.Add("");
  562. array.Add("");
  563. array.Add("");
  564. array.Add(m_bz);
  565. array.Add("");
  566. array.Add("");
  567. array.Add("");
  568. }
  569. if (m_bz != "" && count == 2)
  570. {
  571. array.Add("");
  572. array.Add("");
  573. array.Add("");
  574. array.Add("");
  575. array.Add(m_bz);
  576. array.Add("");
  577. array.Add("");
  578. array.Add("");
  579. }
  580. if (m_bz != "" && count == 3)
  581. {
  582. array.Add(m_bz);
  583. array.Add("");
  584. array.Add("");
  585. array.Add("");
  586. }
  587. if (m_bz != "" && count == 4)
  588. {
  589. array.Add(m_bz);
  590. array.Add("");
  591. array.Add("");
  592. array.Add("");
  593. }
  594. //while(array.GetSize ()<22) array.Add ("");
  595. while (array.GetSize() < 27) array.Add(""); // 显示打印支付方式;
  596. CString smoney;
  597. smoney.Format("%0.1f", money);
  598. if(isSmall == 0)//小单
  599. {
  600. str = "付款情况 应付:" + m_money1;
  601. str += " 实付:" + m_money2;
  602. str += " 欠款:" + m_money3;
  603. }
  604. else
  605. {
  606. str = "付款情况 应付:" + m_money1;
  607. str += " 实付:" + m_money2;
  608. str += " 欠款:" + m_money3;
  609. }
  610. array.Add(str);
  611. if(isSmall == 0)//小单
  612. {
  613. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  614. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  615. }
  616. else
  617. {
  618. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元", \
  619. GetHMoney(GetW(smoney)), GetHMoney(GetK(smoney)), GetHMoney(GetB(smoney)), GetHMoney(GetS(smoney)), GetHMoney(GetG(smoney)));
  620. }
  621. array.Add(str);
  622. array.Add(g_cominfoarray.ElementAt(0).ElementAt(120));
  623. array.Add(" 收银:" + g_user.name);
  624. array.Add("顾客签名:");
  625. 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∨");
  626. g_pMainWnd->PrintReceipt_02(&array); // 2销收入,应该使用PrintReceipt_01,需要显示支付方式 Jeff
  627. }
  628. /*
  629. 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)
  630. */