ClientDlg2.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 1 // 只判断手机长度;
  164. if (m_phone1.GetLength() != 11 || m_phone1.Left(1) != _T("1"))
  165. {
  166. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  167. {
  168. return;
  169. }
  170. }
  171. #else
  172. if (m_phone1.Left(1) == "1")
  173. {
  174. if (CheckPhoneType(m_phone1) == -1)
  175. {
  176. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  177. return;
  178. }
  179. }
  180. #endif
  181. }
  182. if (!m_phone2.IsEmpty())
  183. {
  184. #if 1 // 只判断手机长度;
  185. if (m_phone2.GetLength() != 11 || m_phone2.Left(1) != _T("1"))
  186. {
  187. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  188. {
  189. return;
  190. }
  191. }
  192. #else
  193. if (m_phone2.Left(1) == "1")
  194. {
  195. if (CheckPhoneType(m_phone2) == -1)
  196. {
  197. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  198. return;
  199. }
  200. }
  201. #endif
  202. }
  203. int pos = m_comboarea.GetCurSel();
  204. if (pos != -1)
  205. m_comboarea.GetLBText(pos, m_area);
  206. else
  207. m_area.Empty();
  208. pos = m_combosex.GetCurSel();
  209. if (pos != -1)
  210. m_combosex.GetLBText(pos, m_sex);
  211. else
  212. m_sex.Empty();
  213. pos = m_combozodiac.GetCurSel();
  214. if (pos != -1)
  215. m_combozodiac.GetLBText(pos, m_zodiac);
  216. else
  217. m_zodiac.Empty();
  218. CString strRes1, strRes2;
  219. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  220. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  221. CString sql, sql2;
  222. if (m_bAdd)
  223. 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')",
  224. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_strOrderNum, m_area, m_sex, m_zodiac, m_check1);
  225. else
  226. 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' ",
  227. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_area, m_sex, m_zodiac, m_check1, m_strOrderNum);
  228. 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);
  229. sql += sql2;
  230. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  231. {
  232. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  233. CString str, timestamp;
  234. timestamp = "msgtimestamp";
  235. {
  236. CString name;
  237. if (!m_name1.IsEmpty())
  238. name = m_name1 + ",";
  239. name += m_name2;
  240. name.TrimRight(",");
  241. if (name.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(name, 0) )
  242. {
  243. str = name + "您好," + m_content3;
  244. int count = GetLengthEx(str) / MSG_LENGTH;
  245. if (GetLengthEx(str) % MSG_LENGTH)
  246. count++;
  247. CString scount;
  248. scount.Format("%d", count);
  249. #if JEFF_TEST_ON
  250. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  251. sql += _T("***") + sql2;
  252. #else
  253. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  254. sql += sql2;
  255. #endif
  256. }
  257. }
  258. }
  259. g_sendhead.bsql = 1;
  260. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  261. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  262. CDialog::OnOK();
  263. }
  264. void CClientDlg2::OnBnClickedGetphone1() // 查看完整号码;
  265. {
  266. m_phone1 = m_strPhone1;
  267. UpdateData(FALSE);
  268. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  269. }
  270. void CClientDlg2::OnBnClickedGetphone2() // 查看完整号码;
  271. {
  272. m_phone2 = m_strPhone2;
  273. UpdateData(FALSE);
  274. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  275. }