AddIncome.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. #ifndef CHILD_VERSION
  71. m_combobz.AddString("化妆二销");
  72. #else
  73. m_combobz.AddString("引导二销");
  74. #endif
  75. m_combobz.AddString("选片二销");
  76. if (m_combobz.FindString(0, m_sale2type) == -1)
  77. m_combobz.AddString(m_sale2type);
  78. m_combobz.SetCurSel(m_combobz.FindString(0, m_sale2type));
  79. m_comboren.AddString(m_renyuan3);
  80. m_comboren.SetCurSel(m_comboren.FindString(0, m_renyuan3));
  81. for (i = 0; i < itemarray->GetSize(); i++)
  82. {
  83. if (m_List1.GetCount() % 2)
  84. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  85. else
  86. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol2, m_List1.GetCount());
  87. }
  88. m_List1.Invalidate();
  89. SetMySel();
  90. return TRUE; // return TRUE unless you set the focus to a control
  91. // EXCEPTION: OCX Property Pages should return FALSE
  92. }
  93. void AddIncome::OnOK()
  94. {
  95. // TODO: Add extra validation here
  96. UpdateData();
  97. m_phone.TrimLeft();
  98. m_phone.TrimRight();
  99. if (!m_phone.IsEmpty())
  100. {
  101. if (m_phone.Left(1) == "1")
  102. {
  103. if (CheckPhoneType(m_phone) == -1)
  104. {
  105. AfxMessageBox("手机号码:" + m_phone + "错误!", MB_ICONINFORMATION);
  106. return;
  107. }
  108. }
  109. }
  110. else
  111. return;
  112. int pos = m_comboren.GetCurSel();
  113. if (pos == -1)
  114. {
  115. AfxMessageBox("请填写开单人!", MB_ICONINFORMATION);
  116. return;
  117. }
  118. m_comboren.GetLBText(pos, m_renyuan3);
  119. pos = m_combobz.GetCurSel();
  120. if (pos == -1)
  121. {
  122. AfxMessageBox("请选择正确的二销类别!", MB_ICONINFORMATION);
  123. return;
  124. }
  125. m_combobz.GetLBText(pos, m_sale2type);
  126. if (m_name == "")
  127. {
  128. AfxMessageBox("请选择正确的二销项目!", MB_ICONINFORMATION);
  129. return;
  130. }
  131. m_renyuan1.TrimLeft();
  132. m_renyuan1.TrimRight();
  133. if (m_renyuan1 == "")return;
  134. CString strRes1;
  135. ChinesePinYin::GetFirstLetter(m_renyuan1, strRes1);
  136. CString paytype;
  137. /* SelPayType seltype;
  138. seltype.m_paymoney=m_money;
  139. if(seltype.DoModal ()!=IDOK)return;
  140. if(seltype.m_radio1==0)
  141. paytype="现金";
  142. else if(seltype.m_radio1==1)
  143. paytype="POS机刷卡";
  144. else if(seltype.m_radio1==2)
  145. paytype="储值卡扣款";
  146. else if(seltype.m_radio1==3)
  147. paytype="积分兑换";*/
  148. CString sql;
  149. if (m_id.IsEmpty())
  150. 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);
  151. else
  152. {
  153. 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));
  154. sql += "***refresh singleincomemoney" + m_id;
  155. }
  156. /* CString m_id="其它二销:"+m_name;
  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. CDialog::OnOK();
  183. }
  184. void AddIncome::OnButton1()
  185. {
  186. // TODO: Add your control notification handler code here
  187. SPLBDlg dlg;
  188. dlg.m_mode = 6;
  189. dlg.DoModal();
  190. g_sendhead.bsql = 0;
  191. g_sendhead.code[0] = 160;
  192. g_sendhead.tabcount = 1;
  193. g_pMainWnd->ProcessChatMessageRequest2(1);
  194. if (g_bSendOK == 0)return;
  195. DataToArray(expendtypearray);
  196. m_combobz.ResetContent();
  197. for (int i = 0; i < expendtypearray->GetSize(); i++)
  198. {
  199. m_combobz.AddString(expendtypearray->ElementAt(i).ElementAt(0));
  200. }
  201. m_combobz.AddString("摄影二销");
  202. #ifndef CHILD_VERSION
  203. m_combobz.AddString("化妆二销");
  204. #else
  205. m_combobz.AddString("引导二销");
  206. #endif
  207. m_combobz.AddString("选片二销");
  208. }
  209. void AddIncome::OnDropdownCOMBOname()
  210. {
  211. // TODO: Add your control notification handler code here
  212. }
  213. void AddIncome::OnButton2()
  214. {
  215. // TODO: Add your control notification handler code here
  216. SPLBDlg dlg;
  217. dlg.m_mode = 13;
  218. dlg.DoModal();
  219. g_sendhead.bsql = 0;
  220. g_sendhead.code[0] = 195;
  221. g_sendhead.tabcount = 1;
  222. g_pMainWnd->ProcessChatMessageRequest2(1);
  223. if (g_bSendOK == 0)return;
  224. DataToArray(itemarray);
  225. m_List1.ResetContent();
  226. for (int i = 0; i < itemarray->GetSize(); i++)
  227. {
  228. if (m_List1.GetCount() % 2)
  229. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  230. else
  231. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol2, m_List1.GetCount());
  232. }
  233. m_List1.Invalidate();
  234. SetMySel();
  235. }
  236. void AddIncome::OnSelchangeList1()
  237. {
  238. // TODO: Add your control notification handler code here
  239. UpdateData();
  240. int pos = m_List1.GetCurSel();
  241. if (pos == -1)return;
  242. m_List1.GetText(pos, m_name);
  243. UpdateData(0);
  244. }
  245. void AddIncome::SetMySel()
  246. {
  247. CString str;
  248. for (int i = 0; i < m_List1.GetCount(); i++)
  249. {
  250. m_List1.GetText(i, str);
  251. if (m_name == str)
  252. {
  253. m_List1.SetCurSel(i); m_List1.Invalidate();
  254. return;
  255. }
  256. }
  257. }