BookingPage22.cpp 12 KB

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