BookingPage22.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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 float m_WidthScale2;
  74. extern float m_HeightScale2;
  75. extern BOOL CALLBACK EnumChildProc3(HWND hwnd,LPARAM lParam);
  76. BOOL BookingPage22::OnInitDialog()
  77. {
  78. CDialog::OnInitDialog();
  79. m_bInit=1;
  80. // TODO: Add extra initialization here
  81. CRect rc2;
  82. GetWindowRect(rc2);
  83. MoveWindow(m_rc);
  84. m_WidthScale2 = (float)m_rc.Width()/(float)rc2.Width(); // new/Old
  85. m_HeightScale2 = (float)m_rc.Height()/(float)rc2.Height();
  86. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc3,0);
  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_combozodiac.AddString ("狗");
  98. m_combozodiac.AddString ("猪");
  99. m_combosex.AddString ("男");
  100. m_combosex.AddString ("女");
  101. m_comboarea.GetWindowRect (rc2);
  102. ScreenToClient(rc2);
  103. rc2.bottom +=200;
  104. m_comboarea.MoveWindow (rc2);
  105. for(int i=0; i<m_areaarray.GetSize(); i++)
  106. {
  107. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  108. }
  109. if(((Booking2*)GetParent())->m_bModify)
  110. {
  111. if(m_comboarea.FindString (0, m_area)==-1)
  112. m_comboarea.AddString (m_area);
  113. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  114. m_combosex.SetCurSel (m_combosex.FindString (0, m_sex));
  115. m_combozodiac.SetCurSel (m_combozodiac.FindString (0, m_zodiac));
  116. }
  117. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  118. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  119. return TRUE; // return TRUE unless you set the focus to a control
  120. // EXCEPTION: OCX Property Pages should return FALSE
  121. }
  122. //
  123. // Jeff add this function;
  124. // 函数:IllegalChar
  125. // 描述:判断字符是否含有创建文件夹时的非法字符
  126. // 注:此类函数需要做为Gloabl function;
  127. //
  128. int IllegalChar(const CString &strSource)
  129. {
  130. if ( strSource.Find("\\") != -1 )
  131. {
  132. return 1;
  133. }
  134. if ( strSource.Find("/") != -1 )
  135. {
  136. return 2;
  137. }
  138. if ( strSource.Find(":") != -1 )
  139. {
  140. return 3;
  141. }
  142. if ( strSource.Find("*") != -1 )
  143. {
  144. return 4;
  145. }
  146. if ( strSource.Find("?") != -1 )
  147. {
  148. return 5;
  149. }
  150. if ( strSource.Find("\"") != -1 )
  151. {
  152. return 6;
  153. }
  154. if ( strSource.Find("<") != -1 )
  155. {
  156. return 7;
  157. }
  158. if ( strSource.Find(">") != -1 )
  159. {
  160. return 8;
  161. }
  162. if ( strSource.Find("|") != -1 )
  163. {
  164. return 9;
  165. }
  166. return 0;
  167. }
  168. BOOL BookingPage22::CheckOK()
  169. {
  170. UpdateData();
  171. m_name1.TrimLeft ();
  172. m_name1.TrimRight ();
  173. m_name2.TrimLeft ();
  174. m_name2.TrimRight ();
  175. #if 0 // original code;
  176. if(m_name1.IsEmpty() && m_name2.IsEmpty())
  177. {
  178. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return 0;
  179. }
  180. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1)
  181. {
  182. AfxMessageBox("客人名字不能有*号!", MB_ICONINFORMATION);
  183. return 0;
  184. }
  185. #else // Jeff.判断姓名是否含有创建文件夹时的非法字符;
  186. if(m_name1.IsEmpty() || m_name2.IsEmpty())
  187. {
  188. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);
  189. return 0;
  190. }
  191. if ( (IllegalChar(m_name1) != 0) || (IllegalChar(m_name2) != 0))
  192. {
  193. AfxMessageBox("姓名不能有\\ / : * ? \" < > | 字符",MB_ICONINFORMATION);
  194. return 0;
  195. }
  196. if( m_phone1.IsEmpty() || m_phone1.GetLength() != 11) // Jeff.modify:添加判断手机位数(不含小灵通之类非11位长度的手机号)
  197. {
  198. AfxMessageBox("手机不能为空或位数不是11位!", MB_ICONINFORMATION);
  199. return 0;
  200. }
  201. if( m_birthday1.IsEmpty() )
  202. {
  203. AfxMessageBox("宝宝生日不能为空!", MB_ICONINFORMATION);
  204. return 0;
  205. }
  206. #endif
  207. if(!CheckDateOK(m_birthday1))return 0;
  208. m_phone1.TrimLeft ();
  209. m_phone1.TrimRight ();
  210. m_phone2.TrimLeft ();
  211. m_phone2.TrimRight ();
  212. if(!m_phone1.IsEmpty() )
  213. {
  214. if(m_phone1.Left (1)=="1")
  215. {
  216. if(CheckPhoneType(m_phone1)==-1)
  217. {
  218. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  219. return 0;
  220. }
  221. }
  222. }
  223. if(!m_phone2.IsEmpty ())
  224. {
  225. if(m_phone2.Left (1)=="1")
  226. {
  227. if(CheckPhoneType(m_phone2)==-1)
  228. {
  229. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  230. return 0;
  231. }
  232. }
  233. }
  234. int pos=m_comboarea.GetCurSel();
  235. if(pos!=-1)
  236. m_comboarea.GetLBText(pos, m_area);
  237. else
  238. m_area.Empty();
  239. pos=m_combosex.GetCurSel();
  240. if(pos!=-1)
  241. m_combosex.GetLBText(pos, m_sex);
  242. else
  243. m_sex.Empty();
  244. pos=m_combozodiac.GetCurSel();
  245. if(pos!=-1)
  246. m_combozodiac.GetLBText(pos, m_zodiac);
  247. else
  248. m_zodiac.Empty();
  249. return 1;
  250. }
  251. void BookingPage22::NewDan()
  252. {
  253. m_addr1 = _T("");
  254. m_name1 = _T("");
  255. m_name2 = _T("");
  256. m_phone1 = _T("");
  257. m_phone2 = _T("");
  258. m_qq1 = _T("");
  259. m_birthday1 = _T("");
  260. m_zodiac = _T("");
  261. m_sex = _T("");
  262. m_area = _T("");
  263. m_check1 = FALSE;
  264. UpdateData(0);
  265. m_comboarea.SetCurSel (-1);
  266. m_combozodiac.SetCurSel (-1);
  267. m_combosex.SetCurSel (-1);
  268. }
  269. void BookingPage22::OnChangeEDITname()
  270. {
  271. // TODO: If this is a RICHEDIT control, the control will not
  272. // send this notification unless you override the CDialog::OnInitDialog()
  273. // function and call CRichEditCtrl().SetEventMask()
  274. // with the ENM_CHANGE flag ORed into the mask.
  275. CompareClient();
  276. // TODO: Add your control notification handler code here
  277. }
  278. void BookingPage22::OnChangeEDITname2()
  279. {
  280. // TODO: If this is a RICHEDIT control, the control will not
  281. // send this notification unless you override the CDialog::OnInitDialog()
  282. // function and call CRichEditCtrl().SetEventMask()
  283. // with the ENM_CHANGE flag ORed into the mask.
  284. CompareClient();
  285. // TODO: Add your control notification handler code here
  286. }
  287. void BookingPage22::OnChangeEDITphone()
  288. {
  289. // TODO: If this is a RICHEDIT control, the control will not
  290. // send this notification unless you override the CDialog::OnInitDialog()
  291. // function and call CRichEditCtrl().SetEventMask()
  292. // with the ENM_CHANGE flag ORed into the mask.
  293. CompareClient();
  294. // TODO: Add your control notification handler code here
  295. }
  296. void BookingPage22::OnChangeEDITphone2()
  297. {
  298. // TODO: If this is a RICHEDIT control, the control will not
  299. // send this notification unless you override the CDialog::OnInitDialog()
  300. // function and call CRichEditCtrl().SetEventMask()
  301. // with the ENM_CHANGE flag ORed into the mask.
  302. CompareClient();
  303. // TODO: Add your control notification handler code here
  304. }
  305. void BookingPage22::CompareClient()
  306. {
  307. if(m_bInit==0)return;
  308. UpdateData();
  309. int cot=0;
  310. m_oldclientarray.RemoveAll();
  311. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  312. {
  313. BOOL bFind=0;
  314. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  315. {
  316. bFind=1;
  317. }
  318. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  319. {
  320. bFind=0;continue;
  321. }
  322. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  323. {
  324. bFind=1;
  325. }
  326. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  327. {
  328. bFind=0;continue;
  329. }
  330. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  331. {
  332. bFind=1;
  333. }
  334. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  335. {
  336. bFind=0;continue;
  337. }
  338. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  339. {
  340. bFind=1;
  341. }
  342. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  343. {
  344. bFind=0;continue;
  345. }
  346. if(bFind)
  347. {
  348. cot++;
  349. m_oldclientarray.Add(i);
  350. }
  351. }
  352. if(cot)
  353. {
  354. CString str;
  355. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  356. SetDlgItemText(IDC_EDIT1, str);
  357. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  358. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  359. }
  360. else
  361. {
  362. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  363. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  364. }
  365. }
  366. void BookingPage22::OnButton2()
  367. {
  368. // TODO: Add your control notification handler code here
  369. ShowHistoryClient dlg;
  370. dlg.m_poldclientarray=&m_oldclientarray;
  371. if(dlg.DoModal()!=IDOK)return;
  372. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  373. // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
  374. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  375. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  376. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  377. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  378. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  379. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  380. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  381. m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
  382. m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
  383. m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
  384. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
  385. if(m_comboarea.FindString (0, m_area)==-1)
  386. m_comboarea.AddString (m_area);
  387. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  388. m_combosex.SetCurSel (m_combosex.FindString (0, m_sex));
  389. m_combozodiac.SetCurSel (m_combozodiac.FindString (0, m_zodiac));
  390. UpdateData(0);
  391. }