AddClientLYFZ.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. int i = 0;
  66. for ( i = 0; i < m_List1array.GetSize(); i++)
  67. {
  68. m_comboarea.AddString(m_List1array.ElementAt(i).ElementAt(0));
  69. }
  70. for (i = 0; i < m_List2array.GetSize(); i++)
  71. {
  72. m_combofrom.AddString(m_List2array.ElementAt(i).ElementAt(0));
  73. }
  74. m_combostatus.AddString("有意向");
  75. m_combostatus.AddString("很有意向");
  76. m_combostatus.AddString("意向一般");
  77. m_combostatus.AddString("无意向");
  78. m_combostatus.AddString("已购买");
  79. if (m_comboclerk.FindString(0, m_clerk) == -1)
  80. m_comboclerk.AddString(m_clerk);
  81. m_comboclerk.SetCurSel(m_comboclerk.FindString(0, m_clerk));
  82. m_combofrom.SetCurSel(m_combofrom.FindString(0, m_from));
  83. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  84. m_combostatus.SetCurSel(m_combostatus.FindString(0, m_status));
  85. /* if(g_List1array.GetSize ())
  86. {
  87. m_bAdd=0;
  88. m_name1=g_List1array.ElementAt (0).ElementAt (1);
  89. m_name2=g_List1array.ElementAt (0).ElementAt (2);
  90. m_phone1=g_List1array.ElementAt (0).ElementAt (3);
  91. m_phone2=g_List1array.ElementAt (0).ElementAt (4);
  92. m_qq1=g_List1array.ElementAt (0).ElementAt (5);
  93. m_qq2=g_List1array.ElementAt (0).ElementAt (6);
  94. m_addr1=g_List1array.ElementAt (0).ElementAt (7);
  95. m_addr2=g_List1array.ElementAt (0).ElementAt (8);
  96. m_occupation1=g_List1array.ElementAt (0).ElementAt (9);
  97. m_occupation2=g_List1array.ElementAt (0).ElementAt (10);
  98. m_birthday1=g_List1array.ElementAt (0).ElementAt (11);
  99. m_birthday2=g_List1array.ElementAt (0).ElementAt (12);
  100. m_time3=m_List1array.ElementAt (0).ElementAt (12);
  101. m_area=g_List1array.ElementAt (0).ElementAt (13);
  102. m_area2=g_List1array.ElementAt (0).ElementAt (14);
  103. m_check1=atoi(g_List1array.ElementAt (0).ElementAt (15));
  104. m_check2=atoi(g_List1array.ElementAt (0).ElementAt (16));
  105. m_check3=atoi(g_List1array.ElementAt (0).ElementAt (17));
  106. UpdateData(false);
  107. m_comboarea.SetCurSel(m_comboarea.FindString(0,m_area));
  108. m_comboarea2.SetCurSel(m_comboarea2.FindString(0,m_area2));
  109. }*/
  110. this->CenterWindow(g_pMainWnd);
  111. return false; // return TRUE unless you set the focus to a control
  112. // EXCEPTION: OCX Property Pages should return FALSE
  113. }
  114. void AddClientLYFZ::OnButton1()
  115. {
  116. // TODO: Add your control notification handler code here
  117. SPLBDlg dlg;
  118. dlg.m_mode = 8;
  119. dlg.DoModal();
  120. m_combofrom.ResetContent();
  121. if (m_combofrom.GetCount() < 2)
  122. {
  123. g_sendhead.bsql = 0;
  124. g_sendhead.code[0] = 186;
  125. g_sendhead.tabcount = 1;
  126. g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0)return;
  127. DataToArray(&g_List1array);
  128. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  129. m_combofrom.AddString(g_List1array.ElementAt(ii).ElementAt(0));
  130. }
  131. }
  132. void AddClientLYFZ::OnOK()
  133. {
  134. // TODO: Add extra validation here
  135. UpdateData();
  136. m_name1.TrimLeft();
  137. m_name1.TrimRight();
  138. m_name2.TrimLeft();
  139. m_name2.TrimRight();
  140. m_phone1.TrimLeft();
  141. m_phone1.TrimRight();
  142. if (m_name1.IsEmpty() || m_name2.IsEmpty() || m_phone1.IsEmpty())
  143. {
  144. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
  145. }
  146. if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
  147. {
  148. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  149. return;
  150. }
  151. int pos = m_comboclerk.GetCurSel();
  152. if (pos != -1)
  153. {
  154. m_comboclerk.GetLBText(pos, m_clerk);
  155. }
  156. else
  157. m_clerk.Empty();
  158. if (m_clerk.IsEmpty())
  159. {
  160. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  161. }
  162. pos = m_comboarea.GetCurSel();
  163. if (pos != -1)
  164. {
  165. m_comboarea.GetLBText(pos, m_area);
  166. }
  167. else
  168. m_area.Empty();
  169. pos = m_combofrom.GetCurSel();
  170. if (pos != -1)
  171. {
  172. m_combofrom.GetLBText(pos, m_from);
  173. }
  174. else
  175. m_from.Empty();
  176. pos = m_combostatus.GetCurSel();
  177. if (pos != -1)
  178. {
  179. m_combostatus.GetLBText(pos, m_status);
  180. }
  181. else
  182. m_status.Empty();
  183. m_phone1.TrimLeft();
  184. m_phone1.TrimRight();
  185. if (!m_phone1.IsEmpty())
  186. {
  187. if (m_phone1.Left(1) == "1")
  188. {
  189. if (CheckPhoneType(m_phone1) == -1)
  190. {
  191. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  192. return;
  193. }
  194. }
  195. }
  196. CString strRes1, strRes2;
  197. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  198. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  199. // dlg.m_pList2array=&m_List2array;
  200. for (int i = 0; i < m_pList2array->GetSize(); i++)
  201. {
  202. if (m_bAdd == 0)
  203. {
  204. if (m_pList2array->ElementAt(i).ElementAt(0) == id)continue;
  205. }
  206. if (m_pList2array->ElementAt(i).ElementAt(3) == m_name2)
  207. {
  208. AfxMessageBox("已有此客户的记录!", MB_ICONINFORMATION);
  209. return;
  210. }
  211. if (m_pList2array->ElementAt(i).ElementAt(5) == m_phone1)
  212. {
  213. AfxMessageBox("已有此电话的记录!", MB_ICONINFORMATION);
  214. return;
  215. }
  216. }
  217. CString sql, sql2;
  218. if (m_bAdd)
  219. 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);
  220. else
  221. 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));
  222. g_sendhead.bsql = 1;
  223. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  224. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  225. CDialog::OnOK();
  226. }