BookingPage22.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. END_MESSAGE_MAP()
  52. void BookingPage22::OnOK()
  53. {
  54. }
  55. void BookingPage22::OnCancel()
  56. {
  57. }
  58. extern BOOL CALLBACK EnumChildProc3(HWND hwnd, LPARAM lParam);
  59. BOOL BookingPage22::OnInitDialog()
  60. {
  61. CDialog::OnInitDialog();
  62. m_bInit = 1;
  63. CRect rc2;
  64. GetWindowRect(rc2);
  65. MoveWindow(m_rc);
  66. g_WidthScale2 = (float)m_rc.Width() / (float)rc2.Width(); // new/Old
  67. g_HeightScale2 = (float)m_rc.Height() / (float)rc2.Height();
  68. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc3, 0);
  69. m_combozodiac.AddString("鼠");
  70. m_combozodiac.AddString("牛");
  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_combosex.AddString("男");
  82. m_combosex.AddString("女");
  83. m_comboarea.GetWindowRect(rc2);
  84. ScreenToClient(rc2);
  85. rc2.bottom += 200;
  86. m_comboarea.MoveWindow(rc2);
  87. for (int i = 0; i < m_areaarray.GetSize(); i++)
  88. {
  89. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  90. }
  91. if (((Booking2*)GetParent())->m_bModify)
  92. {
  93. if (m_comboarea.FindString(0, m_area) == -1)
  94. m_comboarea.AddString(m_area);
  95. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  96. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  97. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  98. }
  99. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  100. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  101. return TRUE;
  102. }
  103. //
  104. // Jeff add this function;
  105. // 函数:IllegalChar
  106. // 描述:判断字符是否含有创建文件夹时的非法字符
  107. // 注:此类函数需要做为Gloabl function;
  108. //
  109. int IllegalChar(const CString &strSource)
  110. {
  111. if (strSource.Find("\\") != -1)
  112. {
  113. return 1;
  114. }
  115. if (strSource.Find("/") != -1)
  116. {
  117. return 2;
  118. }
  119. if (strSource.Find(":") != -1)
  120. {
  121. return 3;
  122. }
  123. if (strSource.Find("*") != -1)
  124. {
  125. return 4;
  126. }
  127. if (strSource.Find("?") != -1)
  128. {
  129. return 5;
  130. }
  131. if (strSource.Find("\"") != -1)
  132. {
  133. return 6;
  134. }
  135. if (strSource.Find("<") != -1)
  136. {
  137. return 7;
  138. }
  139. if (strSource.Find(">") != -1)
  140. {
  141. return 8;
  142. }
  143. if (strSource.Find("|") != -1)
  144. {
  145. return 9;
  146. }
  147. return 0;
  148. }
  149. BOOL BookingPage22::CheckOK()
  150. {
  151. UpdateData();
  152. m_name1.TrimLeft();
  153. m_name1.TrimRight();
  154. m_name2.TrimLeft();
  155. m_name2.TrimRight();
  156. #if 0 // original code;
  157. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  158. {
  159. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return 0;
  160. }
  161. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1)
  162. {
  163. AfxMessageBox("客人名字不能有*号!", MB_ICONINFORMATION);
  164. return 0;
  165. }
  166. #else // Jeff.判断姓名是否含有创建文件夹时的非法字符;
  167. if (m_name1.IsEmpty() /*|| m_name2.IsEmpty()*/)
  168. {
  169. AfxMessageBox("家长姓名不能为空!", MB_ICONINFORMATION);
  170. return 0;
  171. }
  172. if ((IllegalChar(m_name1) != 0) || (IllegalChar(m_name2) != 0))
  173. {
  174. AfxMessageBox("姓名不能有\\ / : * ? \" < > | 字符", MB_ICONINFORMATION);
  175. return 0;
  176. }
  177. // 2014.12.18 有客户反应儿童版本手机必填不合理,担心手机信息会泄露了或收到影楼的广告短信什么的;
  178. if (m_phone1.IsEmpty() || m_phone1.GetLength() != 11) // Jeff.modify:添加判断手机位数(不含小灵通之类非11位长度的手机号)
  179. {
  180. AfxMessageBox("手机不能为空或位数不是11位!", MB_ICONINFORMATION);
  181. return 0;
  182. }
  183. /*
  184. if( m_birthday1.IsEmpty() )
  185. {
  186. AfxMessageBox("宝宝生日不能为空!", MB_ICONINFORMATION);
  187. return 0;
  188. }
  189. */
  190. #endif
  191. if (!CheckDateOK(m_birthday1, m_check1))
  192. {
  193. AfxMessageBox("日期无效:" + m_birthday1, MB_ICONINFORMATION);
  194. return 0;
  195. }
  196. m_phone1.TrimLeft();
  197. m_phone1.TrimRight();
  198. m_phone2.TrimLeft();
  199. m_phone2.TrimRight();
  200. if (!m_phone1.IsEmpty())
  201. {
  202. if (m_phone1.Left(1) == "1")
  203. {
  204. if (CheckPhoneType(m_phone1) == -1)
  205. {
  206. AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
  207. return 0;
  208. }
  209. }
  210. }
  211. if (!m_phone2.IsEmpty())
  212. {
  213. if (m_phone2.Left(1) == "1")
  214. {
  215. if (CheckPhoneType(m_phone2) == -1)
  216. {
  217. AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
  218. return 0;
  219. }
  220. }
  221. }
  222. int pos = m_comboarea.GetCurSel();
  223. if (pos != -1)
  224. m_comboarea.GetLBText(pos, m_area);
  225. else
  226. m_area.Empty();
  227. pos = m_combosex.GetCurSel();
  228. if (pos != -1)
  229. m_combosex.GetLBText(pos, m_sex);
  230. else
  231. m_sex.Empty();
  232. pos = m_combozodiac.GetCurSel();
  233. if (pos != -1)
  234. m_combozodiac.GetLBText(pos, m_zodiac);
  235. else
  236. m_zodiac.Empty();
  237. return 1;
  238. }
  239. void BookingPage22::NewDan()
  240. {
  241. m_addr1 = _T("");
  242. m_name1 = _T("");
  243. m_name2 = _T("");
  244. m_phone1 = _T("");
  245. m_phone2 = _T("");
  246. m_qq1 = _T("");
  247. m_birthday1 = _T("");
  248. m_zodiac = _T("");
  249. m_sex = _T("");
  250. m_area = _T("");
  251. m_check1 = FALSE;
  252. UpdateData(0);
  253. m_comboarea.SetCurSel(-1);
  254. m_combozodiac.SetCurSel(-1);
  255. m_combosex.SetCurSel(-1);
  256. }
  257. void BookingPage22::OnChangeEDITname()
  258. {
  259. CompareClient();
  260. }
  261. void BookingPage22::OnChangeEDITname2()
  262. {
  263. CompareClient();
  264. }
  265. void BookingPage22::OnChangeEDITphone()
  266. {
  267. CompareClient();
  268. }
  269. void BookingPage22::OnChangeEDITphone2()
  270. {
  271. CompareClient();
  272. }
  273. void BookingPage22::CompareClient()
  274. {
  275. if (m_bInit == 0)return;
  276. UpdateData();
  277. int cot = 0;
  278. m_oldclientarray.RemoveAll();
  279. for (int i = 0; i < g_oldclientarray.GetSize(); i++)
  280. {
  281. BOOL bFind = 0;
  282. if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) != -1 && m_name1 != "")
  283. {
  284. bFind = 1;
  285. }
  286. else if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) == -1 && m_name1 != "")
  287. {
  288. bFind = 0; continue;
  289. }
  290. if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) != -1 && m_name2 != "")
  291. {
  292. bFind = 1;
  293. }
  294. else if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) == -1 && m_name2 != "")
  295. {
  296. bFind = 0; continue;
  297. }
  298. if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) != -1 && m_phone1 != "")
  299. {
  300. bFind = 1;
  301. }
  302. else if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) == -1 && m_phone1 != "")
  303. {
  304. bFind = 0; continue;
  305. }
  306. if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) != -1 && m_phone2 != "")
  307. {
  308. bFind = 1;
  309. }
  310. else if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) == -1 && m_phone2 != "")
  311. {
  312. bFind = 0; continue;
  313. }
  314. if (bFind)
  315. {
  316. cot++;
  317. m_oldclientarray.Add(i);
  318. }
  319. }
  320. if (cot)
  321. {
  322. CString str;
  323. str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
  324. SetDlgItemText(IDC_EDIT1, str);
  325. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  326. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  327. }
  328. else
  329. {
  330. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  331. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  332. }
  333. }
  334. void BookingPage22::OnButton2()
  335. {
  336. ShowHistoryClient dlg;
  337. dlg.m_poldclientarray = &m_oldclientarray;
  338. if (dlg.DoModal() != IDOK)return;
  339. int pos = m_oldclientarray.ElementAt(dlg.m_pos);
  340. // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
  341. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  342. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  343. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  344. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  345. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  346. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  347. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  348. m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
  349. m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
  350. m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
  351. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
  352. if (m_comboarea.FindString(0, m_area) == -1)
  353. m_comboarea.AddString(m_area);
  354. m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
  355. m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
  356. m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
  357. UpdateData(0);
  358. }