BookingPage22.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. BookingPage22::BookingPage22(CWnd* pParent) :CDialog(BookingPage22::IDD, pParent)
  14. {
  15. m_addr1 = _T("");
  16. m_name1 = _T("");
  17. m_name2 = _T("");
  18. m_phone1 = _T("");
  19. m_phone2 = _T("");
  20. m_qq1 = _T("");
  21. m_birthday1 = _T("");
  22. m_zodiac = _T("");
  23. m_sex = _T("");
  24. m_area = _T("");
  25. m_check1 = FALSE;
  26. m_bInit = 0;
  27. }
  28. void BookingPage22::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CDialog::DoDataExchange(pDX);
  31. DDX_Control(pDX, IDC_COMBOzodiac, m_combozodiac);
  32. DDX_Control(pDX, IDC_COMBOsex, m_combosex);
  33. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  34. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  35. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  36. DDX_Text(pDX, IDC_EDITname, m_name1);
  37. DDX_Text(pDX, IDC_EDITname2, m_name2);
  38. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  39. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  40. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  41. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  42. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  43. DDX_Check(pDX, IDC_CHECK1, m_check1);
  44. }
  45. BEGIN_MESSAGE_MAP(BookingPage22, CDialog)
  46. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  47. ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
  48. ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
  49. ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
  50. ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
  51. ON_WM_CTLCOLOR()
  52. END_MESSAGE_MAP()
  53. void BookingPage22::OnOK()
  54. {
  55. }
  56. void BookingPage22::OnCancel()
  57. {
  58. }
  59. extern BOOL CALLBACK EnumChildProc3(HWND hwnd, LPARAM lParam);
  60. BOOL BookingPage22::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. m_bInit = 1;
  64. CRect rc2;
  65. GetWindowRect(rc2);
  66. MoveWindow(m_rc);
  67. g_WidthScale2 = (float)m_rc.Width() / (float)rc2.Width(); // new/Old
  68. g_HeightScale2 = (float)m_rc.Height() / (float)rc2.Height();
  69. //EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProcBPage2, 0);
  70. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc3, 0);
  71. m_combozodiac.AddString("鼠");
  72. m_combozodiac.AddString("牛");
  73. m_combozodiac.AddString("虎");
  74. m_combozodiac.AddString("兔");
  75. m_combozodiac.AddString("龙");
  76. m_combozodiac.AddString("蛇");
  77. m_combozodiac.AddString("马");
  78. m_combozodiac.AddString("羊");
  79. m_combozodiac.AddString("猴");
  80. m_combozodiac.AddString("鸡");
  81. m_combozodiac.AddString("狗");
  82. m_combozodiac.AddString("猪");
  83. m_combosex.AddString("男");
  84. m_combosex.AddString("女");
  85. #if defined(VC70) || defined(VC80)
  86. m_combozodiac.GetWindowRect(rc2);
  87. rc2.bottom += 300;
  88. ScreenToClient(rc2);
  89. m_combozodiac.MoveWindow(rc2);
  90. m_combosex.GetWindowRect(rc2);
  91. rc2.bottom += 300;
  92. ScreenToClient(rc2);
  93. m_combosex.MoveWindow(rc2);
  94. m_comboarea.GetWindowRect(rc2);
  95. ScreenToClient(rc2);
  96. rc2.bottom += 200;
  97. m_comboarea.MoveWindow(rc2);
  98. #endif
  99. for (int i = 0; i < m_areaarray.GetSize(); i++)
  100. {
  101. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  102. }
  103. if (((Booking2*)GetParent())->m_bModify)
  104. {
  105. if (m_comboarea.FindString(0, m_area) == -1)
  106. m_comboarea.AddString(m_area);
  107. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  108. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  109. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  110. }
  111. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  112. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  113. return TRUE;
  114. }
  115. // 只改变位置,不改变高度;
  116. // 填充式?
  117. BOOL BookingPage22::EnumChildProcBPage2(HWND hwnd,LPARAM lParam)
  118. {
  119. CRect rtCtrl,rtWnd;
  120. static float fWidthScale = ((float)g_rc.Width()) / 720.0;
  121. static float fHeightScale = ((float)g_rc.Height()) / 430.0;
  122. if(hwnd)
  123. {
  124. TCHAR szClassName[MAX_PATH];
  125. ::GetClassName(hwnd, szClassName, MAX_PATH);
  126. ::GetWindowRect(hwnd,&rtCtrl);
  127. ::GetWindowRect(::GetParent(hwnd),&rtWnd);
  128. rtCtrl.OffsetRect(-rtWnd.left,-rtWnd.top);
  129. float temp;
  130. temp= (float)rtCtrl.left*fWidthScale;
  131. rtCtrl.left = (int)temp;
  132. temp= (float)rtCtrl.top*fHeightScale;
  133. rtCtrl.top = (int)temp;
  134. temp = (float)rtCtrl.right*fWidthScale;
  135. rtCtrl.right = (int)temp;
  136. temp =(float)rtCtrl.bottom*fHeightScale;
  137. rtCtrl.bottom =(int)temp;
  138. ::MoveWindow(hwnd,rtCtrl.left,rtCtrl.top,rtCtrl.Width(),rtCtrl.Height(),TRUE);
  139. return TRUE;
  140. }
  141. else
  142. {
  143. return FALSE;
  144. }
  145. }
  146. //
  147. // Jeff add this function;
  148. // 函数:IllegalChar
  149. // 描述:判断字符是否含有创建文件夹时的非法字符
  150. // 注:此类函数需要做为Gloabl function;
  151. //
  152. int IllegalChar(const CString &strSource)
  153. {
  154. if (strSource.Find("\\") != -1)
  155. {
  156. return 1;
  157. }
  158. if (strSource.Find("/") != -1)
  159. {
  160. return 2;
  161. }
  162. if (strSource.Find(":") != -1)
  163. {
  164. return 3;
  165. }
  166. if (strSource.Find("*") != -1)
  167. {
  168. return 4;
  169. }
  170. if (strSource.Find("?") != -1)
  171. {
  172. return 5;
  173. }
  174. if (strSource.Find("\"") != -1)
  175. {
  176. return 6;
  177. }
  178. if (strSource.Find("<") != -1)
  179. {
  180. return 7;
  181. }
  182. if (strSource.Find(">") != -1)
  183. {
  184. return 8;
  185. }
  186. if (strSource.Find("|") != -1)
  187. {
  188. return 9;
  189. }
  190. return 0;
  191. }
  192. BOOL BookingPage22::CheckOK()
  193. {
  194. UpdateData();
  195. m_name1.TrimLeft();
  196. m_name1.TrimRight();
  197. m_name2.TrimLeft();
  198. m_name2.TrimRight();
  199. #if 0 // original code;
  200. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  201. {
  202. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return 0;
  203. }
  204. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1)
  205. {
  206. AfxMessageBox("客人名字不能有*号!", MB_ICONINFORMATION);
  207. return 0;
  208. }
  209. #else // Jeff.判断姓名是否含有创建文件夹时的非法字符;
  210. if (m_name1.IsEmpty() /*|| m_name2.IsEmpty()*/)
  211. {
  212. AfxMessageBox("家长姓名不能为空!", MB_ICONINFORMATION);
  213. return 0;
  214. }
  215. if ((IllegalChar(m_name1) != 0) || (IllegalChar(m_name2) != 0))
  216. {
  217. AfxMessageBox("姓名不能有\\ / : * ? \" < > | 字符", MB_ICONINFORMATION);
  218. return 0;
  219. }
  220. // 2014.12.18 有客户反应儿童版本手机必填不合理,担心手机信息会泄露了或收到影楼的广告短信什么的;
  221. if (m_phone1.IsEmpty() || m_phone1.GetLength() != 11) // Jeff.modify:添加判断手机位数(不含小灵通之类非11位长度的手机号)
  222. {
  223. AfxMessageBox("手机不能为空或位数不是11位!", MB_ICONINFORMATION);
  224. return 0;
  225. }
  226. /*
  227. if( m_birthday1.IsEmpty() )
  228. {
  229. AfxMessageBox("宝宝生日不能为空!", MB_ICONINFORMATION);
  230. return 0;
  231. }
  232. */
  233. #endif
  234. if (!CheckDateOK(m_birthday1, m_check1))
  235. {
  236. AfxMessageBox("日期无效:" + m_birthday1, MB_ICONINFORMATION);
  237. return 0;
  238. }
  239. m_phone1.TrimLeft();
  240. m_phone1.TrimRight();
  241. m_phone2.TrimLeft();
  242. m_phone2.TrimRight();
  243. if (!m_phone1.IsEmpty())
  244. {
  245. if (m_phone1.Left(1) == "1")
  246. {
  247. if (CheckPhoneType(m_phone1) == -1)
  248. {
  249. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  250. return 0;
  251. }
  252. }
  253. }
  254. if (!m_phone2.IsEmpty())
  255. {
  256. if (m_phone2.Left(1) == "1")
  257. {
  258. if (CheckPhoneType(m_phone2) == -1)
  259. {
  260. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  261. return 0;
  262. }
  263. }
  264. }
  265. int pos = m_comboarea.GetCurSel();
  266. if (pos != -1)
  267. m_comboarea.GetLBText(pos, m_area);
  268. else
  269. m_area.Empty();
  270. pos = m_combosex.GetCurSel();
  271. if (pos != -1)
  272. m_combosex.GetLBText(pos, m_sex);
  273. else
  274. m_sex.Empty();
  275. pos = m_combozodiac.GetCurSel();
  276. if (pos != -1)
  277. m_combozodiac.GetLBText(pos, m_zodiac);
  278. else
  279. m_zodiac.Empty();
  280. return 1;
  281. }
  282. void BookingPage22::NewDan()
  283. {
  284. m_addr1 = _T("");
  285. m_name1 = _T("");
  286. m_name2 = _T("");
  287. m_phone1 = _T("");
  288. m_phone2 = _T("");
  289. m_qq1 = _T("");
  290. m_birthday1 = _T("");
  291. m_zodiac = _T("");
  292. m_sex = _T("");
  293. m_area = _T("");
  294. m_check1 = FALSE;
  295. UpdateData(0);
  296. m_comboarea.SetCurSel(-1);
  297. m_combozodiac.SetCurSel(-1);
  298. m_combosex.SetCurSel(-1);
  299. }
  300. void BookingPage22::OnChangeEDITname()
  301. {
  302. CompareClient();
  303. }
  304. void BookingPage22::OnChangeEDITname2()
  305. {
  306. CompareClient();
  307. }
  308. void BookingPage22::OnChangeEDITphone()
  309. {
  310. CompareClient();
  311. }
  312. void BookingPage22::OnChangeEDITphone2()
  313. {
  314. CompareClient();
  315. }
  316. void BookingPage22::CompareClient()
  317. {
  318. if (m_bInit == 0)return;
  319. UpdateData();
  320. int cot = 0;
  321. m_oldclientarray.RemoveAll();
  322. for (int i = 0; i < g_oldclientarray.GetSize(); i++)
  323. {
  324. BOOL bFind = 0;
  325. if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) != -1 && m_name1 != "")
  326. {
  327. bFind = 1;
  328. }
  329. else if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) == -1 && m_name1 != "")
  330. {
  331. bFind = 0; continue;
  332. }
  333. if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) != -1 && m_name2 != "")
  334. {
  335. bFind = 1;
  336. }
  337. else if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) == -1 && m_name2 != "")
  338. {
  339. bFind = 0; continue;
  340. }
  341. if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) != -1 && m_phone1 != "")
  342. {
  343. bFind = 1;
  344. }
  345. else if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) == -1 && m_phone1 != "")
  346. {
  347. bFind = 0; continue;
  348. }
  349. if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) != -1 && m_phone2 != "")
  350. {
  351. bFind = 1;
  352. }
  353. else if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) == -1 && m_phone2 != "")
  354. {
  355. bFind = 0; continue;
  356. }
  357. if (bFind)
  358. {
  359. cot++;
  360. m_oldclientarray.Add(i);
  361. }
  362. }
  363. if (cot)
  364. {
  365. CString str;
  366. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  367. SetDlgItemText(IDC_EDIT1, str);
  368. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  369. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  370. }
  371. else
  372. {
  373. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  374. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  375. }
  376. }
  377. void BookingPage22::OnButton2()
  378. {
  379. ShowHistoryClient dlg;
  380. dlg.m_poldclientarray = &m_oldclientarray;
  381. if (dlg.DoModal() != IDOK)return;
  382. int pos = m_oldclientarray.ElementAt(dlg.m_pos);
  383. // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
  384. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  385. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  386. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  387. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  388. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  389. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  390. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  391. m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
  392. m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
  393. m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
  394. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
  395. if (m_comboarea.FindString(0, m_area) == -1)
  396. m_comboarea.AddString(m_area);
  397. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  398. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  399. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  400. UpdateData(0);
  401. }
  402. HBRUSH BookingPage22::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  403. {
  404. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  405. // TODO: 在此更改 DC 的任何属性
  406. if ( nCtlColor == CTLCOLOR_DLG )
  407. return g_dlgBrush;
  408. else if ( nCtlColor == CTLCOLOR_STATIC )
  409. {
  410. //pDC->SetBkColor(g_bkcol);
  411. pDC->SetBkMode(TRANSPARENT);
  412. hbr=(HBRUSH)g_dlgBrush;
  413. }
  414. // TODO: 如果默认的不是所需画笔,则返回另一个画笔
  415. return hbr;
  416. }