BookingPage22.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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 (m_phone1.Left(1) == "1")
  253. {
  254. if (CheckPhoneType(m_phone1) == -1)
  255. {
  256. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  257. return 0;
  258. }
  259. }
  260. }
  261. if (!m_phone2.IsEmpty())
  262. {
  263. if (m_phone2.Left(1) == "1")
  264. {
  265. if (CheckPhoneType(m_phone2) == -1)
  266. {
  267. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  268. return 0;
  269. }
  270. }
  271. }
  272. int pos = m_comboarea.GetCurSel();
  273. if (pos != -1)
  274. m_comboarea.GetLBText(pos, m_area);
  275. else
  276. m_area.Empty();
  277. pos = m_combosex.GetCurSel();
  278. if (pos != -1)
  279. m_combosex.GetLBText(pos, m_sex);
  280. else
  281. m_sex.Empty();
  282. pos = m_combozodiac.GetCurSel();
  283. if (pos != -1)
  284. m_combozodiac.GetLBText(pos, m_zodiac);
  285. else
  286. m_zodiac.Empty();
  287. return 1;
  288. }
  289. void BookingPage22::NewDan()
  290. {
  291. m_addr1 = _T("");
  292. m_name1 = _T("");
  293. m_name2 = _T("");
  294. m_phone1 = _T("");
  295. m_phone2 = _T("");
  296. m_qq1 = _T("");
  297. m_birthday1 = _T("");
  298. m_zodiac = _T("");
  299. m_sex = _T("");
  300. m_area = _T("");
  301. m_check1 = FALSE;
  302. UpdateData(0);
  303. m_comboarea.SetCurSel(-1);
  304. m_combozodiac.SetCurSel(-1);
  305. m_combosex.SetCurSel(-1);
  306. }
  307. void BookingPage22::OnChangeEDITname()
  308. {
  309. CompareClient();
  310. }
  311. void BookingPage22::OnChangeEDITname2()
  312. {
  313. CompareClient();
  314. }
  315. void BookingPage22::OnChangeEDITphone()
  316. {
  317. CompareClient();
  318. }
  319. void BookingPage22::OnChangeEDITphone2()
  320. {
  321. CompareClient();
  322. }
  323. void BookingPage22::CompareClient()
  324. {
  325. if (m_bInit == 0)return;
  326. UpdateData();
  327. int cot = 0;
  328. m_oldclientarray.RemoveAll();
  329. for (int i = 0; i < g_oldclientarray.GetSize(); i++)
  330. {
  331. BOOL bFind = 0;
  332. if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) != -1 && m_name1 != "")
  333. {
  334. bFind = 1;
  335. }
  336. else if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) == -1 && m_name1 != "")
  337. {
  338. bFind = 0; continue;
  339. }
  340. if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) != -1 && m_name2 != "")
  341. {
  342. bFind = 1;
  343. }
  344. else if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) == -1 && m_name2 != "")
  345. {
  346. bFind = 0; continue;
  347. }
  348. if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) != -1 && m_phone1 != "")
  349. {
  350. bFind = 1;
  351. }
  352. else if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) == -1 && m_phone1 != "")
  353. {
  354. bFind = 0; continue;
  355. }
  356. if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) != -1 && m_phone2 != "")
  357. {
  358. bFind = 1;
  359. }
  360. else if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) == -1 && m_phone2 != "")
  361. {
  362. bFind = 0; continue;
  363. }
  364. if (bFind)
  365. {
  366. cot++;
  367. m_oldclientarray.Add(i);
  368. }
  369. }
  370. if (cot)
  371. {
  372. CString str;
  373. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  374. SetDlgItemText(IDC_EDIT1, str);
  375. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  376. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  377. }
  378. else
  379. {
  380. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  381. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  382. }
  383. }
  384. void BookingPage22::OnButton2()
  385. {
  386. ShowHistoryClient dlg;
  387. dlg.m_poldclientarray = &m_oldclientarray;
  388. if (dlg.DoModal() != IDOK)return;
  389. int pos = m_oldclientarray.ElementAt(dlg.m_pos);
  390. // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
  391. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  392. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  393. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  394. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  395. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  396. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  397. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  398. m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
  399. m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
  400. m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
  401. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
  402. if (m_comboarea.FindString(0, m_area) == -1)
  403. m_comboarea.AddString(m_area);
  404. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  405. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  406. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  407. UpdateData(0);
  408. }
  409. HBRUSH BookingPage22::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  410. {
  411. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  412. // TODO: 在此更改 DC 的任何属性
  413. if ( nCtlColor == CTLCOLOR_DLG )
  414. return g_dlgBrush;
  415. else if ( nCtlColor == CTLCOLOR_STATIC )
  416. {
  417. //pDC->SetBkColor(g_bkcol);
  418. pDC->SetBkMode(TRANSPARENT);
  419. hbr=(HBRUSH)g_dlgBrush;
  420. }
  421. // TODO: 如果默认的不是所需画笔,则返回另一个画笔
  422. return hbr;
  423. }
  424. void BookingPage22::OnBnClickedGetphone1() //查看完整号码1;
  425. {
  426. m_phone1 = m_strPhone1;
  427. UpdateData(FALSE);
  428. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  429. }
  430. void BookingPage22::OnBnClickedGetphone2() //查看完整号码2;
  431. {
  432. m_phone2 = m_strPhone2;
  433. UpdateData(FALSE);
  434. WriteOptLog(_T("查看订单[%s]客人完整号码1"), m_strOrderNum);
  435. }