AddOldClient.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. // AddOldClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "AddOldClient.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // AddOldClient dialog IDC_EDITdate
  13. AddOldClient::AddOldClient(CWnd* pParent /*=NULL*/)
  14. : CDialog(AddOldClient::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(AddOldClient)
  17. m_date = _T("");
  18. m_birthday1 = _T("");
  19. m_birthday2 = _T("");
  20. m_name1 = _T("");
  21. m_name2 = _T("");
  22. m_phone1 = _T("");
  23. m_phone2 = _T("");
  24. m_qq1 = _T("");
  25. m_qq2 = _T("");
  26. m_time3 = _T("");
  27. m_taoxijiage = _T("");
  28. m_taoxiname = _T("");
  29. m_bAdd = 1;
  30. m_check1 = FALSE;
  31. m_check2 = FALSE;
  32. m_check3 = FALSE;
  33. //}}AFX_DATA_INIT
  34. }
  35. void AddOldClient::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(AddOldClient)
  39. DDX_Control(pDX, IDC_EDITtaoxijiage, m_numctrl);
  40. DDX_Control(pDX, IDC_COMBO1, m_combotaoxiname);
  41. DDX_Control(pDX, IDC_EDITtime3, m_ctrldate4);
  42. DDX_Control(pDX, IDC_EDITBirthday3, m_ctrldate3);
  43. DDX_Control(pDX, IDC_EDITBirthday, m_ctrldate2);
  44. DDX_Control(pDX, IDC_EDITdate, m_ctrldate);
  45. DDX_Text(pDX, IDC_EDITdate, m_date);
  46. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  47. DDX_Text(pDX, IDC_EDITBirthday3, m_birthday2);
  48. DDX_Text(pDX, IDC_EDITname2, m_name1);
  49. DDX_Text(pDX, IDC_EDITname3, m_name2);
  50. DDX_Text(pDX, IDC_EDITphone3, m_phone1);
  51. DDX_Text(pDX, IDC_EDITphone4, m_phone2);
  52. DDX_Text(pDX, IDC_EDITqq2, m_qq1);
  53. DDX_Text(pDX, IDC_EDITqq3, m_qq2);
  54. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  55. DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
  56. DDX_CBString(pDX, IDC_COMBO1, m_taoxiname);
  57. DDX_Check(pDX, IDC_CHECK1, m_check1);
  58. DDX_Check(pDX, IDC_CHECK2, m_check2);
  59. DDX_Check(pDX, IDC_CHECK3, m_check3);
  60. //}}AFX_DATA_MAP
  61. }
  62. BEGIN_MESSAGE_MAP(AddOldClient, CDialog)
  63. //{{AFX_MSG_MAP(AddOldClient)
  64. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  65. //}}AFX_MSG_MAP
  66. ON_BN_CLICKED(BTN_GETPHONE1, OnBnClickedGetphone1)
  67. ON_BN_CLICKED(BTN_GETPHONE2, OnBnClickedGetphone2)
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // AddOldClient message handlers
  71. BOOL AddOldClient::OnInitDialog()
  72. {
  73. CDialog::OnInitDialog();
  74. if ( IsHasRights2new(31) == TRUE || ( IsHasRights2new(31) == FALSE && IsHasRights2new(65) == FALSE ))
  75. {// 有查看客人号码权限 或 无查看客人号码权限且没有查看完整号码权限;
  76. GetDlgItem(BTN_GETPHONE1)->ShowWindow(SW_HIDE);
  77. GetDlgItem(BTN_GETPHONE2)->ShowWindow(SW_HIDE);
  78. }
  79. // TODO: Add extra initialization here
  80. g_sendhead.bsql = 0;
  81. g_sendhead.code[0] = 138;
  82. g_sendhead.code[1] = 6;
  83. g_sendhead.tabcount = 2;
  84. CString filter;
  85. filter.Format("[id]=%d;", atoi(id));
  86. g_pMainWnd->ProcessChatMessageRequest2(filter);
  87. if (g_bSendOK == 0)
  88. {
  89. CDialog::OnCancel();
  90. return 0;
  91. }
  92. DataToArray(&g_List1array, &m_List1array);
  93. for (int i = 0; i < m_List1array.GetSize(); i++)
  94. m_combotaoxiname.AddString(m_List1array.ElementAt(i).ElementAt(1));
  95. if (g_List1array.GetSize())
  96. {
  97. m_name1 = g_List1array.ElementAt(0).ElementAt(1);
  98. m_name2 = g_List1array.ElementAt(0).ElementAt(2);
  99. m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
  100. m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
  101. if ( IsHasRights2new(31) == FALSE)
  102. {// 无权限查看客人电话,隐藏中间4位;
  103. if ( IsHasRights2new(65) == TRUE )
  104. {// 具有查看完整号码的权限;
  105. m_strPhone1 = m_phone1;
  106. m_strPhone2 = m_phone2;
  107. }
  108. if ( m_phone1.GetLength() == 11 )
  109. m_phone1.Replace(m_phone1.Mid(3,4), _T("****"));
  110. if ( m_phone2.GetLength() == 11 )
  111. m_phone2.Replace(m_phone2.Mid(3,4), _T("****"));
  112. }
  113. m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
  114. m_qq2 = g_List1array.ElementAt(0).ElementAt(6);
  115. m_birthday1 = g_List1array.ElementAt(0).ElementAt(7);
  116. m_birthday2 = g_List1array.ElementAt(0).ElementAt(8);
  117. m_time3 = g_List1array.ElementAt(0).ElementAt(9);
  118. m_taoxiname = g_List1array.ElementAt(0).ElementAt(10);
  119. m_taoxijiage = g_List1array.ElementAt(0).ElementAt(11);
  120. m_date = g_List1array.ElementAt(0).ElementAt(12);
  121. m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(17));
  122. m_check2 = atoi(g_List1array.ElementAt(0).ElementAt(18));
  123. m_check3 = atoi(g_List1array.ElementAt(0).ElementAt(19));
  124. UpdateData(0);
  125. }
  126. this->CenterWindow(g_pMainWnd);
  127. return false; // return TRUE unless you set the focus to a control
  128. // EXCEPTION: OCX Property Pages should return FALSE
  129. }
  130. void AddOldClient::OnOK()
  131. {
  132. // TODO: Add extra validation here
  133. UpdateData();
  134. m_name1.TrimLeft();
  135. m_name1.TrimRight();
  136. m_name2.TrimLeft();
  137. m_name2.TrimRight();
  138. if (m_name1.IsEmpty() && m_name2.IsEmpty())
  139. {
  140. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  141. }
  142. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  143. {
  144. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  145. return;
  146. }
  147. // 男宾生日;
  148. BOOL bLunanr = ((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck();
  149. if (!CheckDateOK(m_birthday1, bLunanr))
  150. return;
  151. // 女宾生日;
  152. bLunanr = ((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck();
  153. if (!CheckDateOK(m_birthday2, bLunanr))
  154. return;
  155. // 婚期;
  156. bLunanr = ((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck();
  157. if (!CheckDateOK(m_time3, bLunanr))
  158. return;
  159. // 订单日期;
  160. if (!CheckDateOK(m_date))return;
  161. m_phone1.TrimLeft();
  162. m_phone1.TrimRight();
  163. m_phone2.TrimLeft();
  164. m_phone2.TrimRight();
  165. if (!m_phone1.IsEmpty())
  166. {
  167. if (m_phone1.Left(1) == "1")
  168. {
  169. if (CheckPhoneType(m_phone1) == -1)
  170. {
  171. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  172. return;
  173. }
  174. }
  175. }
  176. if (!m_phone2.IsEmpty())
  177. {
  178. if (m_phone2.Left(1) == "1")
  179. {
  180. if (CheckPhoneType(m_phone2) == -1)
  181. {
  182. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  183. return;
  184. }
  185. }
  186. }
  187. CString strRes1, strRes2;
  188. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  189. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  190. CString sql, sql2;
  191. if (m_bAdd)
  192. sql.Format("insert into [client3]([name],[name2],[phone],[phone2],[qq],[qq2],[birthday],[birthday2],[pinyin],[pinyin2],[date],[ren],[dandate],[taoxiname],[taoxijiage],[time3],[check1],[check2],[check3])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d')", m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_birthday1, m_birthday2, strRes1, strRes2, g_date, g_user.name, m_date, m_taoxiname, m_taoxijiage, m_time3, m_check1, m_check2, m_check3);
  193. else
  194. sql.Format("update [client3] set [name]='%s',[name2]='%s',[phone]='%s',[phone2]='%s',[qq]='%s',[qq2]='%s',[birthday]='%s',[birthday2]='%s',[pinyin]='%s',[pinyin2]='%s',[taoxiname]='%s',[taoxijiage]='%s',[time3]='%s',[dandate]='%s',[check1]='%d',[check2]='%d',[check3]='%d' where [id]=%d ", m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_birthday1, m_birthday2, strRes1, strRes2, m_taoxiname, m_taoxijiage, m_time3, m_date, m_check1, m_check2, m_check3, atol(id));
  195. g_sendhead.bsql = 1;
  196. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  197. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  198. CDialog::OnOK();
  199. }
  200. void AddOldClient::OnSelchangeCombo1()
  201. {
  202. // TODO: Add your control notification handler code here
  203. UpdateData();
  204. int pos = m_combotaoxiname.GetCurSel();
  205. if (pos == -1)return;
  206. m_combotaoxiname.GetLBText(pos, m_taoxiname);
  207. pos = -1;
  208. for (int i = 0; i < m_List1array.GetSize(); i++)
  209. {
  210. if (m_taoxiname == m_List1array.ElementAt(i).ElementAt(1))
  211. {
  212. pos = i;
  213. break;
  214. }
  215. }
  216. if (pos == -1)
  217. {
  218. m_taoxijiage = "";
  219. UpdateData(false);
  220. return;
  221. }
  222. m_taoxijiage = m_List1array.ElementAt(pos).ElementAt(2);
  223. UpdateData(false);
  224. }
  225. void AddOldClient::OnBnClickedGetphone1() // 查看完整号码;
  226. {
  227. m_phone1 = m_strPhone1;
  228. UpdateData(FALSE);
  229. WriteOptLog(_T("查看[%s,%s]老客户完整号码1"), m_name1, m_name2);
  230. }
  231. void AddOldClient::OnBnClickedGetphone2() // 查看完整号码;
  232. {
  233. m_phone2 = m_strPhone2;
  234. UpdateData(FALSE);
  235. WriteOptLog(_T("查看[%s,%s]老客户完整号码2"), m_name1, m_name2);
  236. }