AddIncome.cpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. for (int i = 0; i < g_userarray.GetSize(); i++)
  63. m_comboren.AddString(g_userarray.ElementAt(i).ElementAt(1));
  64. for (i = 0; i < expendtypearray->GetSize(); i++)
  65. {
  66. m_combobz.AddString(expendtypearray->ElementAt(i).ElementAt(0));
  67. }
  68. m_combobz.AddString("摄影二销");
  69. m_combobz.AddString("化妆二销");
  70. m_combobz.AddString("选片二销");
  71. if (m_combobz.FindString(0, m_sale2type) == -1)
  72. m_combobz.AddString(m_sale2type);
  73. m_combobz.SetCurSel(m_combobz.FindString(0, m_sale2type));
  74. m_comboren.AddString(m_renyuan3);
  75. m_comboren.SetCurSel(m_comboren.FindString(0, m_renyuan3));
  76. for (i = 0; i < itemarray->GetSize(); i++)
  77. {
  78. if (m_List1.GetCount() % 2)
  79. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  80. else
  81. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol2, m_List1.GetCount());
  82. }
  83. m_List1.Invalidate();
  84. SetMySel();
  85. return TRUE; // return TRUE unless you set the focus to a control
  86. // EXCEPTION: OCX Property Pages should return FALSE
  87. }
  88. void AddIncome::OnOK()
  89. {
  90. // TODO: Add extra validation here
  91. UpdateData();
  92. m_phone.TrimLeft();
  93. m_phone.TrimRight();
  94. if (!m_phone.IsEmpty())
  95. {
  96. if (m_phone.Left(1) == "1")
  97. {
  98. if (CheckPhoneType(m_phone) == -1)
  99. {
  100. AfxMessageBox("手机号码:" + m_phone + "错误!", MB_ICONINFORMATION);
  101. return;
  102. }
  103. }
  104. }
  105. else
  106. return;
  107. int pos = m_comboren.GetCurSel();
  108. if (pos == -1)
  109. {
  110. AfxMessageBox("请填写开单人!", MB_ICONINFORMATION);
  111. return;
  112. }
  113. m_comboren.GetLBText(pos, m_renyuan3);
  114. pos = m_combobz.GetCurSel();
  115. if (pos == -1)
  116. {
  117. AfxMessageBox("请选择正确的二销类别!", MB_ICONINFORMATION);
  118. return;
  119. }
  120. m_combobz.GetLBText(pos, m_sale2type);
  121. if (m_name == "")
  122. {
  123. AfxMessageBox("请选择正确的二销项目!", MB_ICONINFORMATION);
  124. return;
  125. }
  126. m_renyuan1.TrimLeft();
  127. m_renyuan1.TrimRight();
  128. if (m_renyuan1 == "")return;
  129. CString strRes1;
  130. GetFirstLetter(m_renyuan1, strRes1);
  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. CString sql;
  144. if (m_id.IsEmpty())
  145. 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);
  146. else
  147. {
  148. 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));
  149. sql += "***refresh singleincomemoney" + m_id;
  150. }
  151. /* CString m_id="其它二销:"+m_name;
  152. if(paytype=="储值卡扣款")
  153. {
  154. if(seltype.m_bChildMoneyCard)
  155. {
  156. sql+="***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  157. sql+="***refresh balance memberreg4"+seltype.m_parentno+";"+seltype.m_cardno;
  158. }
  159. else
  160. {
  161. sql+="***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  162. sql+="***refresh balance memberreg3";sql+=seltype.m_cardno;
  163. }
  164. }
  165. else if(paytype=="积分兑换")
  166. {
  167. CString point;
  168. float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
  169. point.Format ("%d", (int)(atof(m_money)*GetPointScale2()/rate));
  170. sql+="***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+point+"','"+g_date+"')";
  171. sql+="***refresh balance memberreg2";
  172. sql+=seltype.m_cardno;
  173. }*/
  174. g_sendhead.bsql = 1;
  175. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  176. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  177. CDialog::OnOK();
  178. }
  179. void AddIncome::OnButton1()
  180. {
  181. // TODO: Add your control notification handler code here
  182. SPLBDlg dlg;
  183. dlg.m_mode = 6;
  184. dlg.DoModal();
  185. g_sendhead.bsql = 0;
  186. g_sendhead.code[0] = 160;
  187. g_sendhead.tabcount = 1;
  188. g_pMainWnd->ProcessChatMessageRequest2(1);
  189. if (g_bSendOK == 0)return;
  190. DataToArray(expendtypearray);
  191. m_combobz.ResetContent();
  192. for (int i = 0; i < expendtypearray->GetSize(); i++)
  193. {
  194. m_combobz.AddString(expendtypearray->ElementAt(i).ElementAt(0));
  195. }
  196. m_combobz.AddString("摄影二销");
  197. m_combobz.AddString("化妆二销");
  198. m_combobz.AddString("选片二销");
  199. }
  200. void AddIncome::OnDropdownCOMBOname()
  201. {
  202. // TODO: Add your control notification handler code here
  203. }
  204. void AddIncome::OnButton2()
  205. {
  206. // TODO: Add your control notification handler code here
  207. SPLBDlg dlg;
  208. dlg.m_mode = 13;
  209. dlg.DoModal();
  210. g_sendhead.bsql = 0;
  211. g_sendhead.code[0] = 195;
  212. g_sendhead.tabcount = 1;
  213. g_pMainWnd->ProcessChatMessageRequest2(1);
  214. if (g_bSendOK == 0)return;
  215. DataToArray(itemarray);
  216. m_List1.ResetContent();
  217. for (int i = 0; i < itemarray->GetSize(); i++)
  218. {
  219. if (m_List1.GetCount() % 2)
  220. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  221. else
  222. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol2, m_List1.GetCount());
  223. }
  224. m_List1.Invalidate();
  225. SetMySel();
  226. }
  227. void AddIncome::OnSelchangeList1()
  228. {
  229. // TODO: Add your control notification handler code here
  230. UpdateData();
  231. int pos = m_List1.GetCurSel();
  232. if (pos == -1)return;
  233. m_List1.GetText(pos, m_name);
  234. UpdateData(0);
  235. }
  236. void AddIncome::SetMySel()
  237. {
  238. CString str;
  239. for (int i = 0; i < m_List1.GetCount(); i++)
  240. {
  241. m_List1.GetText(i, str);
  242. if (m_name == str)
  243. {
  244. m_List1.SetCurSel(i); m_List1.Invalidate();
  245. return;
  246. }
  247. }
  248. }