AddClientLYFZ.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. // AddClientLYFZ.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "AddClientLYFZ.h"
  6. #include "SPLBDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // AddClientLYFZ dialog
  14. AddClientLYFZ::AddClientLYFZ(CWnd* pParent /*=NULL*/)
  15. : CDialog(AddClientLYFZ::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(AddClientLYFZ)
  18. m_addr1 = _T("");
  19. m_name1 = _T("");
  20. m_phone1 = _T("");
  21. m_qq1 = _T("");
  22. m_from = _T("");
  23. m_bz = _T("");
  24. m_bAdd = 1;
  25. m_name2 = _T("");
  26. //}}AFX_DATA_INIT
  27. }
  28. void AddClientLYFZ::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CDialog::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(AddClientLYFZ)
  32. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  33. DDX_Control(pDX, IDC_COMBOclerk, m_comboclerk);
  34. DDX_Control(pDX, IDC_COMBOstatus, m_combostatus);
  35. DDX_Control(pDX, IDC_COMBOfrom, m_combofrom);
  36. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  37. DDX_Text(pDX, IDC_EDITname, m_name1);
  38. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  39. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  40. DDX_CBString(pDX, IDC_COMBOfrom, m_from);
  41. DDX_Text(pDX, IDC_EDIT1, m_bz);
  42. DDX_Text(pDX, IDC_EDITname2, m_name2);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(AddClientLYFZ, CDialog)
  46. //{{AFX_MSG_MAP(AddClientLYFZ)
  47. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // AddClientLYFZ message handlers
  52. BOOL AddClientLYFZ::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. // TODO: Add extra initialization here
  56. CString filter = "";
  57. g_sendhead.code[0] = 82;
  58. g_sendhead.code[1] = 186;
  59. g_sendhead.tabcount = 2;
  60. g_sendhead.bsql = 0;
  61. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  62. CArray<CStringArray, CStringArray>m_List1array;
  63. CArray<CStringArray, CStringArray>m_List2array;
  64. DataToArray(&m_List1array, &m_List2array);
  65. for (int i = 0; i < m_List1array.GetSize(); i++)
  66. {
  67. m_comboarea.AddString(m_List1array.ElementAt(i).ElementAt(0));
  68. }
  69. for (i = 0; i < m_List2array.GetSize(); i++)
  70. {
  71. m_combofrom.AddString(m_List2array.ElementAt(i).ElementAt(0));
  72. }
  73. m_combostatus.AddString("有意向");
  74. m_combostatus.AddString("很有意向");
  75. m_combostatus.AddString("意向一般");
  76. m_combostatus.AddString("无意向");
  77. m_combostatus.AddString("已购买");
  78. if (m_comboclerk.FindString(0, m_clerk) == -1)
  79. m_comboclerk.AddString(m_clerk);
  80. m_comboclerk.SetCurSel(m_comboclerk.FindString(0, m_clerk));
  81. m_combofrom.SetCurSel(m_combofrom.FindString(0, m_from));
  82. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  83. m_combostatus.SetCurSel(m_combostatus.FindString(0, m_status));
  84. /* if(g_List1array.GetSize ())
  85. {
  86. m_bAdd=0;
  87. m_name1=g_List1array.ElementAt (0).ElementAt (1);
  88. m_name2=g_List1array.ElementAt (0).ElementAt (2);
  89. m_phone1=g_List1array.ElementAt (0).ElementAt (3);
  90. m_phone2=g_List1array.ElementAt (0).ElementAt (4);
  91. m_qq1=g_List1array.ElementAt (0).ElementAt (5);
  92. m_qq2=g_List1array.ElementAt (0).ElementAt (6);
  93. m_addr1=g_List1array.ElementAt (0).ElementAt (7);
  94. m_addr2=g_List1array.ElementAt (0).ElementAt (8);
  95. m_occupation1=g_List1array.ElementAt (0).ElementAt (9);
  96. m_occupation2=g_List1array.ElementAt (0).ElementAt (10);
  97. m_birthday1=g_List1array.ElementAt (0).ElementAt (11);
  98. m_birthday2=g_List1array.ElementAt (0).ElementAt (12);
  99. m_time3=m_List1array.ElementAt (0).ElementAt (12);
  100. m_area=g_List1array.ElementAt (0).ElementAt (13);
  101. m_area2=g_List1array.ElementAt (0).ElementAt (14);
  102. m_check1=atoi(g_List1array.ElementAt (0).ElementAt (15));
  103. m_check2=atoi(g_List1array.ElementAt (0).ElementAt (16));
  104. m_check3=atoi(g_List1array.ElementAt (0).ElementAt (17));
  105. UpdateData(false);
  106. m_comboarea.SetCurSel(m_comboarea.FindString(0,m_area));
  107. m_comboarea2.SetCurSel(m_comboarea2.FindString(0,m_area2));
  108. }*/
  109. this->CenterWindow(g_pMainWnd);
  110. return false; // return TRUE unless you set the focus to a control
  111. // EXCEPTION: OCX Property Pages should return FALSE
  112. }
  113. void AddClientLYFZ::OnButton1()
  114. {
  115. // TODO: Add your control notification handler code here
  116. SPLBDlg dlg;
  117. dlg.m_mode = 8;
  118. dlg.DoModal();
  119. m_combofrom.ResetContent();
  120. if (m_combofrom.GetCount() < 2)
  121. {
  122. g_sendhead.bsql = 0;
  123. g_sendhead.code[0] = 186;
  124. g_sendhead.tabcount = 1;
  125. g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0)return;
  126. DataToArray(&g_List1array);
  127. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  128. m_combofrom.AddString(g_List1array.ElementAt(ii).ElementAt(0));
  129. }
  130. }
  131. void AddClientLYFZ::OnOK()
  132. {
  133. // TODO: Add extra validation here
  134. UpdateData();
  135. m_name1.TrimLeft();
  136. m_name1.TrimRight();
  137. m_name2.TrimLeft();
  138. m_name2.TrimRight();
  139. m_phone1.TrimLeft();
  140. m_phone1.TrimRight();
  141. if (m_name1.IsEmpty() || m_name2.IsEmpty() || m_phone1.IsEmpty())
  142. {
  143. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  144. }
  145. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  146. {
  147. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  148. return;
  149. }
  150. int pos = m_comboclerk.GetCurSel();
  151. if (pos != -1)
  152. {
  153. m_comboclerk.GetLBText(pos, m_clerk);
  154. }
  155. else
  156. m_clerk.Empty();
  157. if (m_clerk.IsEmpty())
  158. {
  159. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  160. }
  161. pos = m_comboarea.GetCurSel();
  162. if (pos != -1)
  163. {
  164. m_comboarea.GetLBText(pos, m_area);
  165. }
  166. else
  167. m_area.Empty();
  168. pos = m_combofrom.GetCurSel();
  169. if (pos != -1)
  170. {
  171. m_combofrom.GetLBText(pos, m_from);
  172. }
  173. else
  174. m_from.Empty();
  175. pos = m_combostatus.GetCurSel();
  176. if (pos != -1)
  177. {
  178. m_combostatus.GetLBText(pos, m_status);
  179. }
  180. else
  181. m_status.Empty();
  182. m_phone1.TrimLeft();
  183. m_phone1.TrimRight();
  184. if (!m_phone1.IsEmpty())
  185. {
  186. if (m_phone1.Left(1) == "1")
  187. {
  188. if (CheckPhoneType(m_phone1) == -1)
  189. {
  190. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  191. return;
  192. }
  193. }
  194. }
  195. CString strRes1, strRes2;
  196. GetFirstLetter(m_name1, strRes1); GetFirstLetter(m_name2, strRes2);
  197. // dlg.m_pList2array=&m_List2array;
  198. for (int i = 0; i < m_pList2array->GetSize(); i++)
  199. {
  200. if (m_bAdd == 0)
  201. {
  202. if (m_pList2array->ElementAt(i).ElementAt(0) == id)continue;
  203. }
  204. if (m_pList2array->ElementAt(i).ElementAt(3) == m_name2)
  205. {
  206. AfxMessageBox("已有此客户的记录!", MB_ICONINFORMATION);
  207. return;
  208. }
  209. if (m_pList2array->ElementAt(i).ElementAt(5) == m_phone1)
  210. {
  211. AfxMessageBox("已有此电话的记录!", MB_ICONINFORMATION);
  212. return;
  213. }
  214. }
  215. CString sql, sql2;
  216. if (m_bAdd)
  217. sql.Format("insert into [client2]([name],[name2],[area],[phone],[ren],[qq],[addr],[from],[status],[bz],[pinyin],[pinyin2],[date])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", m_name1, m_name2, m_area, m_phone1, m_clerk, m_qq1, m_addr1, m_from, m_status, m_bz, strRes1, strRes2, g_date);
  218. else
  219. sql.Format("update [client2] set [name]='%s',[name2]='%s',[area]='%s',[phone]='%s',[ren]='%s',[qq]='%s',[addr]='%s',[from]='%s',[status]='%s',[bz]='%s',[pinyin]='%s',[pinyin2]='%s' where [id]=%d ", m_name1, m_name2, m_area, m_phone1, m_clerk, m_qq1, m_addr1, m_from, m_status, m_bz, strRes1, strRes2, atol(id));
  220. g_sendhead.bsql = 1;
  221. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  222. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  223. CDialog::OnOK();
  224. }