Singleincomemoney.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. // TODO: Add extra validation here
  94. UpdateData();
  95. if(m_money.IsEmpty ())
  96. {
  97. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  98. return;
  99. }
  100. if(!CheckDateOK(m_time1))return;
  101. CString m_date=m_time1;
  102. BOOL bexist1=0;
  103. BOOL bexist2=0;
  104. if(bexist1==0)
  105. {
  106. for(int i=0; i<m_List1array.GetSize (); i++)
  107. {
  108. if(m_List1array.ElementAt (i).ElementAt (0)==m_money)
  109. {
  110. bexist1=1;
  111. break;
  112. }
  113. }
  114. }
  115. if(bexist2==0)
  116. {
  117. for(int i=0; i<m_List1array.GetSize (); i++)
  118. {
  119. if(m_List1array.ElementAt (i).ElementAt (1)==m_time1)
  120. {
  121. bexist2=1;
  122. break;
  123. }
  124. }
  125. }
  126. if(bexist1 && bexist2)
  127. {
  128. if(AfxMessageBox("已有相似的记录, 确认没有重复吗? 是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)
  129. return;
  130. }
  131. CString sql;
  132. CString paytype;
  133. SelPayType seltype;
  134. seltype.m_paymoney=m_money;
  135. if(seltype.DoModal ()!=IDOK)return;
  136. if(seltype.m_radio1==0)
  137. paytype="现金";
  138. else if(seltype.m_radio1==1)
  139. paytype="POS机刷卡";
  140. else if(seltype.m_radio1==2)
  141. paytype="储值卡扣款";
  142. else if(seltype.m_radio1==3)
  143. paytype="积分兑换";
  144. else if(seltype.m_radio1==4)
  145. paytype="银行转账";
  146. CString jdd;
  147. if(atoi(g_cominfoarray.ElementAt(0).ElementAt(115)))
  148. {
  149. SelExpendType dlg;
  150. dlg.m_mode=3;
  151. if(dlg.DoModal()==IDOK)
  152. jdd=dlg.m_sel;
  153. }
  154. sql.Format("insert into [singleincomemoney]([id],[money],[date],[clerk],[paytype],[time],[jdd])values('%s','%s','%s','%s','%s','curtimereplace','%s')***refresh singleincomemoney%s",
  155. m_id, m_money, m_date, m_ren2, paytype, jdd, m_id);
  156. CString m_id="其它二销:"+m_sitem;
  157. if(paytype=="储值卡扣款")
  158. {
  159. if(seltype.m_bChildMoneyCard)
  160. {
  161. sql+="***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  162. sql+="***refresh balance memberreg4"+seltype.m_parentno+";"+seltype.m_cardno;
  163. }
  164. else
  165. {
  166. sql+="***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  167. sql+="***refresh balance memberreg3";sql+=seltype.m_cardno;
  168. }
  169. }
  170. else if(paytype=="积分兑换")
  171. {
  172. CString point;
  173. float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
  174. point.Format ("%d", (int)(atof(m_money)*GetPointScale2()/rate));
  175. sql+="***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+point+"','"+g_date+"')";
  176. sql+="***refresh balance memberreg2";
  177. sql+=seltype.m_cardno;
  178. }
  179. g_sendhead.bsql=1;
  180. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  181. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  182. GetData();
  183. // CDialog::OnOK();
  184. }
  185. HBRUSH Singleincomemoney::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  186. {
  187. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  188. // TODO: Change any attributes of the DC here
  189. if (nCtlColor==CTLCOLOR_STATIC)
  190. {
  191. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  192. return (HBRUSH)::GetStockObject(NULL_BRUSH); // 设置背景色
  193. }
  194. // TODO: Return a different brush if the default is not desired
  195. return hbr;
  196. }
  197. void Singleincomemoney::OnLButtonDown(UINT nFlags, CPoint point)
  198. {
  199. // TODO: Add your message handler code here and/or call default
  200. CDialog::OnLButtonDown(nFlags, point);
  201. }
  202. void Singleincomemoney::GetData()
  203. {
  204. g_sendhead.bsql=0;
  205. g_sendhead.code[0]=197;
  206. g_sendhead.tabcount=1;
  207. CString filter="id='"+m_id+"'";
  208. g_pMainWnd->ProcessChatMessageRequest2(filter);
  209. if(g_bSendOK==0)return;
  210. DataToArray( &m_List1array);
  211. FillGrid();
  212. float payed=0;
  213. for(int i=0; i<m_List1.GetItemCount(); i++)
  214. {
  215. payed+=atof(m_List1.GetItemText(i, 1));
  216. }
  217. m_money2.Format("%0.1f", payed);
  218. m_money3.Format("%0.1f", atof(m_money1)-atof(m_money2));
  219. UpdateData(0);
  220. }
  221. void Singleincomemoney::FillGrid()
  222. {
  223. m_List1.DeleteAllItems2 ();
  224. int ii=0;
  225. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  226. int count=0;
  227. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  228. {
  229. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  230. }
  231. m_List1.m_arLabels.SetSize(count, 1);
  232. ii=count;
  233. m_List1.m_LabelCount=ii;
  234. m_List1.SetItemCountEx (ii);
  235. }
  236. BOOL Singleincomemoney::PreTranslateMessage(MSG* pMsg)
  237. {
  238. // TODO: Add your specialized code here and/or call the base class
  239. if(pMsg->message==WM_KEYDOWN)
  240. {
  241. switch (pMsg->wParam)
  242. {
  243. case VK_RETURN:
  244. return 1;
  245. }
  246. }
  247. return CDialog::PreTranslateMessage(pMsg);
  248. }
  249. void Singleincomemoney::OnButton1()
  250. {
  251. // TODO: Add your control notification handler code here
  252. if(IsHasRights2new(49)==0)return;
  253. // TODO: Add your control notification handler code here
  254. POSITION pos;
  255. pos=m_List1.GetFirstSelectedItemPosition();
  256. if(pos==NULL)
  257. {
  258. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  259. return;
  260. }
  261. if(AfxMessageBox("是否删除此项目?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  262. int iItem=m_List1.GetNextSelectedItem(pos);
  263. CString id=m_List1.GetItemText (iItem, 0);
  264. CString money=m_List1.GetItemText (iItem, 1);
  265. CString bz=m_List1.GetItemText (iItem, 2)+m_List1.GetItemText (iItem, 3);
  266. CString sql;
  267. sql.Format ("delete from singleincomemoney where [autoid]=%d***refresh singleincomemoney%s", atol(id), m_id);
  268. g_sendhead.bsql=1;
  269. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  270. GetData();
  271. CString str;
  272. str=m_List1.GetItemText (iItem, 3);
  273. str+="删除客人";
  274. str+=m_name;
  275. str+=m_List1.GetItemText (iItem, 2);
  276. str+="其它二销收款:";
  277. str+=money;
  278. WriteLog(str);
  279. }
  280. void Singleincomemoney::OnButton3()
  281. {
  282. // TODO: Add your control notification handler code here
  283. Login2 dlg;
  284. dlg.m_mode=3;
  285. if(dlg.DoModal ()!=IDOK)return;
  286. if(IsHasRightsnew2(49, dlg.m_rights)==0)return;
  287. ((CEdit*)GetDlgItem(IDC_EDIT2))->SetReadOnly (0);
  288. }
  289. void Singleincomemoney::OnButton8() // 其它二销打印;
  290. {
  291. // TODO: Add your control notification handler code here
  292. //AfxMessageBox("789");
  293. POSITION pos;
  294. pos=m_List1.GetFirstSelectedItemPosition();
  295. if(pos==NULL)
  296. {
  297. AfxMessageBox("请先选中您要打单的项目!", MB_ICONINFORMATION);
  298. return;
  299. }
  300. int iItem;
  301. CStringArray array;
  302. array.Add ("");
  303. array.Add (g_cominfoarray.ElementAt (0).ElementAt (48));
  304. array.Add ("NO."+m_id);
  305. CString str="地址:"+g_cominfoarray.ElementAt (0).ElementAt (12);
  306. str+=" 电话:"+g_cominfoarray.ElementAt (0).ElementAt (11);
  307. array.Add (str);
  308. CString name=m_name;
  309. CString phone=m_phone;
  310. array.Add ("客户姓名:"+name);
  311. if(IsHasRights2new(31)==0)
  312. array.Add ("");
  313. else
  314. array.Add ("联系电话:"+phone);
  315. CString date;
  316. date.Format ("日期:%s年%s月%s日", g_date.Mid (0,4), g_date.Mid (5,2), g_date.Mid (8,2));
  317. array.Add (date);
  318. array.Add (" 收 款 项 目 ");
  319. #if 1 // Jeff 显示打印支付方式;
  320. array.Add(" 支付方式 ");
  321. #endif
  322. array.Add (" 金 额 ");
  323. array.Add (" 开单人 ");
  324. int count=0;
  325. float money=0;
  326. while (pos)
  327. {
  328. count++;
  329. if(m_bz!="" && count>3)break;
  330. if(count>4)break;
  331. iItem = m_List1.GetNextSelectedItem(pos);
  332. array.Add (m_sitem);
  333. #if 1 // 显示打印支付方式;
  334. array.Add(m_List1.GetItemText(iItem,4)); // add by Jeff:添加支付方式;
  335. #endif
  336. array.Add (m_List1.GetItemText (iItem, 1));
  337. money+=atof(m_List1.GetItemText (iItem, 1));
  338. array.Add (m_ren);
  339. }
  340. if(m_bz!="" && count==1)
  341. {
  342. array.Add ("");
  343. array.Add ("");
  344. array.Add ("");
  345. array.Add ("");
  346. array.Add ("");
  347. array.Add ("");
  348. array.Add ("");
  349. array.Add ("");
  350. array.Add (m_bz);
  351. array.Add ("");
  352. array.Add ("");
  353. array.Add ("");
  354. }
  355. if(m_bz!="" && count==2)
  356. {
  357. array.Add ("");
  358. array.Add ("");
  359. array.Add ("");
  360. array.Add ("");
  361. array.Add (m_bz);
  362. array.Add ("");
  363. array.Add ("");
  364. array.Add ("");
  365. }
  366. if(m_bz!="" && count==3)
  367. {
  368. array.Add (m_bz);
  369. array.Add ("");
  370. array.Add ("");
  371. array.Add ("");
  372. }
  373. if(m_bz!="" && count==4)
  374. {
  375. array.Add (m_bz);
  376. array.Add ("");
  377. array.Add ("");
  378. array.Add ("");
  379. }
  380. //while(array.GetSize ()<22) array.Add ("");
  381. while(array.GetSize()<27) array.Add(""); // 显示打印支付方式;
  382. CString smoney;
  383. smoney.Format ("%0.1f", money);
  384. if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  385. {
  386. str="付款情况 应付:"+m_money1;
  387. str+=" 实付:"+m_money2;
  388. str+=" 欠款:"+m_money3;
  389. }
  390. else
  391. {
  392. str="付款情况 应付:"+m_money1;
  393. str+=" 实付:"+m_money2;
  394. str+=" 欠款:"+m_money3;
  395. }
  396. array.Add (str);
  397. if(atoi(g_cominfoarray.ElementAt(0).ElementAt(87)))//小单
  398. {
  399. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\
  400. GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney)));
  401. }
  402. else
  403. {
  404. str.Format("合计人民币(大写): %s 萬 %s 仟 %s 佰 %s 拾 %s 元",\
  405. GetHMoney(GetW(smoney)),GetHMoney(GetK(smoney)),GetHMoney(GetB(smoney)),GetHMoney(GetS(smoney)),GetHMoney(GetG(smoney)));
  406. }
  407. array.Add (str);
  408. array.Add (g_cominfoarray.ElementAt (0).ElementAt (120));
  409. array.Add (" 收银:"+g_user.name);
  410. array.Add ("顾客签名:");
  411. 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∨");
  412. g_pMainWnd->PrintReceipt_01(&array); // 2销收入,应该使用PrintReceipt_01,需要显示支付方式 Jeff
  413. }
  414. /*
  415. 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)
  416. */