UsePoint.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. // UsePoint.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "UsePoint.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // UsePoint dialog IDC_EDITmembername
  13. UsePoint::UsePoint(CWnd* pParent /*=NULL*/)
  14. : CDialog(UsePoint::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(UsePoint)
  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_goods = _T("");
  28. m_point2 = _T("");
  29. m_mode = 0;
  30. //}}AFX_DATA_INIT
  31. }
  32. void UsePoint::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(UsePoint)
  36. DDX_Control(pDX, IDC_EDIT3, m_editnum);
  37. DDX_Control(pDX, IDC_COMBO5, m_combobox);
  38. DDX_Text(pDX, IDC_EDITname, m_name1);
  39. DDX_Text(pDX, IDC_EDITname2, m_name2);
  40. DDX_Text(pDX, IDC_EDITid, m_id);
  41. DDX_Text(pDX, IDC_EDITOren, m_ren);
  42. DDX_Text(pDX, IDC_EDITtaoxiname, m_taoxiname);
  43. DDX_Text(pDX, IDC_EDIT1, m_memberno);
  44. DDX_Text(pDX, IDC_EDITmembername, m_name);
  45. DDX_Text(pDX, IDC_EDIT2, m_point);
  46. DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
  47. DDX_Text(pDX, IDC_EDITcard2no, m_card2no);
  48. DDX_Text(pDX, IDC_EDIT7, m_goods);
  49. DDX_Text(pDX, IDC_EDIT3, m_point2);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(UsePoint, CDialog)
  53. //{{AFX_MSG_MAP(UsePoint)
  54. ON_CBN_SELCHANGE(IDC_COMBO5, OnSelchangeCombo5)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // UsePoint message handlers
  59. BOOL UsePoint::OnInitDialog()
  60. {
  61. CDialog::OnInitDialog();
  62. // TODO: Add extra initialization here
  63. if (m_mode == 1)
  64. {
  65. SetWindowText("赠送积分");
  66. GetDlgItem(IDC_STATIC4)->SetWindowText("*赠送说明:");
  67. GetDlgItem(IDC_STATIC5)->SetWindowText("*此次赠送积分:");
  68. }
  69. else if (m_mode == 2)
  70. {
  71. SetWindowText("卡号变更");
  72. GetDlgItem(IDC_STATIC4)->SetWindowText("*请输入新卡号:");
  73. GetDlgItem(IDC_STATIC5)->ShowWindow(0);
  74. GetDlgItem(IDC_EDIT3)->ShowWindow(0);
  75. }
  76. return false; // return TRUE unless you set the focus to a control
  77. // EXCEPTION: OCX Property Pages should return FALSE
  78. }
  79. void UsePoint::OnOK()
  80. {
  81. // TODO: Add extra validation here
  82. UpdateData();
  83. if (m_mode == 2)
  84. {
  85. g_sendhead.bsql = 0;
  86. g_sendhead.code[0] = 68;
  87. g_sendhead.tabcount = 1;
  88. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  89. CArray<CStringArray, CStringArray>m_List1array;
  90. DataToArray(&m_List1array);
  91. CString newno = m_goods;
  92. if (newno.IsEmpty())
  93. {
  94. AfxMessageBox("卡号不能为空,请重新输入!", MB_ICONINFORMATION);
  95. return;
  96. }
  97. if (newno == m_memberno)
  98. {
  99. AfxMessageBox("卡号不能与旧卡号相同,请重新输入!", MB_ICONINFORMATION);
  100. m_goods = "";
  101. UpdateData(false);
  102. GetDlgItem(IDC_EDIT7)->SetFocus();
  103. return;
  104. }
  105. for (int i = 0; i < m_List1array.GetSize(); i++)
  106. {
  107. if (newno == m_List1array.ElementAt(i).ElementAt(1))
  108. {
  109. AfxMessageBox("此会员卡卡号已存在,请重新输入!", MB_ICONINFORMATION);
  110. m_goods = "";
  111. UpdateData(false);
  112. GetDlgItem(IDC_EDIT7)->SetFocus();
  113. return;
  114. }
  115. }
  116. CString sql;
  117. sql = "update membermanage set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  118. sql += "***update memberreg set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  119. sql += "***update memberreg2 set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  120. sql += "***update memberreg3 set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  121. sql += "***update memberreg4 set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  122. sql += "***update membercard3usereg set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  123. sql += "***update membercard2 set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  124. sql += "***update membercard3 set [memberno]='" + newno + "' where [memberno]='" + m_memberno + "'";
  125. g_sendhead.bsql = 1;
  126. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  127. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  128. CDialog::OnOK();
  129. return;
  130. }
  131. if (atol(m_point2) < 1)
  132. {
  133. AfxMessageBox("积分不能小于1分!", MB_ICONINFORMATION);
  134. return;
  135. }
  136. CString point2; CString sql;
  137. if (m_mode == 0)
  138. {
  139. if (atol(m_point) < 1)
  140. {
  141. AfxMessageBox("积分不能小于1分!", MB_ICONINFORMATION);
  142. return;
  143. }
  144. if (atol(m_point2) > atol(m_point))
  145. {
  146. AfxMessageBox("积分不够!", MB_ICONINFORMATION);
  147. return;
  148. }
  149. point2.Format("%d", (int)(atof(m_point2)*GetPointScale2()));
  150. sql = "insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('" + m_memberno + "','" + m_goods + "','0','" + point2 + "','" + g_date + "')";
  151. sql += "&&&update membermanage set [sendmark1]='',[sendmark2]='' where [memberno]='" + m_memberno + "'";
  152. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(122)))
  153. {
  154. CString content, timestamp;
  155. content.Format("%s您好,您本次兑换%s,使用积分%d分,余额:%d分", m_name, m_goods, atol(m_point2), atol(m_point) - atol(m_point2));
  156. timestamp = "msgtimestamp";
  157. if (CheckPhoneType(m_phone) != -1 && CheckBadWords(content, 0))
  158. {
  159. int count = GetLengthEx(content) / MSG_LENGTH;
  160. if (GetLengthEx(content) % MSG_LENGTH)
  161. count++;
  162. CString scount;
  163. scount.Format("%d", count);
  164. #if JEFF_TEST_ON
  165. CString sql2 = _T("");
  166. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  167. sql += _T("&&&") + sql2;
  168. #else
  169. CString sql2 = "&&&insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  170. sql += sql2;
  171. #endif
  172. }
  173. }
  174. sql += "&&&";
  175. sql += m_memberno;
  176. }
  177. else//赠送积分
  178. {
  179. point2.Format("%d", (int)(atof(m_point2)*GetPointScale2()));
  180. sql = "insert into memberreg([memberno],[dindanid],[money],[date],[type])values('" + m_memberno + "','" + m_goods + "','" + point2 + "','" + g_date + "','消费积分')";
  181. if (0)//atoi(g_cominfoarray.ElementAt(0).ElementAt(122)))
  182. {
  183. CString content, timestamp;
  184. content.Format("%s您好,%s,本次赠送积分%d,余额:%d分", m_name, m_goods, atol(m_point2), atol(m_point) + atol(m_point2));
  185. timestamp = "msgtimestamp";
  186. if (CheckPhoneType(m_phone) != -1)//&& CheckBadWords(content,0) && CheckBadWords2(content,0) )
  187. {
  188. int count = GetLengthEx(content) / MSG_LENGTH;
  189. if (GetLengthEx(content) % MSG_LENGTH)
  190. count++;
  191. CString scount;
  192. scount.Format("%d", count);
  193. #if JEFF_TEST_ON
  194. CString sql2 = _T("");
  195. sql2.Format(INSERT_SENDREG, _T("16"), m_phone, content, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  196. sql += _T("&&&") + sql2;
  197. #else
  198. CString sql2 = "&&&insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  199. sql += sql2;
  200. #endif
  201. }
  202. }
  203. sql += "&&&";
  204. sql += m_memberno;
  205. }
  206. g_sendhead.bsql = 1;
  207. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  208. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  209. CDialog::OnOK();
  210. }
  211. void UsePoint::ClientChange()
  212. {
  213. CString filter = "id='" + id + "'";
  214. g_sendhead.code[0] = 11;
  215. g_sendhead.tabcount = 1;
  216. g_sendhead.bsql = 0;
  217. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return;
  218. DataToArray(&g_List1array);
  219. if (g_List1array.GetSize())
  220. {
  221. m_id = g_List1array.ElementAt(0).ElementAt(0);
  222. m_name1 = g_List1array.ElementAt(0).ElementAt(4);
  223. m_name2 = g_List1array.ElementAt(0).ElementAt(5);
  224. m_taoxiname = g_List1array.ElementAt(0).ElementAt(7);
  225. m_point = m_taoxijiage = g_List1array.ElementAt(0).ElementAt(8);
  226. m_ren = g_List1array.ElementAt(0).ElementAt(14);
  227. UpdateData(false);
  228. }
  229. }
  230. void UsePoint::OnSelchangeCombo5()
  231. {
  232. // TODO: Add your control notification handler code here
  233. int pos = m_combobox.GetCurSel();
  234. if (pos == -1)return;
  235. if (m_acCombo.m_posarray.GetSize() <= pos)return;
  236. int pos2 = m_acCombo.m_posarray.ElementAt(pos);
  237. id = m_List1array.ElementAt(pos2).ElementAt(0);
  238. ClientChange();
  239. }