ClientDlg.cpp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. END_MESSAGE_MAP()
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CClientDlg message handlers
  75. BOOL CClientDlg::OnInitDialog()
  76. {
  77. CDialog::OnInitDialog();
  78. // TODO: Add extra initialization here
  79. if (m_bHistory)
  80. {
  81. SetWindowText("历史客人信息");
  82. GetDlgItem(IDOK)->EnableWindow(0);
  83. }
  84. CString filter = "id='" + id + "';id='" + id + "'";
  85. g_sendhead.code[0] = 52;
  86. g_sendhead.code[1] = 11;
  87. g_sendhead.code[2] = 82;
  88. g_sendhead.tabcount = 3;
  89. g_sendhead.bsql = 0;
  90. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  91. CArray<CStringArray, CStringArray>m_List1array;
  92. CArray<CStringArray, CStringArray>m_List2array;
  93. DataToArray(&g_List1array, &m_List1array, &m_List2array);
  94. for (int i = 0; i < m_List2array.GetSize(); i++)
  95. {
  96. m_comboarea.AddString(m_List2array.ElementAt(i).ElementAt(0));
  97. m_comboarea2.AddString(m_List2array.ElementAt(i).ElementAt(0));
  98. }
  99. if (g_List1array.GetSize())
  100. {
  101. m_bAdd = 0;
  102. m_name1 = g_List1array.ElementAt(0).ElementAt(1);
  103. m_name2 = g_List1array.ElementAt(0).ElementAt(2);
  104. if (m_bNeedSendMsg == 0)
  105. {
  106. m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
  107. m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
  108. }
  109. m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
  110. m_qq2 = g_List1array.ElementAt(0).ElementAt(6);
  111. m_addr1 = g_List1array.ElementAt(0).ElementAt(7);
  112. m_addr2 = g_List1array.ElementAt(0).ElementAt(8);
  113. m_occupation1 = g_List1array.ElementAt(0).ElementAt(9);
  114. m_occupation2 = g_List1array.ElementAt(0).ElementAt(10);
  115. m_birthday1 = g_List1array.ElementAt(0).ElementAt(11);
  116. m_birthday2 = g_List1array.ElementAt(0).ElementAt(12);
  117. m_time3 = m_List1array.ElementAt(0).ElementAt(12);
  118. m_area = g_List1array.ElementAt(0).ElementAt(13);
  119. m_area2 = g_List1array.ElementAt(0).ElementAt(14);
  120. m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(15));
  121. m_check2 = atoi(g_List1array.ElementAt(0).ElementAt(16));
  122. m_check3 = atoi(g_List1array.ElementAt(0).ElementAt(17));
  123. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  124. m_comboarea2.SetCurSel(m_comboarea2.FindString(0, m_area2));
  125. if (IsHasRights2new(31) == 0)
  126. {
  127. m_phone1 = "***";
  128. m_phone2 = "***";
  129. m_qq1 = "***";
  130. m_qq2 = "***";
  131. GetDlgItem(IDOK)->EnableWindow(0);
  132. }
  133. }
  134. UpdateData(false);
  135. this->CenterWindow(g_pMainWnd);
  136. GetDlgItem(IDC_EDITphone2)->SetFocus();
  137. return false; // return TRUE unless you set the focus to a control
  138. // EXCEPTION: OCX Property Pages should return FALSE
  139. }
  140. void CClientDlg::OnOK()
  141. {
  142. // TODO: Add extra validation here
  143. UpdateData();
  144. m_name1.TrimLeft();
  145. m_name1.TrimRight();
  146. m_name2.TrimLeft();
  147. m_name2.TrimRight();
  148. if (m_name1.IsEmpty() && m_name2.IsEmpty())
  149. {
  150. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  151. }
  152. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  153. {
  154. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  155. return;
  156. }
  157. if (!CheckDateOK(m_birthday1))return;
  158. if (!CheckDateOK(m_birthday2))return;
  159. if (!CheckDateOK(m_time3))return;
  160. m_phone1.TrimLeft();
  161. m_phone1.TrimRight();
  162. m_phone2.TrimLeft();
  163. m_phone2.TrimRight();
  164. if (!m_phone1.IsEmpty())
  165. {
  166. if (m_phone1.Left(1) == "1")
  167. {
  168. if (CheckPhoneType(m_phone1) == -1)
  169. {
  170. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  171. return;
  172. }
  173. }
  174. }
  175. if (!m_phone2.IsEmpty())
  176. {
  177. if (m_phone2.Left(1) == "1")
  178. {
  179. if (CheckPhoneType(m_phone2) == -1)
  180. {
  181. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  182. return;
  183. }
  184. }
  185. }
  186. int pos = m_comboarea.GetCurSel();
  187. if (pos != -1)
  188. m_comboarea.GetLBText(pos, m_area);
  189. else
  190. m_area.Empty();
  191. pos = m_comboarea2.GetCurSel();
  192. if (pos != -1)
  193. m_comboarea2.GetLBText(pos, m_area2);
  194. else
  195. m_area2.Empty();
  196. CString strRes1, strRes2;
  197. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  198. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  199. CString sql, sql2;
  200. if (m_bAdd)
  201. 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')",
  202. m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_addr1, m_addr2, m_occupation1, m_occupation2, m_birthday1, m_birthday2, id, m_area, m_area2, m_check1, m_check2, m_check3);
  203. else
  204. 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' ",
  205. 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, id);
  206. 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, id);
  207. sql += sql2;
  208. #ifndef CHILD_VERSION
  209. if(m_hqtime.IsEmpty ()==0)
  210. {
  211. sql2.Format ("***update dindansp set hqdate='%s' where id='%s' and hqdate is null", m_hqtime, id);
  212. sql+=sql2;
  213. }
  214. #endif
  215. if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
  216. {
  217. CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
  218. CString str, timestamp;
  219. timestamp = "msgtimestamp";
  220. int pos = m_content3.Find("xxx先生/女士");
  221. if (pos != -1)
  222. {
  223. if (m_name1.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(m_name1, 0) )
  224. {
  225. str = m_content3;
  226. str.Replace("xxx先生/女士", m_name1 + "先生");
  227. int count = GetLengthEx(str) / MSG_LENGTH;
  228. if (GetLengthEx(str) % MSG_LENGTH)
  229. count++;
  230. CString scount;
  231. scount.Format("%d", count);
  232. #if JEFF_TEST_ON
  233. sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"),_T("系统自动发送"));
  234. sql += _T("***") + sql2;
  235. #else
  236. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  237. sql += sql2;
  238. #endif
  239. }
  240. if (m_name2.IsEmpty() == 0 && CheckPhoneType(m_phone2) != -1 && CheckBadWords(m_name2, 0) )
  241. {
  242. str = m_content3;
  243. str.Replace("xxx先生/女士", m_name2 + "女士");
  244. int count = GetLengthEx(str) / MSG_LENGTH;
  245. if (GetLengthEx(str) % MSG_LENGTH)
  246. count++;
  247. CString scount;
  248. scount.Format("%d", count);
  249. CTime tm = CTime::GetCurrentTime();
  250. tm += CTimeSpan(0, 0, 0, 3);
  251. timestamp = tm.Format("%Y%m%d%H%M%S");
  252. timestamp = "msgtimexxstamp";
  253. #if JEFF_TEST_ON
  254. sql2.Format(INSERT_SENDREG, _T("3"), m_phone2, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
  255. sql += _T("***") + sql2;
  256. #else
  257. sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone2 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  258. sql += sql2;
  259. #endif
  260. }
  261. }
  262. }
  263. g_sendhead.bsql = 1;
  264. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  265. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  266. CDialog::OnOK();
  267. }
  268. void CClientDlg::OnCancel()
  269. {
  270. // TODO: Add extra cleanup here
  271. if (!m_hqtime.IsEmpty())
  272. {
  273. CString sql;
  274. sql.Format("***update dindansp set hqdate='%s' where id='%s'", m_hqtime, id);
  275. g_sendhead.bsql = 1;
  276. g_pMainWnd->ProcessChatMessageRequest2(sql);
  277. }
  278. CDialog::OnCancel();
  279. }