BookingPage2.cpp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. #ifdef LYFZ_VERSION
  80. GetDlgItem(IDC_STATIC1)->SetWindowText("老总姓名:");
  81. GetDlgItem(IDC_STATIC2)->SetWindowText("影楼名称:");
  82. GetDlgItem(IDC_STATIC3)->SetWindowText("快递单号:");
  83. GetDlgItem(IDC_STATIC4)->SetWindowText("短信账号:");
  84. GetDlgItem(IDC_STATIC5)->SetWindowText("域名:");
  85. GetDlgItem(IDC_STATIC6)->SetWindowText("座机:");
  86. #endif
  87. CRect rc2;
  88. GetWindowRect(rc2);
  89. MoveWindow(m_rc);
  90. g_WidthScale2 = (float)m_rc.Width()/(float)rc2.Width(); // new/Old
  91. g_HeightScale2 = (float)m_rc.Height()/(float)rc2.Height();
  92. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc3,0);
  93. m_comboarea.GetWindowRect (rc2);
  94. ScreenToClient(rc2);
  95. rc2.bottom +=200;
  96. m_comboarea.MoveWindow (rc2);
  97. m_comboarea2.GetWindowRect (rc2);
  98. ScreenToClient(rc2);
  99. rc2.bottom +=200;
  100. m_comboarea2.MoveWindow (rc2);
  101. for(int i=0; i<m_areaarray.GetSize(); i++)
  102. {
  103. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  104. m_comboarea2.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  105. }
  106. if(((Booking2*)GetParent())->m_bModify)
  107. {
  108. if(m_comboarea.FindString (0, m_area)==-1)
  109. m_comboarea.AddString (m_area);
  110. if(m_comboarea2.FindString (0, m_area2)==-1)
  111. m_comboarea2.AddString (m_area2);
  112. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  113. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  114. }
  115. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  116. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  117. m_bInit=1;
  118. return TRUE;
  119. }
  120. BOOL BookingPage2::CheckOK()
  121. {
  122. UpdateData();
  123. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  124. {
  125. return 0;
  126. }
  127. if(m_phone1.IsEmpty () && m_phone2.IsEmpty ())
  128. {
  129. return 0;
  130. }
  131. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1 )
  132. {
  133. AfxMessageBox("客人名字中不能有*号!", MB_ICONINFORMATION);
  134. return 0;
  135. }
  136. if (!CheckDateOK(m_birthday1, m_check1))
  137. {
  138. AfxMessageBox("日期无效:" + m_birthday1, MB_ICONINFORMATION);
  139. return 0;
  140. }
  141. if (!CheckDateOK(m_birthday2, m_check2))
  142. {
  143. AfxMessageBox("日期无效:" + m_birthday2 , MB_ICONINFORMATION);
  144. return 0;
  145. }
  146. if (!CheckDateOK(m_time3, m_check3))
  147. {
  148. AfxMessageBox("日期无效:" + m_time3 , MB_ICONINFORMATION);
  149. return 0;
  150. }
  151. m_phone1.TrimLeft ();
  152. m_phone1.TrimRight ();
  153. m_phone2.TrimLeft ();
  154. m_phone2.TrimRight ();
  155. if(!m_phone1.IsEmpty ())
  156. {
  157. if(m_phone1.Left (1)=="1")
  158. {
  159. if(CheckPhoneType(m_phone1)==-1)
  160. {
  161. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  162. return 0;
  163. }
  164. }
  165. }
  166. if(!m_phone2.IsEmpty ())
  167. {
  168. if(m_phone2.Left (1)=="1")
  169. {
  170. if(CheckPhoneType(m_phone2)==-1)
  171. {
  172. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  173. return 0;
  174. }
  175. }
  176. }
  177. int pos=m_comboarea.GetCurSel();
  178. if(pos!=-1)
  179. m_comboarea.GetLBText(pos, m_area);
  180. else
  181. m_area.Empty();
  182. pos=m_comboarea2.GetCurSel();
  183. if(pos!=-1)
  184. m_comboarea2.GetLBText(pos, m_area2);
  185. else
  186. m_area2.Empty();
  187. return 1;
  188. }
  189. void BookingPage2::NewDan()
  190. {
  191. m_addr1 = _T("");
  192. m_addr2 = _T("");
  193. m_name1 = _T("");
  194. m_name2 = _T("");
  195. m_occupation1 = _T("");
  196. m_occupation2 = _T("");
  197. m_phone1 = _T("");
  198. m_phone2 = _T("");
  199. m_qq1 = _T("");
  200. m_qq2 = _T("");
  201. m_birthday1 = _T("");
  202. m_birthday2 = _T("");
  203. m_time3 = _T("");
  204. m_area = _T("");
  205. m_area2 = _T("");
  206. m_check1 = FALSE;
  207. m_check2 = FALSE;
  208. m_check3 = FALSE;
  209. UpdateData(0);
  210. m_comboarea.SetCurSel (-1);
  211. m_comboarea2.SetCurSel (-1);
  212. }
  213. void BookingPage2::OnChangeEDITname()
  214. {
  215. CompareClient();
  216. }
  217. void BookingPage2::OnChangeEDITname2()
  218. {
  219. CompareClient();
  220. }
  221. void BookingPage2::OnChangeEDITphone()
  222. {
  223. CompareClient();
  224. }
  225. void BookingPage2::OnChangeEDITphone2()
  226. {
  227. CompareClient();
  228. }
  229. void BookingPage2::CompareClient()
  230. {
  231. if(m_bInit==0)return;
  232. UpdateData();
  233. int cot=0;
  234. m_oldclientarray.RemoveAll();
  235. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  236. {
  237. BOOL bFind=0;
  238. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  239. {
  240. bFind=1;
  241. }
  242. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  243. {
  244. bFind=0;continue;
  245. }
  246. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  247. {
  248. bFind=1;
  249. }
  250. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  251. {
  252. bFind=0;continue;
  253. }
  254. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  255. {
  256. bFind=1;
  257. }
  258. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  259. {
  260. bFind=0;continue;
  261. }
  262. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  263. {
  264. bFind=1;
  265. }
  266. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  267. {
  268. bFind=0;continue;
  269. }
  270. if(bFind)
  271. {
  272. cot++;
  273. m_oldclientarray.Add(i);
  274. }
  275. }
  276. if(cot)
  277. {
  278. CString str;
  279. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  280. SetDlgItemText(IDC_EDIT1, str);
  281. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  282. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  283. }
  284. else
  285. {
  286. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  287. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  288. }
  289. }
  290. void BookingPage2::OnButton2()
  291. {
  292. ShowHistoryClient dlg;
  293. dlg.m_poldclientarray=&m_oldclientarray;
  294. if(dlg.DoModal()!=IDOK)return;
  295. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  296. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  297. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  298. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  299. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  300. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  301. m_qq2 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  302. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  303. m_addr2 = g_oldclientarray.ElementAt(pos).ElementAt(8);
  304. m_occupation1 = g_oldclientarray.ElementAt(pos).ElementAt(9);
  305. m_occupation2 = g_oldclientarray.ElementAt(pos).ElementAt(10);
  306. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(11);
  307. m_birthday2 = g_oldclientarray.ElementAt(pos).ElementAt(12);
  308. m_area = g_oldclientarray.ElementAt(pos).ElementAt(13);
  309. m_area2 = g_oldclientarray.ElementAt(pos).ElementAt(14);
  310. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(15));
  311. m_check2 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(16));
  312. m_check3 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(17));
  313. m_time3 = g_oldclientarray.ElementAt(pos).ElementAt(18);
  314. if(m_comboarea.FindString (0, m_area)==-1)
  315. m_comboarea.AddString (m_area);
  316. if(m_comboarea2.FindString (0, m_area2)==-1)
  317. m_comboarea2.AddString (m_area2);
  318. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  319. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  320. UpdateData(0);
  321. }