AddIncome.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 1 // 只判断手机长度;
  102. if (m_phone.GetLength() != 11 || m_phone.Left(1) != _T("1"))
  103. {
  104. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  105. {
  106. return;
  107. }
  108. }
  109. #else
  110. if (m_phone.Left(1) == "1")
  111. {
  112. if (CheckPhoneType(m_phone) == -1)
  113. {
  114. AfxMessageBox("手机号码:" + m_phone + "错误!", MB_ICONINFORMATION);
  115. return;
  116. }
  117. }
  118. #endif
  119. }
  120. else
  121. return;
  122. int pos = m_comboren.GetCurSel();
  123. if (pos == -1)
  124. {
  125. AfxMessageBox("请填写开单人!", MB_ICONINFORMATION);
  126. return;
  127. }
  128. m_comboren.GetLBText(pos, m_renyuan3);
  129. pos = m_combobz.GetCurSel();
  130. if (pos == -1)
  131. {
  132. AfxMessageBox("请选择正确的二销类别!", MB_ICONINFORMATION);
  133. return;
  134. }
  135. m_combobz.GetLBText(pos, m_sale2type);
  136. if (m_name == "")
  137. {
  138. AfxMessageBox("请选择正确的二销项目!", MB_ICONINFORMATION);
  139. return;
  140. }
  141. m_renyuan1.TrimLeft();
  142. m_renyuan1.TrimRight();
  143. if (m_renyuan1 == "")return;
  144. CString strRes1;
  145. ChinesePinYin::GetFirstLetter(m_renyuan1, strRes1);
  146. CString paytype;
  147. /* SelPayType seltype;
  148. seltype.m_paymoney=m_money;
  149. if(seltype.DoModal ()!=IDOK)return;
  150. if(seltype.m_radio1==0)
  151. paytype="现金";
  152. else if(seltype.m_radio1==1)
  153. paytype="POS机刷卡";
  154. else if(seltype.m_radio1==2)
  155. paytype="储值卡扣款";
  156. else if(seltype.m_radio1==3)
  157. paytype="积分兑换";*/
  158. CString sql;
  159. if (m_id.IsEmpty())
  160. 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);
  161. else
  162. {
  163. 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));
  164. sql += "***refresh singleincomemoney" + m_id;
  165. }
  166. /* CString m_id="其它二销:"+m_name;
  167. if(paytype=="储值卡扣款")
  168. {
  169. if(seltype.m_bChildMoneyCard)
  170. {
  171. sql+="***insert into [membercard3childusereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  172. sql+="***refresh balance memberreg4"+seltype.m_parentno+";"+seltype.m_cardno;
  173. }
  174. else
  175. {
  176. sql+="***insert into [membercard3usereg]([memberno],[dindanid],[money],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+m_date+"')";
  177. sql+="***refresh balance memberreg3";sql+=seltype.m_cardno;
  178. }
  179. }
  180. else if(paytype=="积分兑换")
  181. {
  182. CString point;
  183. float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
  184. point.Format ("%d", (int)(atof(m_money)*GetPointScale2()/rate));
  185. sql+="***insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('"+seltype.m_cardno+"','"+m_id+"','"+m_money+"','"+point+"','"+g_date+"')";
  186. sql+="***refresh balance memberreg2";
  187. sql+=seltype.m_cardno;
  188. }*/
  189. g_sendhead.bsql = 1;
  190. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  191. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  192. CDialog::OnOK();
  193. }
  194. void AddIncome::OnButton1()
  195. {
  196. // TODO: Add your control notification handler code here
  197. SPLBDlg dlg;
  198. dlg.m_mode = 6;
  199. dlg.DoModal();
  200. g_sendhead.bsql = 0;
  201. g_sendhead.code[0] = 160;
  202. g_sendhead.tabcount = 1;
  203. g_pMainWnd->ProcessChatMessageRequest2(1);
  204. if (g_bSendOK == 0)return;
  205. DataToArray(expendtypearray);
  206. m_combobz.ResetContent();
  207. for (int i = 0; i < expendtypearray->GetSize(); i++)
  208. {
  209. m_combobz.AddString(expendtypearray->ElementAt(i).ElementAt(0));
  210. }
  211. m_combobz.AddString("摄影二销");
  212. #ifndef CHILD_VERSION
  213. m_combobz.AddString("化妆二销");
  214. #else
  215. m_combobz.AddString("引导二销");
  216. #endif
  217. m_combobz.AddString("选片二销");
  218. }
  219. void AddIncome::OnDropdownCOMBOname()
  220. {
  221. // TODO: Add your control notification handler code here
  222. }
  223. void AddIncome::OnButton2()
  224. {
  225. // TODO: Add your control notification handler code here
  226. SPLBDlg dlg;
  227. dlg.m_mode = 13;
  228. dlg.DoModal();
  229. g_sendhead.bsql = 0;
  230. g_sendhead.code[0] = 195;
  231. g_sendhead.tabcount = 1;
  232. g_pMainWnd->ProcessChatMessageRequest2(1);
  233. if (g_bSendOK == 0)return;
  234. DataToArray(itemarray);
  235. m_List1.ResetContent();
  236. for (int i = 0; i < itemarray->GetSize(); i++)
  237. {
  238. if (m_List1.GetCount() % 2)
  239. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol1, m_List1.GetCount());
  240. else
  241. m_List1.AddEntry(itemarray->ElementAt(i).ElementAt(0), g_gridcol2, m_List1.GetCount());
  242. }
  243. m_List1.Invalidate();
  244. SetMySel();
  245. }
  246. void AddIncome::OnSelchangeList1()
  247. {
  248. // TODO: Add your control notification handler code here
  249. UpdateData();
  250. int pos = m_List1.GetCurSel();
  251. if (pos == -1)return;
  252. m_List1.GetText(pos, m_name);
  253. UpdateData(0);
  254. }
  255. void AddIncome::SetMySel()
  256. {
  257. CString str;
  258. for (int i = 0; i < m_List1.GetCount(); i++)
  259. {
  260. m_List1.GetText(i, str);
  261. if (m_name == str)
  262. {
  263. m_List1.SetCurSel(i); m_List1.Invalidate();
  264. return;
  265. }
  266. }
  267. }