InputCard2Point.cpp 6.4 KB

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