AddIncome.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // AddIncome.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "AddIncome.h"
  6. #include "SPLBDlg.h"
  7. #include "SelPayType.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // AddIncome dialog
  15. AddIncome::AddIncome(CWnd* pParent /*=NULL*/)
  16. : CDialog(AddIncome::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(AddIncome)
  19. m_bz = _T("");
  20. m_date = g_date;
  21. m_money = _T("");
  22. m_name = _T("");
  23. m_renyuan1 = _T("");
  24. m_renyuan2 = g_user.name;
  25. m_phone = _T("");
  26. m_count = _T("");
  27. //}}AFX_DATA_INIT
  28. }
  29. void AddIncome::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(AddIncome)
  33. DDX_Control(pDX, IDC_LIST1, m_List1);
  34. DDX_Control(pDX, IDC_COMBO4, m_combobz);
  35. DDX_Control(pDX, IDC_COMBO2, m_comboren);
  36. DDX_Control(pDX, IDC_EDITmoney, m_editctrl1);
  37. DDX_Text(pDX, IDC_EDITbz, m_bz);
  38. DDV_MaxChars(pDX, m_bz, 1000);
  39. DDX_Text(pDX, IDC_EDITdate, m_date);
  40. DDX_Text(pDX, IDC_EDITmoney, m_money);
  41. DDX_Text(pDX, IDC_EDITname, m_name);
  42. DDX_Text(pDX, IDC_EDITrenyuan1, m_renyuan1);
  43. DDX_Text(pDX, IDC_EDITrenyuan2, m_renyuan2);
  44. DDX_Text(pDX, IDC_EDITphone, m_phone);
  45. DDX_Text(pDX, IDC_EDITcount, m_count);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(AddIncome, CDialog)
  49. //{{AFX_MSG_MAP(AddIncome)
  50. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  51. ON_CBN_DROPDOWN(IDC_COMBOname, OnDropdownCOMBOname)
  52. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  53. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // AddIncome message handlers
  58. BOOL AddIncome::OnInitDialog()
  59. {
  60. CDialog::OnInitDialog();
  61. // TODO: Add extra initialization here
  62. int i = 0;
  63. for( i=0; i<g_userarray.GetSize (); i++)
  64. m_comboren.AddString (g_userarray.ElementAt (i).ElementAt (1));
  65. for( i=0; i<expendtypearray->GetSize (); i++)
  66. {
  67. m_combobz.AddString (expendtypearray->ElementAt (i).ElementAt (0));
  68. }
  69. m_combobz.AddString ("摄影二销");
  70. m_combobz.AddString ("化妆二销");
  71. m_combobz.AddString ("选片二销");
  72. if(m_combobz.FindString (0, m_sale2type)==-1)
  73. m_combobz.AddString (m_sale2type);
  74. m_combobz.SetCurSel (m_combobz.FindString (0, m_sale2type));
  75. m_comboren.AddString (m_renyuan3);
  76. m_comboren.SetCurSel (m_comboren.FindString (0, m_renyuan3));
  77. for( i=0; i<itemarray->GetSize(); i++)
  78. {
  79. if(m_List1.GetCount()%2)
  80. m_List1.AddEntry( itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  81. else
  82. m_List1.AddEntry( itemarray->ElementAt(i).ElementAt(0) , g_gridcol2, m_List1.GetCount());
  83. }
  84. m_List1.Invalidate ();
  85. SetMySel();
  86. return TRUE; // return TRUE unless you set the focus to a control
  87. // EXCEPTION: OCX Property Pages should return FALSE
  88. }
  89. void AddIncome::OnOK()
  90. {
  91. // TODO: Add extra validation here
  92. UpdateData();
  93. m_phone.TrimLeft();
  94. m_phone.TrimRight();
  95. if(!m_phone.IsEmpty ())
  96. {
  97. if(m_phone.Left (1)=="1")
  98. {
  99. if(CheckPhoneType(m_phone)==-1)
  100. {
  101. AfxMessageBox("手机号码:"+m_phone+"错误!", MB_ICONINFORMATION);
  102. return;
  103. }
  104. }
  105. }
  106. else
  107. return;
  108. int pos=m_comboren.GetCurSel ();
  109. if(pos==-1)
  110. {
  111. AfxMessageBox("请填写开单人!", MB_ICONINFORMATION);
  112. return;
  113. }
  114. m_comboren.GetLBText (pos, m_renyuan3);
  115. pos=m_combobz.GetCurSel();
  116. if(pos==-1)
  117. {
  118. AfxMessageBox("请选择正确的二销类别!", MB_ICONINFORMATION);
  119. return;
  120. }
  121. m_combobz.GetLBText (pos, m_sale2type);
  122. if(m_name=="")
  123. {
  124. AfxMessageBox("请选择正确的二销项目!", MB_ICONINFORMATION);
  125. return;
  126. }
  127. m_renyuan1.TrimLeft();
  128. m_renyuan1.TrimRight();
  129. if(m_renyuan1=="")return;
  130. CString strRes1;
  131. GetFirstLetter(m_renyuan1, strRes1);
  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. CString sql;
  145. if(m_id.IsEmpty ())
  146. sql.Format ("insert into singleincome([name],[phone],[money],[dat],[renyuan1],[renyuan2],[renyuan3],[sale2type],[bz],[paytype],[pinyin],[payed],[balance],[count])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','0','%s','%s')",m_name,m_phone,m_money,m_date,m_renyuan1,m_renyuan2,m_renyuan3,m_sale2type,m_bz,paytype,strRes1,m_money,m_count);
  147. else
  148. {
  149. sql.Format ("update singleincome set [name]='%s',[phone]='%s',[money]='%s',[renyuan1]='%s',[renyuan3]='%s',[sale2type]='%s',[bz]='%s',[pinyin]='%s',[count]='%s' where [id]=%d", m_name,m_phone,m_money,m_renyuan1,m_renyuan3,m_sale2type,m_bz, strRes1,m_count,atoi(m_id));
  150. sql+="***refresh singleincomemoney"+m_id;
  151. }
  152. /* CString m_id="其它二销:"+m_name;
  153. if(paytype=="储值卡扣款")
  154. {
  155. if(seltype.m_bChildMoneyCard)
  156. {
  157. sql+="***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  158. sql+="***refresh balance memberreg4"+seltype.m_parentno+";"+seltype.m_cardno;
  159. }
  160. else
  161. {
  162. sql+="***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  163. sql+="***refresh balance memberreg3";sql+=seltype.m_cardno;
  164. }
  165. }
  166. else if(paytype=="积分兑换")
  167. {
  168. CString point;
  169. float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
  170. point.Format ("%d", (int)(atof(m_money)*GetPointScale2()/rate));
  171. sql+="***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+point+"','"+g_date+"')";
  172. sql+="***refresh balance memberreg2";
  173. sql+=seltype.m_cardno;
  174. }*/
  175. g_sendhead.bsql=1;
  176. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  177. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  178. CDialog::OnOK();
  179. }
  180. void AddIncome::OnButton1()
  181. {
  182. // TODO: Add your control notification handler code here
  183. SPLBDlg dlg;
  184. dlg.m_mode=6;
  185. dlg.DoModal ();
  186. g_sendhead.bsql=0;
  187. g_sendhead.code[0]=160;
  188. g_sendhead.tabcount=1;
  189. g_pMainWnd->ProcessChatMessageRequest2(1);
  190. if(g_bSendOK==0)return;
  191. DataToArray(expendtypearray);
  192. m_combobz.ResetContent ();
  193. for(int i=0; i<expendtypearray->GetSize (); i++)
  194. {
  195. m_combobz.AddString (expendtypearray->ElementAt (i).ElementAt (0));
  196. }
  197. m_combobz.AddString ("摄影二销");
  198. m_combobz.AddString ("化妆二销");
  199. m_combobz.AddString ("选片二销");
  200. }
  201. void AddIncome::OnDropdownCOMBOname()
  202. {
  203. // TODO: Add your control notification handler code here
  204. }
  205. void AddIncome::OnButton2()
  206. {
  207. // TODO: Add your control notification handler code here
  208. SPLBDlg dlg;
  209. dlg.m_mode=13;
  210. dlg.DoModal ();
  211. g_sendhead.bsql=0;
  212. g_sendhead.code[0]=195;
  213. g_sendhead.tabcount=1;
  214. g_pMainWnd->ProcessChatMessageRequest2(1);
  215. if(g_bSendOK==0)return;
  216. DataToArray(itemarray);
  217. m_List1.ResetContent ();
  218. for(int i=0; i<itemarray->GetSize(); i++)
  219. {
  220. if(m_List1.GetCount()%2)
  221. m_List1.AddEntry( itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  222. else
  223. m_List1.AddEntry( itemarray->ElementAt(i).ElementAt(0) , g_gridcol2, m_List1.GetCount());
  224. }
  225. m_List1.Invalidate ();
  226. SetMySel();
  227. }
  228. void AddIncome::OnSelchangeList1()
  229. {
  230. // TODO: Add your control notification handler code here
  231. UpdateData();
  232. int pos=m_List1.GetCurSel();
  233. if(pos==-1)return;
  234. m_List1.GetText (pos, m_name);
  235. UpdateData(0);
  236. }
  237. void AddIncome::SetMySel()
  238. {
  239. CString str;
  240. for(int i=0; i<m_List1.GetCount(); i++)
  241. {
  242. m_List1.GetText (i, str);
  243. if(m_name==str)
  244. {
  245. m_List1.SetCurSel(i);m_List1.Invalidate ();
  246. return;
  247. }
  248. }
  249. }