BookingPage2.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. // BookingPage2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "BookingPage2.h"
  6. #include "Booking2.h"
  7. #include "ShowHistoryClient.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. BookingPage2::BookingPage2(CWnd* pParent /*=NULL*/): CDialog(BookingPage2::IDD, pParent)
  14. {
  15. m_addr1 = _T("");
  16. m_addr2 = _T("");
  17. m_name1 = _T("");
  18. m_name2 = _T("");
  19. m_occupation1 = _T("");
  20. m_occupation2 = _T("");
  21. m_phone1 = _T("");
  22. m_phone2 = _T("");
  23. m_qq1 = _T("");
  24. m_qq2 = _T("");
  25. m_birthday1 = _T("");
  26. m_birthday2 = _T("");
  27. m_time3 = _T("");
  28. m_area = _T("");
  29. m_area2 = _T("");
  30. m_check1 = FALSE;
  31. m_check2 = FALSE;
  32. m_check3 = FALSE;
  33. m_bInit=0;
  34. }
  35. void BookingPage2::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. DDX_Control(pDX, IDC_COMBOarea2, m_comboarea2);
  39. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  40. DDX_Control(pDX, IDC_EDITtime3, m_datectrl3);
  41. DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2);
  42. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  43. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  44. DDX_Text(pDX, IDC_EDITaddr2, m_addr2);
  45. DDX_Text(pDX, IDC_EDITname, m_name1);
  46. DDX_Text(pDX, IDC_EDITname2, m_name2);
  47. DDX_Text(pDX, IDC_EDITOccupation, m_occupation1);
  48. DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2);
  49. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  50. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  51. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  52. DDX_Text(pDX, IDC_EDITqq2, m_qq2);
  53. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  54. DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2);
  55. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  56. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  57. DDX_CBString(pDX, IDC_COMBOarea2, m_area2);
  58. DDX_Check(pDX, IDC_CHECK1, m_check1);
  59. DDX_Check(pDX, IDC_CHECK2, m_check2);
  60. DDX_Check(pDX, IDC_CHECK3, m_check3);
  61. }
  62. BEGIN_MESSAGE_MAP(BookingPage2, CDialog)
  63. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  64. ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
  65. ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
  66. ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
  67. ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
  68. END_MESSAGE_MAP()
  69. void BookingPage2::OnCancel()
  70. {
  71. }
  72. void BookingPage2::OnOK()
  73. {
  74. }
  75. extern BOOL CALLBACK EnumChildProc3(HWND hwnd,LPARAM lParam);
  76. BOOL BookingPage2::OnInitDialog()
  77. {
  78. CDialog::OnInitDialog();
  79. CRect rc2;
  80. GetWindowRect(rc2);
  81. MoveWindow(m_rc);
  82. g_WidthScale2 = (float)m_rc.Width()/(float)rc2.Width(); // new/Old
  83. g_HeightScale2 = (float)m_rc.Height()/(float)rc2.Height();
  84. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc3,0);
  85. m_comboarea.GetWindowRect (rc2);
  86. ScreenToClient(rc2);
  87. rc2.bottom +=200;
  88. m_comboarea.MoveWindow (rc2);
  89. m_comboarea2.GetWindowRect (rc2);
  90. ScreenToClient(rc2);
  91. rc2.bottom +=200;
  92. m_comboarea2.MoveWindow (rc2);
  93. for(int i=0; i<m_areaarray.GetSize(); i++)
  94. {
  95. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  96. m_comboarea2.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  97. }
  98. if(((Booking2*)GetParent())->m_bModify)
  99. {
  100. if(m_comboarea.FindString (0, m_area)==-1)
  101. m_comboarea.AddString (m_area);
  102. if(m_comboarea2.FindString (0, m_area2)==-1)
  103. m_comboarea2.AddString (m_area2);
  104. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  105. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  106. }
  107. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  108. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  109. m_bInit=1;
  110. return TRUE;
  111. }
  112. BOOL BookingPage2::CheckOK()
  113. {
  114. UpdateData();
  115. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  116. {
  117. return 0;
  118. }
  119. if(m_phone1.IsEmpty () && m_phone2.IsEmpty ())
  120. {
  121. return 0;
  122. }
  123. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1 )
  124. {
  125. AfxMessageBox("客人名字中不能有*号!", MB_ICONINFORMATION);
  126. return 0;
  127. }
  128. if (!CheckDateOK(m_birthday1, m_check1))
  129. {
  130. AfxMessageBox("日期无效:" + m_birthday1, MB_ICONINFORMATION);
  131. return 0;
  132. }
  133. if (!CheckDateOK(m_birthday2, m_check2))
  134. {
  135. AfxMessageBox("日期无效:" + m_birthday2 , MB_ICONINFORMATION);
  136. return 0;
  137. }
  138. if (!CheckDateOK(m_time3, m_check3))
  139. {
  140. AfxMessageBox("日期无效:" + m_time3 , MB_ICONINFORMATION);
  141. return 0;
  142. }
  143. m_phone1.TrimLeft ();
  144. m_phone1.TrimRight ();
  145. m_phone2.TrimLeft ();
  146. m_phone2.TrimRight ();
  147. if(!m_phone1.IsEmpty ())
  148. {
  149. if(m_phone1.Left (1)=="1")
  150. {
  151. if(CheckPhoneType(m_phone1)==-1)
  152. {
  153. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  154. return 0;
  155. }
  156. }
  157. }
  158. if(!m_phone2.IsEmpty ())
  159. {
  160. if(m_phone2.Left (1)=="1")
  161. {
  162. if(CheckPhoneType(m_phone2)==-1)
  163. {
  164. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  165. return 0;
  166. }
  167. }
  168. }
  169. int pos=m_comboarea.GetCurSel();
  170. if(pos!=-1)
  171. m_comboarea.GetLBText(pos, m_area);
  172. else
  173. m_area.Empty();
  174. pos=m_comboarea2.GetCurSel();
  175. if(pos!=-1)
  176. m_comboarea2.GetLBText(pos, m_area2);
  177. else
  178. m_area2.Empty();
  179. return 1;
  180. }
  181. void BookingPage2::NewDan()
  182. {
  183. m_addr1 = _T("");
  184. m_addr2 = _T("");
  185. m_name1 = _T("");
  186. m_name2 = _T("");
  187. m_occupation1 = _T("");
  188. m_occupation2 = _T("");
  189. m_phone1 = _T("");
  190. m_phone2 = _T("");
  191. m_qq1 = _T("");
  192. m_qq2 = _T("");
  193. m_birthday1 = _T("");
  194. m_birthday2 = _T("");
  195. m_time3 = _T("");
  196. m_area = _T("");
  197. m_area2 = _T("");
  198. m_check1 = FALSE;
  199. m_check2 = FALSE;
  200. m_check3 = FALSE;
  201. UpdateData(0);
  202. m_comboarea.SetCurSel (-1);
  203. m_comboarea2.SetCurSel (-1);
  204. }
  205. void BookingPage2::OnChangeEDITname()
  206. {
  207. CompareClient();
  208. }
  209. void BookingPage2::OnChangeEDITname2()
  210. {
  211. CompareClient();
  212. }
  213. void BookingPage2::OnChangeEDITphone()
  214. {
  215. CompareClient();
  216. }
  217. void BookingPage2::OnChangeEDITphone2()
  218. {
  219. CompareClient();
  220. }
  221. void BookingPage2::CompareClient()
  222. {
  223. if(m_bInit==0)return;
  224. UpdateData();
  225. int cot=0;
  226. m_oldclientarray.RemoveAll();
  227. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  228. {
  229. BOOL bFind=0;
  230. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  231. {
  232. bFind=1;
  233. }
  234. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  235. {
  236. bFind=0;continue;
  237. }
  238. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  239. {
  240. bFind=1;
  241. }
  242. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  243. {
  244. bFind=0;continue;
  245. }
  246. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  247. {
  248. bFind=1;
  249. }
  250. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  251. {
  252. bFind=0;continue;
  253. }
  254. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  255. {
  256. bFind=1;
  257. }
  258. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  259. {
  260. bFind=0;continue;
  261. }
  262. if(bFind)
  263. {
  264. cot++;
  265. m_oldclientarray.Add(i);
  266. }
  267. }
  268. if(cot)
  269. {
  270. CString str;
  271. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  272. SetDlgItemText(IDC_EDIT1, str);
  273. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  274. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  275. }
  276. else
  277. {
  278. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  279. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  280. }
  281. }
  282. void BookingPage2::OnButton2()
  283. {
  284. ShowHistoryClient dlg;
  285. dlg.m_poldclientarray=&m_oldclientarray;
  286. if(dlg.DoModal()!=IDOK)return;
  287. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  288. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  289. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  290. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  291. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  292. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  293. m_qq2 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  294. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  295. m_addr2 = g_oldclientarray.ElementAt(pos).ElementAt(8);
  296. m_occupation1 = g_oldclientarray.ElementAt(pos).ElementAt(9);
  297. m_occupation2 = g_oldclientarray.ElementAt(pos).ElementAt(10);
  298. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(11);
  299. m_birthday2 = g_oldclientarray.ElementAt(pos).ElementAt(12);
  300. m_area = g_oldclientarray.ElementAt(pos).ElementAt(13);
  301. m_area2 = g_oldclientarray.ElementAt(pos).ElementAt(14);
  302. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(15));
  303. m_check2 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(16));
  304. m_check3 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(17));
  305. m_time3 = g_oldclientarray.ElementAt(pos).ElementAt(18);
  306. if(m_comboarea.FindString (0, m_area)==-1)
  307. m_comboarea.AddString (m_area);
  308. if(m_comboarea2.FindString (0, m_area2)==-1)
  309. m_comboarea2.AddString (m_area2);
  310. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  311. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  312. UpdateData(0);
  313. }