ClientDlg.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 1 // 只判断手机长度;
  181. if (m_phone1.GetLength() != 11 || m_phone1.Left(1) != _T("1"))
  182. {
  183. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  184. {
  185. return;
  186. }
  187. }
  188. #else
  189. if (m_phone1.Left(1) == "1")
  190. {
  191. if (CheckPhoneType(m_phone1) == -1)
  192. {
  193. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  194. return;
  195. }
  196. }
  197. #endif
  198. }
  199. if (!m_phone2.IsEmpty())
  200. {
  201. #if 1 // 只判断手机长度;
  202. if (m_phone2.GetLength() != 11 || m_phone2.Left(1) != _T("1"))
  203. {
  204. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  205. {
  206. return;
  207. }
  208. }
  209. #else
  210. if (m_phone2.Left(1) == "1")
  211. {
  212. if (CheckPhoneType(m_phone2) == -1)
  213. {
  214. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  215. return;
  216. }
  217. }
  218. #endif
  219. }
  220. int pos = m_comboarea.GetCurSel();
  221. if (pos != -1)
  222. m_comboarea.GetLBText(pos, m_area);
  223. else
  224. m_area.Empty();
  225. pos = m_comboarea2.GetCurSel();
  226. if (pos != -1)
  227. m_comboarea2.GetLBText(pos, m_area2);
  228. else
  229. m_area2.Empty();
  230. CString strRes1, strRes2;
  231. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  232. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  233. CString sql, sql2;
  234. if (m_bAdd)
  235. 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')",
  236. 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);
  237. else
  238. 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' ",
  239. 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);
  240. 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);
  241. sql += sql2;
  242. #ifndef CHILD_VERSION
  243. if(m_hqtime.IsEmpty ()==0)
  244. {
  245. sql2.Format ("***update dindansp set hqdate='%s' where id='%s' and hqdate is null", m_hqtime, m_strOrderNum);
  246. sql+=sql2;
  247. }
  248. #endif
  249. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  250. {
  251. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  252. CString str, timestamp;
  253. timestamp = "msgtimestamp";
  254. int pos = m_content3.Find("xxx先生/女士");
  255. if (pos != -1)
  256. {
  257. if (m_name1.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(m_name1, 0) )
  258. {
  259. str = m_content3;
  260. str.Replace("xxx先生/女士", m_name1 + "先生");
  261. int count = GetLengthEx(str) / MSG_LENGTH;
  262. if (GetLengthEx(str) % MSG_LENGTH)
  263. count++;
  264. CString scount;
  265. scount.Format("%d", count);
  266. #if JEFF_TEST_ON
  267. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"),_T("系统自动发送"));
  268. sql += _T("***") + sql2;
  269. #else
  270. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  271. sql += sql2;
  272. #endif
  273. }
  274. if (m_name2.IsEmpty() == 0 && CheckPhoneType(m_phone2) != -1 && CheckBadWords(m_name2, 0) )
  275. {
  276. str = m_content3;
  277. str.Replace("xxx先生/女士", m_name2 + "女士");
  278. int count = GetLengthEx(str) / MSG_LENGTH;
  279. if (GetLengthEx(str) % MSG_LENGTH)
  280. count++;
  281. CString scount;
  282. scount.Format("%d", count);
  283. CTime tm = CTime::GetCurrentTime();
  284. tm += CTimeSpan(0, 0, 0, 3);
  285. timestamp = tm.Format("%Y%m%d%H%M%S");
  286. timestamp = "msgtimexxstamp";
  287. #if JEFF_TEST_ON
  288. sql2.Format(INSERT_SENDREG, _T("3"), m_phone2, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  289. sql += _T("***") + sql2;
  290. #else
  291. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone2 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  292. sql += sql2;
  293. #endif
  294. }
  295. }
  296. }
  297. g_sendhead.bsql = 1;
  298. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  299. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  300. CDialog::OnOK();
  301. }
  302. void CClientDlg::OnCancel()
  303. {
  304. // TODO: Add extra cleanup here
  305. if (!m_hqtime.IsEmpty())
  306. {
  307. CString sql;
  308. sql.Format("***update dindansp set hqdate='%s' where id='%s'", m_hqtime, m_strOrderNum);
  309. g_sendhead.bsql = 1;
  310. g_pMainWnd->ProcessChatMessageRequest2(sql);
  311. }
  312. CDialog::OnCancel();
  313. }
  314. void CClientDlg::OnBnClickedGetphone1() // 查看完整号码;
  315. {
  316. m_phone1 = m_strPhone1;
  317. UpdateData();
  318. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  319. }
  320. void CClientDlg::OnBnClickedGetphone2() // 查看完整号码;
  321. {
  322. m_phone2 = m_strPhone2;
  323. UpdateData();
  324. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  325. }