ClientDlg2.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. // ClientDlg2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ClientDlg2.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CClientDlg2 dialog
  13. CClientDlg2::CClientDlg2(CWnd* pParent /*=NULL*/)
  14. : CDialog(CClientDlg2::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CClientDlg2)
  17. m_addr1 = _T("");
  18. m_name1 = _T("");
  19. m_name2 = _T("");
  20. m_phone1 = _T("");
  21. m_phone2 = _T("");
  22. m_qq1 = _T("");
  23. m_birthday1 = _T("");
  24. m_zodiac = _T("");
  25. m_sex = _T("");
  26. m_bAdd = 1;
  27. m_area = _T("");
  28. m_check1 = FALSE;
  29. m_bNeedSendMsg = 0;
  30. m_bHistory = 0;
  31. //}}AFX_DATA_INIT
  32. }
  33. void CClientDlg2::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CDialog::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CClientDlg2)
  37. DDX_Control(pDX, IDC_COMBOzodiac, m_combozodiac);
  38. DDX_Control(pDX, IDC_COMBOsex, m_combosex);
  39. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  40. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  41. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  42. DDX_Text(pDX, IDC_EDITname, m_name1);
  43. DDX_Text(pDX, IDC_EDITname2, m_name2);
  44. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  45. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  46. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  47. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  48. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  49. DDX_Check(pDX, IDC_CHECK1, m_check1);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(CClientDlg2, CDialog)
  53. //{{AFX_MSG_MAP(CClientDlg2)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CClientDlg2 message handlers
  58. BOOL CClientDlg2::OnInitDialog()
  59. {
  60. CDialog::OnInitDialog();
  61. // TODO: Add extra initialization here
  62. if (m_bHistory)
  63. {
  64. SetWindowText("历史客人信息");
  65. GetDlgItem(IDOK)->EnableWindow(0);
  66. }
  67. m_combozodiac.AddString("鼠");
  68. m_combozodiac.AddString("牛");
  69. m_combozodiac.AddString("虎");
  70. m_combozodiac.AddString("兔");
  71. m_combozodiac.AddString("龙");
  72. m_combozodiac.AddString("蛇");
  73. m_combozodiac.AddString("马");
  74. m_combozodiac.AddString("羊");
  75. m_combozodiac.AddString("猴");
  76. m_combozodiac.AddString("鸡");
  77. m_combozodiac.AddString("狗");
  78. m_combozodiac.AddString("猪");
  79. m_combosex.AddString("男");
  80. m_combosex.AddString("女");
  81. CString filter = "id='" + id + "';id='" + id + "'";
  82. g_sendhead.code[0] = 94;
  83. g_sendhead.code[1] = 11;
  84. g_sendhead.code[2] = 82;
  85. g_sendhead.tabcount = 3;
  86. g_sendhead.bsql = 0;
  87. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  88. CArray<CStringArray, CStringArray>m_List1array;
  89. CArray<CStringArray, CStringArray>m_List2array;
  90. DataToArray(&g_List1array, &m_List1array, &m_List2array);
  91. for (int i = 0; i < m_List2array.GetSize(); i++)
  92. {
  93. m_comboarea.AddString(m_List2array.ElementAt(i).ElementAt(0));
  94. }
  95. if (g_List1array.GetSize())
  96. {
  97. m_bAdd = 0;
  98. m_name1 = g_List1array.ElementAt(0).ElementAt(1);
  99. m_name2 = g_List1array.ElementAt(0).ElementAt(2);
  100. if (m_bNeedSendMsg == 0)
  101. {
  102. m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
  103. m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
  104. }
  105. m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
  106. m_addr1 = g_List1array.ElementAt(0).ElementAt(6);
  107. m_birthday1 = g_List1array.ElementAt(0).ElementAt(7);
  108. m_area = g_List1array.ElementAt(0).ElementAt(8);
  109. m_sex = g_List1array.ElementAt(0).ElementAt(9);
  110. m_zodiac = g_List1array.ElementAt(0).ElementAt(10);
  111. m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(11));
  112. //#ifdef LKAY_VERSION
  113. if (IsHasRights2new(31) == 0)
  114. {
  115. m_phone1 = "***";
  116. m_phone2 = "***";
  117. m_qq1 = "***";
  118. m_addr1 = "***";
  119. m_area = "***";
  120. GetDlgItem(IDOK)->EnableWindow(0);
  121. }
  122. //#endif
  123. UpdateData(false);
  124. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  125. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  126. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  127. }
  128. this->CenterWindow(g_pMainWnd);
  129. return false; // return TRUE unless you set the focus to a control
  130. // EXCEPTION: OCX Property Pages should return FALSE
  131. }
  132. void CClientDlg2::OnOK()
  133. {
  134. // TODO: Add extra validation here
  135. UpdateData();
  136. m_name1.TrimLeft();
  137. m_name1.TrimRight();
  138. m_name2.TrimLeft();
  139. m_name2.TrimRight();
  140. if (m_name1.IsEmpty() && m_name2.IsEmpty())
  141. {
  142. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  143. }
  144. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  145. {
  146. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  147. return;
  148. }
  149. if (!CheckDateOK(m_birthday1))return;
  150. m_phone1.TrimLeft();
  151. m_phone1.TrimRight();
  152. m_phone2.TrimLeft();
  153. m_phone2.TrimRight();
  154. if (!m_phone1.IsEmpty())
  155. {
  156. if (m_phone1.Left(1) == "1")
  157. {
  158. if (CheckPhoneType(m_phone1) == -1)
  159. {
  160. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  161. return;
  162. }
  163. }
  164. }
  165. if (!m_phone2.IsEmpty())
  166. {
  167. if (m_phone2.Left(1) == "1")
  168. {
  169. if (CheckPhoneType(m_phone2) == -1)
  170. {
  171. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  172. return;
  173. }
  174. }
  175. }
  176. int pos = m_comboarea.GetCurSel();
  177. if (pos != -1)
  178. m_comboarea.GetLBText(pos, m_area);
  179. else
  180. m_area.Empty();
  181. pos = m_combosex.GetCurSel();
  182. if (pos != -1)
  183. m_combosex.GetLBText(pos, m_sex);
  184. else
  185. m_sex.Empty();
  186. pos = m_combozodiac.GetCurSel();
  187. if (pos != -1)
  188. m_combozodiac.GetLBText(pos, m_zodiac);
  189. else
  190. m_zodiac.Empty();
  191. CString strRes1, strRes2;
  192. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  193. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  194. CString sql, sql2;
  195. if (m_bAdd)
  196. sql.Format("insert into [client]([name1],[name2],[phone1],[phone2],[qq1],[addr1],[birthday1],[id],[area],[sex],[zodiac],[check1])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d')",
  197. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, id, m_area, m_sex, m_zodiac, m_check1);
  198. else
  199. sql.Format("update [client] set [name1]='%s',[name2]='%s',[phone1]='%s',[phone2]='%s',[qq1]='%s',[addr1]='%s',[birthday1]='%s',[area]='%s',[sex]='%s',[zodiac]='%s',[check1]='%d' where [id]='%s' ",
  200. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_area, m_sex, m_zodiac, m_check1, id);
  201. sql2.Format("***update dindan set name1='%s',name2='%s',pinyin1='%s',pinyin2='%s',phone1='%s',phone2='%s' where id='%s'", m_name1, m_name2, strRes1, strRes2, m_phone1, m_phone2, id);
  202. sql += sql2;
  203. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  204. {
  205. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  206. CString str, timestamp;
  207. timestamp = "msgtimestamp";
  208. {
  209. CString name;
  210. if (!m_name1.IsEmpty())
  211. name = m_name1 + ",";
  212. name += m_name2;
  213. name.TrimRight(",");
  214. if (name.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(name, 0) )
  215. {
  216. str = name + "您好," + m_content3;
  217. int count = GetLengthEx(str) / MSG_LENGTH;
  218. if (GetLengthEx(str) % MSG_LENGTH)
  219. count++;
  220. CString scount;
  221. scount.Format("%d", count);
  222. #if JEFF_TEST_ON
  223. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  224. sql += _T("***") + sql2;
  225. #else
  226. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  227. sql += sql2;
  228. #endif
  229. }
  230. }
  231. }
  232. g_sendhead.bsql = 1;
  233. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  234. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  235. CDialog::OnOK();
  236. }