BookingPage2.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. /////////////////////////////////////////////////////////////////////////////
  14. // BookingPage2 dialog
  15. BookingPage2::BookingPage2(CWnd* pParent /*=NULL*/)
  16. : CDialog(BookingPage2::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(BookingPage2)
  19. // NOTE: the ClassWizard will add member initialization here
  20. m_addr1 = _T("");
  21. m_addr2 = _T("");
  22. m_name1 = _T("");
  23. m_name2 = _T("");
  24. m_occupation1 = _T("");
  25. m_occupation2 = _T("");
  26. m_phone1 = _T("");
  27. m_phone2 = _T("");
  28. m_qq1 = _T("");
  29. m_qq2 = _T("");
  30. m_birthday1 = _T("");
  31. m_birthday2 = _T("");
  32. m_time3 = _T("");
  33. m_area = _T("");
  34. m_area2 = _T("");
  35. m_check1 = FALSE;
  36. m_check2 = FALSE;
  37. m_check3 = FALSE;
  38. m_bInit=0;
  39. //}}AFX_DATA_INIT
  40. }
  41. void BookingPage2::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(BookingPage2)
  45. // NOTE: the ClassWizard will add DDX and DDV calls here
  46. DDX_Control(pDX, IDC_COMBOarea2, m_comboarea2);
  47. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  48. DDX_Control(pDX, IDC_EDITtime3, m_datectrl3);
  49. DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2);
  50. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  51. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  52. DDX_Text(pDX, IDC_EDITaddr2, m_addr2);
  53. DDX_Text(pDX, IDC_EDITname, m_name1);
  54. DDX_Text(pDX, IDC_EDITname2, m_name2);
  55. DDX_Text(pDX, IDC_EDITOccupation, m_occupation1);
  56. DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2);
  57. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  58. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  59. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  60. DDX_Text(pDX, IDC_EDITqq2, m_qq2);
  61. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  62. DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2);
  63. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  64. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  65. DDX_CBString(pDX, IDC_COMBOarea2, m_area2);
  66. DDX_Check(pDX, IDC_CHECK1, m_check1);
  67. DDX_Check(pDX, IDC_CHECK2, m_check2);
  68. DDX_Check(pDX, IDC_CHECK3, m_check3);
  69. //}}AFX_DATA_MAP
  70. }
  71. BEGIN_MESSAGE_MAP(BookingPage2, CDialog)
  72. //{{AFX_MSG_MAP(BookingPage2)
  73. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  74. ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
  75. ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
  76. ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
  77. ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
  78. //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80. /////////////////////////////////////////////////////////////////////////////
  81. // BookingPage2 message handlers
  82. void BookingPage2::OnCancel()
  83. {
  84. // TODO: Add extra cleanup here
  85. }
  86. void BookingPage2::OnOK()
  87. {
  88. // TODO: Add extra validation here
  89. }
  90. extern float m_WidthScale2;
  91. extern float m_HeightScale2;
  92. extern BOOL CALLBACK EnumChildProc3(HWND hwnd,LPARAM lParam);
  93. BOOL BookingPage2::OnInitDialog()
  94. {
  95. CDialog::OnInitDialog();
  96. // TODO: Add extra initialization here
  97. #ifdef LYFZ_VERSION
  98. GetDlgItem(IDC_STATIC1)->SetWindowText("老总姓名:");
  99. GetDlgItem(IDC_STATIC2)->SetWindowText("影楼名称:");
  100. GetDlgItem(IDC_STATIC3)->SetWindowText("快递单号:");
  101. GetDlgItem(IDC_STATIC4)->SetWindowText("短信账号:");
  102. GetDlgItem(IDC_STATIC5)->SetWindowText("域名:");
  103. GetDlgItem(IDC_STATIC6)->SetWindowText("座机:");
  104. #endif
  105. CRect rc2;
  106. GetWindowRect(rc2);
  107. MoveWindow(m_rc);
  108. m_WidthScale2 = (float)m_rc.Width()/(float)rc2.Width(); // new/Old
  109. m_HeightScale2 = (float)m_rc.Height()/(float)rc2.Height();
  110. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc3,0);
  111. m_comboarea.GetWindowRect (rc2);
  112. ScreenToClient(rc2);
  113. rc2.bottom +=200;
  114. m_comboarea.MoveWindow (rc2);
  115. m_comboarea2.GetWindowRect (rc2);
  116. ScreenToClient(rc2);
  117. rc2.bottom +=200;
  118. m_comboarea2.MoveWindow (rc2);
  119. for(int i=0; i<m_areaarray.GetSize(); i++)
  120. {
  121. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  122. m_comboarea2.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  123. }
  124. if(((Booking2*)GetParent())->m_bModify)
  125. {
  126. if(m_comboarea.FindString (0, m_area)==-1)
  127. m_comboarea.AddString (m_area);
  128. if(m_comboarea2.FindString (0, m_area2)==-1)
  129. m_comboarea2.AddString (m_area2);
  130. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  131. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  132. }
  133. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  134. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  135. m_bInit=1;
  136. return TRUE; // return TRUE unless you set the focus to a control
  137. // EXCEPTION: OCX Property Pages should return FALSE
  138. }
  139. BOOL BookingPage2::CheckOK()
  140. {
  141. UpdateData();
  142. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  143. {
  144. return 0;
  145. }
  146. if(m_phone1.IsEmpty () && m_phone2.IsEmpty ())
  147. {
  148. return 0;
  149. }
  150. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1 )
  151. {
  152. AfxMessageBox("客人名字中不能有*号!", MB_ICONINFORMATION);
  153. return 0;
  154. }
  155. if(!CheckDateOK(m_birthday1))return 0;
  156. if(!CheckDateOK(m_birthday2))return 0;
  157. if(!CheckDateOK(m_time3))return 0;
  158. m_phone1.TrimLeft ();
  159. m_phone1.TrimRight ();
  160. m_phone2.TrimLeft ();
  161. m_phone2.TrimRight ();
  162. if(!m_phone1.IsEmpty ())
  163. {
  164. if(m_phone1.Left (1)=="1")
  165. {
  166. if(CheckPhoneType(m_phone1)==-1)
  167. {
  168. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  169. return 0;
  170. }
  171. }
  172. }
  173. if(!m_phone2.IsEmpty ())
  174. {
  175. if(m_phone2.Left (1)=="1")
  176. {
  177. if(CheckPhoneType(m_phone2)==-1)
  178. {
  179. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  180. return 0;
  181. }
  182. }
  183. }
  184. int pos=m_comboarea.GetCurSel();
  185. if(pos!=-1)
  186. m_comboarea.GetLBText(pos, m_area);
  187. else
  188. m_area.Empty();
  189. pos=m_comboarea2.GetCurSel();
  190. if(pos!=-1)
  191. m_comboarea2.GetLBText(pos, m_area2);
  192. else
  193. m_area2.Empty();
  194. return 1;
  195. }
  196. void BookingPage2::NewDan()
  197. {
  198. m_addr1 = _T("");
  199. m_addr2 = _T("");
  200. m_name1 = _T("");
  201. m_name2 = _T("");
  202. m_occupation1 = _T("");
  203. m_occupation2 = _T("");
  204. m_phone1 = _T("");
  205. m_phone2 = _T("");
  206. m_qq1 = _T("");
  207. m_qq2 = _T("");
  208. m_birthday1 = _T("");
  209. m_birthday2 = _T("");
  210. m_time3 = _T("");
  211. m_area = _T("");
  212. m_area2 = _T("");
  213. m_check1 = FALSE;
  214. m_check2 = FALSE;
  215. m_check3 = FALSE;
  216. UpdateData(0);
  217. m_comboarea.SetCurSel (-1);
  218. m_comboarea2.SetCurSel (-1);
  219. }
  220. void BookingPage2::OnChangeEDITname()
  221. {
  222. // TODO: If this is a RICHEDIT control, the control will not
  223. // send this notification unless you override the CDialog::OnInitDialog()
  224. // function and call CRichEditCtrl().SetEventMask()
  225. // with the ENM_CHANGE flag ORed into the mask.
  226. CompareClient();
  227. // TODO: Add your control notification handler code here
  228. }
  229. void BookingPage2::OnChangeEDITname2()
  230. {
  231. // TODO: If this is a RICHEDIT control, the control will not
  232. // send this notification unless you override the CDialog::OnInitDialog()
  233. // function and call CRichEditCtrl().SetEventMask()
  234. // with the ENM_CHANGE flag ORed into the mask.
  235. CompareClient();
  236. // TODO: Add your control notification handler code here
  237. }
  238. void BookingPage2::OnChangeEDITphone()
  239. {
  240. // TODO: If this is a RICHEDIT control, the control will not
  241. // send this notification unless you override the CDialog::OnInitDialog()
  242. // function and call CRichEditCtrl().SetEventMask()
  243. // with the ENM_CHANGE flag ORed into the mask.
  244. CompareClient();
  245. // TODO: Add your control notification handler code here
  246. }
  247. void BookingPage2::OnChangeEDITphone2()
  248. {
  249. // TODO: If this is a RICHEDIT control, the control will not
  250. // send this notification unless you override the CDialog::OnInitDialog()
  251. // function and call CRichEditCtrl().SetEventMask()
  252. // with the ENM_CHANGE flag ORed into the mask.
  253. CompareClient();
  254. // TODO: Add your control notification handler code here
  255. }
  256. void BookingPage2::CompareClient()
  257. {
  258. if(m_bInit==0)return;
  259. UpdateData();
  260. int cot=0;
  261. m_oldclientarray.RemoveAll();
  262. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  263. {
  264. BOOL bFind=0;
  265. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  266. {
  267. bFind=1;
  268. }
  269. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  270. {
  271. bFind=0;continue;
  272. }
  273. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  274. {
  275. bFind=1;
  276. }
  277. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  278. {
  279. bFind=0;continue;
  280. }
  281. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  282. {
  283. bFind=1;
  284. }
  285. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  286. {
  287. bFind=0;continue;
  288. }
  289. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  290. {
  291. bFind=1;
  292. }
  293. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  294. {
  295. bFind=0;continue;
  296. }
  297. if(bFind)
  298. {
  299. cot++;
  300. m_oldclientarray.Add(i);
  301. }
  302. }
  303. if(cot)
  304. {
  305. CString str;
  306. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  307. SetDlgItemText(IDC_EDIT1, str);
  308. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  309. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  310. }
  311. else
  312. {
  313. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  314. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  315. }
  316. }
  317. void BookingPage2::OnButton2()
  318. {
  319. // TODO: Add your control notification handler code here
  320. ShowHistoryClient dlg;
  321. dlg.m_poldclientarray=&m_oldclientarray;
  322. if(dlg.DoModal()!=IDOK)return;
  323. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  324. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  325. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  326. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  327. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  328. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  329. m_qq2 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  330. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  331. m_addr2 = g_oldclientarray.ElementAt(pos).ElementAt(8);
  332. m_occupation1 = g_oldclientarray.ElementAt(pos).ElementAt(9);
  333. m_occupation2 = g_oldclientarray.ElementAt(pos).ElementAt(10);
  334. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(11);
  335. m_birthday2 = g_oldclientarray.ElementAt(pos).ElementAt(12);
  336. m_area = g_oldclientarray.ElementAt(pos).ElementAt(13);
  337. m_area2 = g_oldclientarray.ElementAt(pos).ElementAt(14);
  338. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(15));
  339. m_check2 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(16));
  340. m_check3 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(17));
  341. m_time3 = g_oldclientarray.ElementAt(pos).ElementAt(18);
  342. if(m_comboarea.FindString (0, m_area)==-1)
  343. m_comboarea.AddString (m_area);
  344. if(m_comboarea2.FindString (0, m_area2)==-1)
  345. m_comboarea2.AddString (m_area2);
  346. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  347. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  348. UpdateData(0);
  349. }