ClientDlg.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. // ClientDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ClientDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CClientDlg dialog IDC_CHECK3
  13. CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CClientDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CClientDlg)
  17. m_addr1 = _T("");
  18. m_addr2 = _T("");
  19. m_name1 = _T("");
  20. m_name2 = _T("");
  21. m_occupation1 = _T("");
  22. m_occupation2 = _T("");
  23. m_phone1 = _T("");
  24. m_phone2 = _T("");
  25. m_qq1 = _T("");
  26. m_qq2 = _T("");
  27. m_birthday1 = _T("");
  28. m_birthday2 = _T("");
  29. m_time3 = _T("");
  30. m_bAdd = 1;
  31. m_area = _T("");
  32. m_area2 = _T("");
  33. m_check1 = FALSE;
  34. m_check2 = FALSE;
  35. m_check3 = FALSE;
  36. m_bNeedSendMsg = 0;
  37. m_bHistory = 0;
  38. //}}AFX_DATA_INIT
  39. }
  40. void CClientDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CClientDlg)
  44. DDX_Control(pDX, IDC_COMBOarea2, m_comboarea2);
  45. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  46. DDX_Control(pDX, IDC_EDITtime3, m_datectrl3);
  47. DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2);
  48. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  49. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  50. DDX_Text(pDX, IDC_EDITaddr2, m_addr2);
  51. DDX_Text(pDX, IDC_EDITname, m_name1);
  52. DDX_Text(pDX, IDC_EDITname2, m_name2);
  53. DDX_Text(pDX, IDC_EDITOccupation, m_occupation1);
  54. DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2);
  55. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  56. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  57. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  58. DDX_Text(pDX, IDC_EDITqq2, m_qq2);
  59. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  60. DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2);
  61. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  62. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  63. DDX_CBString(pDX, IDC_COMBOarea2, m_area2);
  64. DDX_Check(pDX, IDC_CHECK1, m_check1);
  65. DDX_Check(pDX, IDC_CHECK2, m_check2);
  66. DDX_Check(pDX, IDC_CHECK3, m_check3);
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(CClientDlg, CDialog)
  70. //{{AFX_MSG_MAP(CClientDlg)
  71. //}}AFX_MSG_MAP
  72. ON_BN_CLICKED(BTN_GETPHONE1, OnBnClickedGetphone1)
  73. ON_BN_CLICKED(BTN_GETPHONE2, OnBnClickedGetphone2)
  74. END_MESSAGE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CClientDlg message handlers
  77. BOOL CClientDlg::OnInitDialog()
  78. {
  79. CDialog::OnInitDialog();
  80. if ( IsHasRights2new(31) == TRUE || ( IsHasRights2new(31) == FALSE && IsHasRights2new(65) == FALSE ))
  81. {// 有查看客人号码权限 或 无查看客人号码权限且没有查看完整号码权限;
  82. GetDlgItem(BTN_GETPHONE1)->ShowWindow(SW_HIDE);
  83. GetDlgItem(BTN_GETPHONE2)->ShowWindow(SW_HIDE);
  84. }
  85. // TODO: Add extra initialization here
  86. if (m_bHistory)
  87. {
  88. SetWindowText("历史客人信息");
  89. GetDlgItem(IDOK)->EnableWindow(0);
  90. }
  91. CString filter = "id='" + m_strOrderNum + "';id='" + m_strOrderNum + "'";
  92. g_sendhead.code[0] = 52;
  93. g_sendhead.code[1] = 11;
  94. g_sendhead.code[2] = 82;
  95. g_sendhead.tabcount = 3;
  96. g_sendhead.bsql = 0;
  97. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  98. CArray<CStringArray, CStringArray>m_List1array;
  99. CArray<CStringArray, CStringArray>m_List2array;
  100. DataToArray(&g_List1array, &m_List1array, &m_List2array);
  101. for (int i = 0; i < m_List2array.GetSize(); i++)
  102. {
  103. m_comboarea.AddString(m_List2array.ElementAt(i).ElementAt(0));
  104. m_comboarea2.AddString(m_List2array.ElementAt(i).ElementAt(0));
  105. }
  106. if (g_List1array.GetSize())
  107. {
  108. m_bAdd = 0;
  109. m_name1 = g_List1array.ElementAt(0).ElementAt(1);
  110. m_name2 = g_List1array.ElementAt(0).ElementAt(2);
  111. if (m_bNeedSendMsg == 0)
  112. {
  113. m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
  114. m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
  115. }
  116. m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
  117. m_qq2 = g_List1array.ElementAt(0).ElementAt(6);
  118. m_addr1 = g_List1array.ElementAt(0).ElementAt(7);
  119. m_addr2 = g_List1array.ElementAt(0).ElementAt(8);
  120. m_occupation1 = g_List1array.ElementAt(0).ElementAt(9);
  121. m_occupation2 = g_List1array.ElementAt(0).ElementAt(10);
  122. m_birthday1 = g_List1array.ElementAt(0).ElementAt(11);
  123. m_birthday2 = g_List1array.ElementAt(0).ElementAt(12);
  124. m_time3 = m_List1array.ElementAt(0).ElementAt(12);
  125. m_area = g_List1array.ElementAt(0).ElementAt(13);
  126. m_area2 = g_List1array.ElementAt(0).ElementAt(14);
  127. m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(15));
  128. m_check2 = atoi(g_List1array.ElementAt(0).ElementAt(16));
  129. m_check3 = atoi(g_List1array.ElementAt(0).ElementAt(17));
  130. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  131. m_comboarea2.SetCurSel(m_comboarea2.FindString(0, m_area2));
  132. if (IsHasRights2new(31) == FALSE)
  133. {
  134. if ( IsHasRights2new(65) == TRUE )
  135. {
  136. m_strPhone1 = m_phone1;
  137. m_strPhone2 = m_phone2;
  138. }
  139. if ( m_phone1.GetLength() == 11 )
  140. m_phone1.Replace(m_phone1.Mid(3,4), _T("****"));
  141. if ( m_phone2.GetLength() == 11 )
  142. m_phone2.Replace(m_phone2.Mid(3,4), _T("****"));
  143. m_qq1 = "***";
  144. m_qq2 = "***";
  145. GetDlgItem(IDOK)->EnableWindow(0);
  146. }
  147. }
  148. UpdateData(false);
  149. this->CenterWindow(g_pMainWnd);
  150. GetDlgItem(IDC_EDITphone2)->SetFocus();
  151. return false; // return TRUE unless you set the focus to a control
  152. // EXCEPTION: OCX Property Pages should return FALSE
  153. }
  154. void CClientDlg::OnOK()
  155. {
  156. // TODO: Add extra validation here
  157. UpdateData();
  158. m_name1.TrimLeft();
  159. m_name1.TrimRight();
  160. m_name2.TrimLeft();
  161. m_name2.TrimRight();
  162. if (m_name1.IsEmpty() && m_name2.IsEmpty())
  163. {
  164. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  165. }
  166. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  167. {
  168. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  169. return;
  170. }
  171. if (!CheckDateOK(m_birthday1))return;
  172. if (!CheckDateOK(m_birthday2))return;
  173. if (!CheckDateOK(m_time3))return;
  174. m_phone1.TrimLeft();
  175. m_phone1.TrimRight();
  176. m_phone2.TrimLeft();
  177. m_phone2.TrimRight();
  178. if (!m_phone1.IsEmpty())
  179. {
  180. if (m_phone1.Left(1) == "1")
  181. {
  182. if (CheckPhoneType(m_phone1) == -1)
  183. {
  184. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  185. return;
  186. }
  187. }
  188. }
  189. if (!m_phone2.IsEmpty())
  190. {
  191. if (m_phone2.Left(1) == "1")
  192. {
  193. if (CheckPhoneType(m_phone2) == -1)
  194. {
  195. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  196. return;
  197. }
  198. }
  199. }
  200. int pos = m_comboarea.GetCurSel();
  201. if (pos != -1)
  202. m_comboarea.GetLBText(pos, m_area);
  203. else
  204. m_area.Empty();
  205. pos = m_comboarea2.GetCurSel();
  206. if (pos != -1)
  207. m_comboarea2.GetLBText(pos, m_area2);
  208. else
  209. m_area2.Empty();
  210. CString strRes1, strRes2;
  211. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  212. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  213. CString sql, sql2;
  214. if (m_bAdd)
  215. sql.Format("insert into [client]([name1],[name2],[phone1],[phone2],[qq1],[qq2],[addr1],[addr2],[occupation1],[occupation2],[birthday1],[birthday2],[id],[area],[area2],[check1],[check2],[check3])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d')",
  216. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_addr1, m_addr2, m_occupation1, m_occupation2, m_birthday1, m_birthday2, m_strOrderNum, m_area, m_area2, m_check1, m_check2, m_check3);
  217. else
  218. sql.Format("update [client] set [name1]='%s',[name2]='%s',[phone1]='%s',[phone2]='%s',[qq1]='%s',[qq2]='%s',[addr1]='%s',[addr2]='%s',[occupation1]='%s',[occupation2]='%s',[birthday1]='%s',[birthday2]='%s',[area]='%s',[area2]='%s',[check1]='%d',[check2]='%d',[check3]='%d',[time3]='%s' where [id]='%s' ",
  219. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_addr1, m_addr2, m_occupation1, m_occupation2, m_birthday1, m_birthday2, m_area, m_area2, m_check1, m_check2, m_check3, m_time3, m_strOrderNum);
  220. sql2.Format("***update dindan set name1='%s',name2='%s',pinyin1='%s',pinyin2='%s',phone1='%s',phone2='%s',[time3]='%s' where id='%s'", m_name1, m_name2, strRes1, strRes2, m_phone1, m_phone2, m_time3, m_strOrderNum);
  221. sql += sql2;
  222. #ifndef CHILD_VERSION
  223. if(m_hqtime.IsEmpty ()==0)
  224. {
  225. sql2.Format ("***update dindansp set hqdate='%s' where id='%s' and hqdate is null", m_hqtime, m_strOrderNum);
  226. sql+=sql2;
  227. }
  228. #endif
  229. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  230. {
  231. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  232. CString str, timestamp;
  233. timestamp = "msgtimestamp";
  234. int pos = m_content3.Find("xxx先生/女士");
  235. if (pos != -1)
  236. {
  237. if (m_name1.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(m_name1, 0) )
  238. {
  239. str = m_content3;
  240. str.Replace("xxx先生/女士", m_name1 + "先生");
  241. int count = GetLengthEx(str) / MSG_LENGTH;
  242. if (GetLengthEx(str) % MSG_LENGTH)
  243. count++;
  244. CString scount;
  245. scount.Format("%d", count);
  246. #if JEFF_TEST_ON
  247. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"),_T("系统自动发送"));
  248. sql += _T("***") + sql2;
  249. #else
  250. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  251. sql += sql2;
  252. #endif
  253. }
  254. if (m_name2.IsEmpty() == 0 && CheckPhoneType(m_phone2) != -1 && CheckBadWords(m_name2, 0) )
  255. {
  256. str = m_content3;
  257. str.Replace("xxx先生/女士", m_name2 + "女士");
  258. int count = GetLengthEx(str) / MSG_LENGTH;
  259. if (GetLengthEx(str) % MSG_LENGTH)
  260. count++;
  261. CString scount;
  262. scount.Format("%d", count);
  263. CTime tm = CTime::GetCurrentTime();
  264. tm += CTimeSpan(0, 0, 0, 3);
  265. timestamp = tm.Format("%Y%m%d%H%M%S");
  266. timestamp = "msgtimexxstamp";
  267. #if JEFF_TEST_ON
  268. sql2.Format(INSERT_SENDREG, _T("3"), m_phone2, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  269. sql += _T("***") + sql2;
  270. #else
  271. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone2 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  272. sql += sql2;
  273. #endif
  274. }
  275. }
  276. }
  277. g_sendhead.bsql = 1;
  278. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  279. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  280. CDialog::OnOK();
  281. }
  282. void CClientDlg::OnCancel()
  283. {
  284. // TODO: Add extra cleanup here
  285. if (!m_hqtime.IsEmpty())
  286. {
  287. CString sql;
  288. sql.Format("***update dindansp set hqdate='%s' where id='%s'", m_hqtime, m_strOrderNum);
  289. g_sendhead.bsql = 1;
  290. g_pMainWnd->ProcessChatMessageRequest2(sql);
  291. }
  292. CDialog::OnCancel();
  293. }
  294. void CClientDlg::OnBnClickedGetphone1() // 查看完整号码;
  295. {
  296. m_phone1 = m_strPhone1;
  297. UpdateData();
  298. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  299. }
  300. void CClientDlg::OnBnClickedGetphone2() // 查看完整号码;
  301. {
  302. m_phone2 = m_strPhone2;
  303. UpdateData();
  304. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  305. }