BookingPage22.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // BookingPage22.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "BookingPage22.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. // BookingPage22 dialog
  15. BookingPage22::BookingPage22(CWnd* pParent /*=NULL*/)
  16. : CDialog(BookingPage22::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(BookingPage22)
  19. // NOTE: the ClassWizard will add member initialization here
  20. m_addr1 = _T("");
  21. m_name1 = _T("");
  22. m_name2 = _T("");
  23. m_phone1 = _T("");
  24. m_phone2 = _T("");
  25. m_qq1 = _T("");
  26. m_birthday1 = _T("");
  27. m_zodiac = _T("");
  28. m_sex = _T("");
  29. m_area = _T("");
  30. m_check1 = FALSE;
  31. m_bInit=0;
  32. //}}AFX_DATA_INIT
  33. }
  34. void BookingPage22::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(BookingPage22)
  38. // NOTE: the ClassWizard will add DDX and DDV calls here
  39. DDX_Control(pDX, IDC_COMBOzodiac, m_combozodiac);
  40. DDX_Control(pDX, IDC_COMBOsex, m_combosex);
  41. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  42. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  43. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  44. DDX_Text(pDX, IDC_EDITname, m_name1);
  45. DDX_Text(pDX, IDC_EDITname2, m_name2);
  46. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  47. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  48. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  49. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  50. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  51. DDX_Check(pDX, IDC_CHECK1, m_check1);
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(BookingPage22, CDialog)
  55. //{{AFX_MSG_MAP(BookingPage22)
  56. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  57. ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
  58. ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
  59. ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
  60. ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // BookingPage22 message handlers
  65. void BookingPage22::OnOK()
  66. {
  67. // TODO: Add extra validation here
  68. }
  69. void BookingPage22::OnCancel()
  70. {
  71. // TODO: Add extra cleanup here
  72. }
  73. extern BOOL CALLBACK EnumChildProc3(HWND hwnd,LPARAM lParam);
  74. BOOL BookingPage22::OnInitDialog()
  75. {
  76. CDialog::OnInitDialog();
  77. m_bInit=1;
  78. // TODO: Add extra initialization here
  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_combozodiac.AddString ("鼠");
  86. m_combozodiac.AddString ("牛");
  87. m_combozodiac.AddString ("虎");
  88. m_combozodiac.AddString ("兔");
  89. m_combozodiac.AddString ("龙");
  90. m_combozodiac.AddString ("蛇");
  91. m_combozodiac.AddString ("马");
  92. m_combozodiac.AddString ("羊");
  93. m_combozodiac.AddString ("猴");
  94. m_combozodiac.AddString ("鸡");
  95. m_combozodiac.AddString ("狗");
  96. m_combozodiac.AddString ("猪");
  97. m_combosex.AddString ("男");
  98. m_combosex.AddString ("女");
  99. m_comboarea.GetWindowRect (rc2);
  100. ScreenToClient(rc2);
  101. rc2.bottom +=200;
  102. m_comboarea.MoveWindow (rc2);
  103. for(int i=0; i<m_areaarray.GetSize(); i++)
  104. {
  105. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  106. }
  107. if(((Booking2*)GetParent())->m_bModify)
  108. {
  109. if(m_comboarea.FindString (0, m_area)==-1)
  110. m_comboarea.AddString (m_area);
  111. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  112. m_combosex.SetCurSel (m_combosex.FindString (0, m_sex));
  113. m_combozodiac.SetCurSel (m_combozodiac.FindString (0, m_zodiac));
  114. }
  115. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  116. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  117. return TRUE; // return TRUE unless you set the focus to a control
  118. // EXCEPTION: OCX Property Pages should return FALSE
  119. }
  120. //
  121. // Jeff add this function;
  122. // 函数:IllegalChar
  123. // 描述:判断字符是否含有创建文件夹时的非法字符
  124. // 注:此类函数需要做为Gloabl function;
  125. //
  126. int IllegalChar(const CString &strSource)
  127. {
  128. if ( strSource.Find("\\") != -1 )
  129. {
  130. return 1;
  131. }
  132. if ( strSource.Find("/") != -1 )
  133. {
  134. return 2;
  135. }
  136. if ( strSource.Find(":") != -1 )
  137. {
  138. return 3;
  139. }
  140. if ( strSource.Find("*") != -1 )
  141. {
  142. return 4;
  143. }
  144. if ( strSource.Find("?") != -1 )
  145. {
  146. return 5;
  147. }
  148. if ( strSource.Find("\"") != -1 )
  149. {
  150. return 6;
  151. }
  152. if ( strSource.Find("<") != -1 )
  153. {
  154. return 7;
  155. }
  156. if ( strSource.Find(">") != -1 )
  157. {
  158. return 8;
  159. }
  160. if ( strSource.Find("|") != -1 )
  161. {
  162. return 9;
  163. }
  164. return 0;
  165. }
  166. BOOL BookingPage22::CheckOK()
  167. {
  168. UpdateData();
  169. m_name1.TrimLeft ();
  170. m_name1.TrimRight ();
  171. m_name2.TrimLeft ();
  172. m_name2.TrimRight ();
  173. #if 0 // original code;
  174. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  175. {
  176. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return 0;
  177. }
  178. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1)
  179. {
  180. AfxMessageBox("客人名字不能有*号!", MB_ICONINFORMATION);
  181. return 0;
  182. }
  183. #else // Jeff.判断姓名是否含有创建文件夹时的非法字符;
  184. if(m_name1.IsEmpty() /*|| m_name2.IsEmpty()*/)
  185. {
  186. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);
  187. return 0;
  188. }
  189. if ( (IllegalChar(m_name1) != 0) || (IllegalChar(m_name2) != 0))
  190. {
  191. AfxMessageBox("姓名不能有\\ / : * ? \" < > | 字符",MB_ICONINFORMATION);
  192. return 0;
  193. }
  194. if( m_phone1.IsEmpty() || m_phone1.GetLength() != 11) // Jeff.modify:添加判断手机位数(不含小灵通之类非11位长度的手机号)
  195. {
  196. AfxMessageBox("手机不能为空或位数不是11位!", MB_ICONINFORMATION);
  197. return 0;
  198. }
  199. /*if( m_birthday1.IsEmpty() )
  200. {
  201. AfxMessageBox("宝宝生日不能为空!", MB_ICONINFORMATION);
  202. return 0;
  203. }*/
  204. #endif
  205. if(!CheckDateOK(m_birthday1))return 0;
  206. m_phone1.TrimLeft ();
  207. m_phone1.TrimRight ();
  208. m_phone2.TrimLeft ();
  209. m_phone2.TrimRight ();
  210. if(!m_phone1.IsEmpty ())
  211. {
  212. if(m_phone1.Left (1)=="1")
  213. {
  214. if(CheckPhoneType(m_phone1)==-1)
  215. {
  216. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  217. return 0;
  218. }
  219. }
  220. }
  221. if(!m_phone2.IsEmpty ())
  222. {
  223. if(m_phone2.Left (1)=="1")
  224. {
  225. if(CheckPhoneType(m_phone2)==-1)
  226. {
  227. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  228. return 0;
  229. }
  230. }
  231. }
  232. int pos=m_comboarea.GetCurSel();
  233. if(pos!=-1)
  234. m_comboarea.GetLBText(pos, m_area);
  235. else
  236. m_area.Empty();
  237. pos=m_combosex.GetCurSel();
  238. if(pos!=-1)
  239. m_combosex.GetLBText(pos, m_sex);
  240. else
  241. m_sex.Empty();
  242. pos=m_combozodiac.GetCurSel();
  243. if(pos!=-1)
  244. m_combozodiac.GetLBText(pos, m_zodiac);
  245. else
  246. m_zodiac.Empty();
  247. return 1;
  248. }
  249. void BookingPage22::NewDan()
  250. {
  251. m_addr1 = _T("");
  252. m_name1 = _T("");
  253. m_name2 = _T("");
  254. m_phone1 = _T("");
  255. m_phone2 = _T("");
  256. m_qq1 = _T("");
  257. m_birthday1 = _T("");
  258. m_zodiac = _T("");
  259. m_sex = _T("");
  260. m_area = _T("");
  261. m_check1 = FALSE;
  262. UpdateData(0);
  263. m_comboarea.SetCurSel (-1);
  264. m_combozodiac.SetCurSel (-1);
  265. m_combosex.SetCurSel (-1);
  266. }
  267. void BookingPage22::OnChangeEDITname()
  268. {
  269. // TODO: If this is a RICHEDIT control, the control will not
  270. // send this notification unless you override the CDialog::OnInitDialog()
  271. // function and call CRichEditCtrl().SetEventMask()
  272. // with the ENM_CHANGE flag ORed into the mask.
  273. CompareClient();
  274. // TODO: Add your control notification handler code here
  275. }
  276. void BookingPage22::OnChangeEDITname2()
  277. {
  278. // TODO: If this is a RICHEDIT control, the control will not
  279. // send this notification unless you override the CDialog::OnInitDialog()
  280. // function and call CRichEditCtrl().SetEventMask()
  281. // with the ENM_CHANGE flag ORed into the mask.
  282. CompareClient();
  283. // TODO: Add your control notification handler code here
  284. }
  285. void BookingPage22::OnChangeEDITphone()
  286. {
  287. // TODO: If this is a RICHEDIT control, the control will not
  288. // send this notification unless you override the CDialog::OnInitDialog()
  289. // function and call CRichEditCtrl().SetEventMask()
  290. // with the ENM_CHANGE flag ORed into the mask.
  291. CompareClient();
  292. // TODO: Add your control notification handler code here
  293. }
  294. void BookingPage22::OnChangeEDITphone2()
  295. {
  296. // TODO: If this is a RICHEDIT control, the control will not
  297. // send this notification unless you override the CDialog::OnInitDialog()
  298. // function and call CRichEditCtrl().SetEventMask()
  299. // with the ENM_CHANGE flag ORed into the mask.
  300. CompareClient();
  301. // TODO: Add your control notification handler code here
  302. }
  303. void BookingPage22::CompareClient()
  304. {
  305. if(m_bInit==0)return;
  306. UpdateData();
  307. int cot=0;
  308. m_oldclientarray.RemoveAll();
  309. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  310. {
  311. BOOL bFind=0;
  312. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  313. {
  314. bFind=1;
  315. }
  316. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  317. {
  318. bFind=0;continue;
  319. }
  320. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  321. {
  322. bFind=1;
  323. }
  324. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  325. {
  326. bFind=0;continue;
  327. }
  328. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  329. {
  330. bFind=1;
  331. }
  332. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  333. {
  334. bFind=0;continue;
  335. }
  336. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  337. {
  338. bFind=1;
  339. }
  340. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  341. {
  342. bFind=0;continue;
  343. }
  344. if(bFind)
  345. {
  346. cot++;
  347. m_oldclientarray.Add(i);
  348. }
  349. }
  350. if(cot)
  351. {
  352. CString str;
  353. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  354. SetDlgItemText(IDC_EDIT1, str);
  355. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  356. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  357. }
  358. else
  359. {
  360. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  361. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  362. }
  363. }
  364. void BookingPage22::OnButton2()
  365. {
  366. // TODO: Add your control notification handler code here
  367. ShowHistoryClient dlg;
  368. dlg.m_poldclientarray=&m_oldclientarray;
  369. if(dlg.DoModal()!=IDOK)return;
  370. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  371. // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
  372. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  373. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  374. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  375. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  376. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  377. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  378. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  379. m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
  380. m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
  381. m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
  382. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
  383. if(m_comboarea.FindString (0, m_area)==-1)
  384. m_comboarea.AddString (m_area);
  385. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  386. m_combosex.SetCurSel (m_combosex.FindString (0, m_sex));
  387. m_combozodiac.SetCurSel (m_combozodiac.FindString (0, m_zodiac));
  388. UpdateData(0);
  389. }