InputCard2PointBlue.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // InputCard2PointBlue.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "InputCard2PointBlue.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // InputCard2PointBlue dialog IDC_EDITtaoxijiage
  13. InputCard2PointBlue::InputCard2PointBlue(CWnd* pParent /*=NULL*/)
  14. : CDialog(InputCard2PointBlue::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(InputCard2PointBlue)
  17. m_name1 = _T("");
  18. m_name2 = _T("");
  19. m_id = _T("");
  20. m_ren = _T("");
  21. m_taoxiname = _T("");
  22. m_memberno = _T("");
  23. m_name = _T("");
  24. m_point = _T("");
  25. m_taoxijiage = _T("");
  26. m_card2no = _T("");
  27. m_jiage = _T("");
  28. m_rate = _T("");
  29. //}}AFX_DATA_INIT
  30. }
  31. void InputCard2PointBlue::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(InputCard2PointBlue)
  35. DDX_Control(pDX, IDC_COMBO5, m_combobox);
  36. DDX_Text(pDX, IDC_EDITname, m_name1);
  37. DDX_Text(pDX, IDC_EDITname2, m_name2);
  38. DDX_Text(pDX, IDC_EDITid, m_id);
  39. DDX_Text(pDX, IDC_EDITOren, m_ren);
  40. DDX_Text(pDX, IDC_EDITtaoxiname, m_taoxiname);
  41. DDX_Text(pDX, IDC_EDIT1, m_memberno);
  42. DDX_Text(pDX, IDC_EDITmembername, m_name);
  43. DDX_Text(pDX, IDC_EDIT2, m_point);
  44. DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
  45. DDX_Text(pDX, IDC_EDITcard2no, m_card2no);
  46. DDX_Text(pDX, IDC_EDIT7, m_jiage);
  47. DDX_Text(pDX, IDC_EDIT3, m_rate);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(InputCard2PointBlue, CDialog)
  51. //{{AFX_MSG_MAP(InputCard2PointBlue)
  52. ON_CBN_SELCHANGE(IDC_COMBO5, OnSelchangeCombo5)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // InputCard2PointBlue message handlers
  57. BOOL InputCard2PointBlue::OnInitDialog()
  58. {
  59. CDialog::OnInitDialog();
  60. // TODO: Add extra initialization here
  61. #ifdef CHILD_VERSION
  62. GetDlgItem(IDC_STATIC1)->SetWindowText("家长姓名:");
  63. GetDlgItem(IDC_STATIC2)->SetWindowText("宝宝姓名:");
  64. #endif
  65. m_acCombo.Init(&m_combobox);
  66. CString filter = "hashistory;[memberno]='" + m_memberno + "'";
  67. g_sendhead.bsql = 0;
  68. g_sendhead.code[0] = 30;
  69. g_sendhead.code[1] = 132;
  70. g_sendhead.tabcount = 2;
  71. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 0;
  72. DataToArray(&m_List1array, &g_List1array);
  73. m_acCombo.m_pArray = &m_List1array;
  74. m_combobox.SetFocus();
  75. CString m_bluescale1;
  76. CString m_bluescale2;
  77. CString m_bluescale3;
  78. CString m_bluescale4;
  79. CString m_bluescale5;
  80. CString m_bluescale6;
  81. CString m_bluescale7;
  82. CString m_bluescale8;
  83. CString m_bluescale9;
  84. CString m_bluescale10;
  85. CString str = (g_cominfoarray.ElementAt(0).ElementAt(119));
  86. if (str == "")
  87. str = "5,10,15,20,50,0,0,0,0,0";
  88. int pos = str.Find(",");
  89. m_bluescale1 = str.Left(pos);
  90. str = str.Right(str.GetLength() - pos - 1);
  91. pos = str.Find(",");
  92. m_bluescale2 = str.Left(pos);
  93. str = str.Right(str.GetLength() - pos - 1);
  94. pos = str.Find(",");
  95. m_bluescale3 = str.Left(pos);
  96. str = str.Right(str.GetLength() - pos - 1);
  97. pos = str.Find(",");
  98. m_bluescale4 = str.Left(pos);
  99. str = str.Right(str.GetLength() - pos - 1);
  100. pos = str.Find(",");
  101. m_bluescale5 = str.Left(pos);
  102. str = str.Right(str.GetLength() - pos - 1);
  103. pos = str.Find(",");
  104. m_bluescale6 = str.Left(pos);
  105. str = str.Right(str.GetLength() - pos - 1);
  106. pos = str.Find(",");
  107. m_bluescale7 = str.Left(pos);
  108. str = str.Right(str.GetLength() - pos - 1);
  109. pos = str.Find(",");
  110. m_bluescale8 = str.Left(pos);
  111. str = str.Right(str.GetLength() - pos - 1);
  112. pos = str.Find(",");
  113. m_bluescale9 = str.Left(pos);
  114. str = str.Right(str.GetLength() - pos - 1);
  115. m_bluescale10 = str.Left(pos);
  116. if (g_List1array.GetSize() % 10 == 0)
  117. m_rate = m_bluescale1 + "%";
  118. else if (g_List1array.GetSize() % 10 == 1)
  119. m_rate = m_bluescale2 + "%";
  120. else if (g_List1array.GetSize() % 10 == 2)
  121. m_rate = m_bluescale3 + "%";
  122. else if (g_List1array.GetSize() % 10 == 3)
  123. m_rate = m_bluescale4 + "%";
  124. else if (g_List1array.GetSize() % 10 == 4)
  125. m_rate = m_bluescale5 + "%";
  126. else if (g_List1array.GetSize() % 10 == 5)
  127. m_rate = m_bluescale6 + "%";
  128. else if (g_List1array.GetSize() % 10 == 6)
  129. m_rate = m_bluescale7 + "%";
  130. else if (g_List1array.GetSize() % 10 == 7)
  131. m_rate = m_bluescale8 + "%";
  132. else if (g_List1array.GetSize() % 10 == 8)
  133. m_rate = m_bluescale9 + "%";
  134. else if (g_List1array.GetSize() % 10 == 9)
  135. m_rate = m_bluescale10 + "%";
  136. else
  137. m_rate = "0%";
  138. UpdateData(false);
  139. this->CenterWindow(g_pMainWnd);
  140. return false; // return TRUE unless you set the focus to a control
  141. // EXCEPTION: OCX Property Pages should return FALSE
  142. }
  143. void InputCard2PointBlue::OnOK()
  144. {
  145. // TODO: Add extra validation here
  146. UpdateData();
  147. if (atol(m_point) < 1)
  148. {
  149. AfxMessageBox("现金不能小于1!", MB_ICONINFORMATION);
  150. return;
  151. }
  152. m_card2no.TrimLeft();
  153. m_card2no.TrimRight();
  154. if (m_card2no.IsEmpty())
  155. {
  156. AfxMessageBox("副卡卡号不能为空!", MB_ICONINFORMATION);
  157. return;
  158. }
  159. CString filter = "[card2no]='" + m_card2no + "'";
  160. g_sendhead.bsql = 0;
  161. g_sendhead.code[0] = 131;
  162. g_sendhead.tabcount = 1;
  163. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return;
  164. DataToArray(&g_List1array);
  165. if (g_List1array.GetSize() == 0)
  166. {
  167. AfxMessageBox("没有此副卡号的记录!"); return;
  168. }
  169. CString date2 = g_List1array.ElementAt(0).ElementAt(2);
  170. CString sql;
  171. sql = "delete from membercard2blue where [card2no]='" + m_card2no + "'";
  172. sql += "~~~insert into memberregblue([memberno],[dindanid],[money],[date],[card2no],[type],[taoxi],[date2])values('" + m_memberno + "','" + m_id + "','" + m_point + "','" + g_date + "','" + m_card2no + "','转介绍','" + m_taoxiname + "','" + date2 + "')";
  173. sql += "~~~";
  174. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(51))) // msgcheck5
  175. {
  176. CString m_content5 = g_cominfoarray.ElementAt(0).ElementAt(52);
  177. CString content, timestamp;
  178. CString name;
  179. if (!m_name1.IsEmpty())
  180. name = m_name1 + ",";
  181. name += m_name2;
  182. name.TrimRight(",");
  183. CString name2 = m_name;
  184. #ifndef CHILD_VERSION
  185. if(m_sex=="男")
  186. name2+="先生";
  187. else if(m_sex=="女")
  188. name2+="女士";
  189. #endif
  190. content.Format("%s您好,您的朋友%s为您返现金%s元.", name2, name, m_point);
  191. content += m_content5;
  192. timestamp = "msgtimestamp";
  193. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  194. {
  195. int count = GetLengthEx(content) / MSG_LENGTH;
  196. if (GetLengthEx(content) % MSG_LENGTH)
  197. count++;
  198. CString scount;
  199. scount.Format("%d", count);
  200. #if JEFF_TEST_ON
  201. CString sql2 = _T("");
  202. sql2.Format(INSERT_SENDREG, _T("5"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  203. sql += sql2;
  204. #else
  205. CString sql2 = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  206. sql += sql2;
  207. #endif
  208. sql += "~~~";
  209. }
  210. }
  211. sql += m_memberno;
  212. g_sendhead.bsql = 1;
  213. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  214. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  215. CDialog::OnOK();
  216. }
  217. void InputCard2PointBlue::ClientChange()
  218. {
  219. CString filter = "id='" + id + "'";
  220. g_sendhead.code[0] = 11;
  221. g_sendhead.tabcount = 1;
  222. g_sendhead.bsql = 0;
  223. int g_nYearposTemp = g_nYearpos;
  224. g_nYearpos = curyear;
  225. g_pMainWnd->ProcessChatMessageRequest2(filter);
  226. g_nYearpos = g_nYearposTemp;
  227. if (g_bSendOK == 0)return;
  228. DataToArray(&g_List1array);
  229. if (g_List1array.GetSize())
  230. {
  231. m_id = g_List1array.ElementAt(0).ElementAt(0);
  232. m_name1 = g_List1array.ElementAt(0).ElementAt(4);
  233. m_name2 = g_List1array.ElementAt(0).ElementAt(5);
  234. m_taoxiname = g_List1array.ElementAt(0).ElementAt(7);
  235. m_taoxijiage = g_List1array.ElementAt(0).ElementAt(8);
  236. m_ren = g_List1array.ElementAt(0).ElementAt(14);
  237. float frate = atof(m_rate) / 100.0;
  238. m_point.Format("%d", (int)(min(atof(m_taoxijiage), atof(m_jiage))*frate));
  239. GetDlgItem(IDOK)->EnableWindow(1);
  240. if (atof(m_taoxijiage) < atof(m_jiage))
  241. {
  242. AfxMessageBox("此套系金额小于主套系,无法返现!");
  243. m_point = "0";
  244. GetDlgItem(IDOK)->EnableWindow(0);
  245. }
  246. UpdateData(false);
  247. }
  248. }
  249. void InputCard2PointBlue::OnSelchangeCombo5()
  250. {
  251. // TODO: Add your control notification handler code here
  252. int pos = m_combobox.GetCurSel();
  253. if (pos == -1)return;
  254. if (m_acCombo.m_posarray.GetSize() <= pos)return;
  255. int pos2 = m_acCombo.m_posarray.ElementAt(pos);
  256. id = m_List1array.ElementAt(pos2).ElementAt(0);
  257. curyear = atoi(m_List1array.ElementAt(pos2).ElementAt(16));
  258. ClientChange();
  259. }