ClientDlg2.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. ON_BN_CLICKED(BTN_GETPHONE1, OnBnClickedGetphone1)
  56. ON_BN_CLICKED(BTN_GETPHONE2, OnBnClickedGetphone2)
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CClientDlg2 message handlers
  60. BOOL CClientDlg2::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. // TODO: Add extra initialization here
  64. if ( IsHasRights2new(31) == TRUE || ( IsHasRights2new(31) == FALSE && IsHasRights2new(65) == FALSE ))
  65. {// 有查看客人号码权限 或 无查看客人号码权限且没有查看完整号码权限;
  66. GetDlgItem(BTN_GETPHONE1)->ShowWindow(SW_HIDE);
  67. GetDlgItem(BTN_GETPHONE2)->ShowWindow(SW_HIDE);
  68. }
  69. if (m_bHistory)
  70. {
  71. SetWindowText("历史客人信息");
  72. GetDlgItem(IDOK)->EnableWindow(0);
  73. }
  74. m_combozodiac.AddString("鼠");
  75. m_combozodiac.AddString("牛");
  76. m_combozodiac.AddString("虎");
  77. m_combozodiac.AddString("兔");
  78. m_combozodiac.AddString("龙");
  79. m_combozodiac.AddString("蛇");
  80. m_combozodiac.AddString("马");
  81. m_combozodiac.AddString("羊");
  82. m_combozodiac.AddString("猴");
  83. m_combozodiac.AddString("鸡");
  84. m_combozodiac.AddString("狗");
  85. m_combozodiac.AddString("猪");
  86. m_combosex.AddString("男");
  87. m_combosex.AddString("女");
  88. CString filter = "id='" + m_strOrderNum + "';id='" + m_strOrderNum + "'";
  89. g_sendhead.code[0] = 94;
  90. g_sendhead.code[1] = 11;
  91. g_sendhead.code[2] = 82;
  92. g_sendhead.tabcount = 3;
  93. g_sendhead.bsql = 0;
  94. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  95. CArray<CStringArray, CStringArray>m_List1array;
  96. CArray<CStringArray, CStringArray>m_List2array;
  97. DataToArray(&g_List1array, &m_List1array, &m_List2array);
  98. for (int i = 0; i < m_List2array.GetSize(); i++)
  99. {
  100. m_comboarea.AddString(m_List2array.ElementAt(i).ElementAt(0));
  101. }
  102. if (g_List1array.GetSize())
  103. {
  104. m_bAdd = 0;
  105. m_name1 = g_List1array.ElementAt(0).ElementAt(1);
  106. m_name2 = g_List1array.ElementAt(0).ElementAt(2);
  107. if (m_bNeedSendMsg == 0)
  108. {
  109. m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
  110. m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
  111. }
  112. m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
  113. m_addr1 = g_List1array.ElementAt(0).ElementAt(6);
  114. m_birthday1 = g_List1array.ElementAt(0).ElementAt(7);
  115. m_area = g_List1array.ElementAt(0).ElementAt(8);
  116. m_sex = g_List1array.ElementAt(0).ElementAt(9);
  117. m_zodiac = g_List1array.ElementAt(0).ElementAt(10);
  118. m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(11));
  119. //#ifdef LKAY_VERSION
  120. if (IsHasRights2new(31) == 0)
  121. {
  122. m_phone1 = "***";
  123. m_phone2 = "***";
  124. m_qq1 = "***";
  125. m_addr1 = "***";
  126. m_area = "***";
  127. GetDlgItem(IDOK)->EnableWindow(0);
  128. }
  129. //#endif
  130. UpdateData(false);
  131. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  132. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  133. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  134. }
  135. this->CenterWindow(g_pMainWnd);
  136. return false; // return TRUE unless you set the focus to a control
  137. // EXCEPTION: OCX Property Pages should return FALSE
  138. }
  139. void CClientDlg2::OnOK()
  140. {
  141. // TODO: Add extra validation here
  142. UpdateData();
  143. m_name1.TrimLeft();
  144. m_name1.TrimRight();
  145. m_name2.TrimLeft();
  146. m_name2.TrimRight();
  147. if (m_name1.IsEmpty() && m_name2.IsEmpty())
  148. {
  149. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  150. }
  151. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  152. {
  153. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  154. return;
  155. }
  156. if (!CheckDateOK(m_birthday1))return;
  157. m_phone1.TrimLeft();
  158. m_phone1.TrimRight();
  159. m_phone2.TrimLeft();
  160. m_phone2.TrimRight();
  161. if (!m_phone1.IsEmpty())
  162. {
  163. if (m_phone1.Left(1) == "1")
  164. {
  165. if (CheckPhoneType(m_phone1) == -1)
  166. {
  167. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  168. return;
  169. }
  170. }
  171. }
  172. if (!m_phone2.IsEmpty())
  173. {
  174. if (m_phone2.Left(1) == "1")
  175. {
  176. if (CheckPhoneType(m_phone2) == -1)
  177. {
  178. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  179. return;
  180. }
  181. }
  182. }
  183. int pos = m_comboarea.GetCurSel();
  184. if (pos != -1)
  185. m_comboarea.GetLBText(pos, m_area);
  186. else
  187. m_area.Empty();
  188. pos = m_combosex.GetCurSel();
  189. if (pos != -1)
  190. m_combosex.GetLBText(pos, m_sex);
  191. else
  192. m_sex.Empty();
  193. pos = m_combozodiac.GetCurSel();
  194. if (pos != -1)
  195. m_combozodiac.GetLBText(pos, m_zodiac);
  196. else
  197. m_zodiac.Empty();
  198. CString strRes1, strRes2;
  199. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  200. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  201. CString sql, sql2;
  202. if (m_bAdd)
  203. 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')",
  204. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_strOrderNum, m_area, m_sex, m_zodiac, m_check1);
  205. else
  206. 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' ",
  207. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_area, m_sex, m_zodiac, m_check1, m_strOrderNum);
  208. 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, m_strOrderNum);
  209. sql += sql2;
  210. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  211. {
  212. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  213. CString str, timestamp;
  214. timestamp = "msgtimestamp";
  215. {
  216. CString name;
  217. if (!m_name1.IsEmpty())
  218. name = m_name1 + ",";
  219. name += m_name2;
  220. name.TrimRight(",");
  221. if (name.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(name, 0) )
  222. {
  223. str = name + "您好," + m_content3;
  224. int count = GetLengthEx(str) / MSG_LENGTH;
  225. if (GetLengthEx(str) % MSG_LENGTH)
  226. count++;
  227. CString scount;
  228. scount.Format("%d", count);
  229. #if JEFF_TEST_ON
  230. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  231. sql += _T("***") + sql2;
  232. #else
  233. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  234. sql += sql2;
  235. #endif
  236. }
  237. }
  238. }
  239. g_sendhead.bsql = 1;
  240. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  241. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  242. CDialog::OnOK();
  243. }
  244. void CClientDlg2::OnBnClickedGetphone1() // 查看完整号码;
  245. {
  246. m_phone1 = m_strPhone1;
  247. UpdateData(FALSE);
  248. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  249. }
  250. void CClientDlg2::OnBnClickedGetphone2() // 查看完整号码;
  251. {
  252. m_phone2 = m_strPhone2;
  253. UpdateData(FALSE);
  254. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  255. }