BookingPage2.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. // BookingPage2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "BookingPage2.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. // BookingPage2 dialog
  15. BookingPage2::BookingPage2(CWnd* pParent /*=NULL*/)
  16. : CDialog(BookingPage2::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(BookingPage2)
  19. // NOTE: the ClassWizard will add member initialization here
  20. m_addr1 = _T("");
  21. m_addr2 = _T("");
  22. m_name1 = _T("");
  23. m_name2 = _T("");
  24. m_occupation1 = _T("");
  25. m_occupation2 = _T("");
  26. m_phone1 = _T("");
  27. m_phone2 = _T("");
  28. m_qq1 = _T("");
  29. m_qq2 = _T("");
  30. m_birthday1 = _T("");
  31. m_birthday2 = _T("");
  32. m_time3 = _T("");
  33. m_area = _T("");
  34. m_area2 = _T("");
  35. m_check1 = FALSE;
  36. m_check2 = FALSE;
  37. m_check3 = FALSE;
  38. m_bInit=0;
  39. m_nIntentionPos = -1;
  40. //}}AFX_DATA_INIT
  41. }
  42. void BookingPage2::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(BookingPage2)
  46. // NOTE: the ClassWizard will add DDX and DDV calls here
  47. DDX_Control(pDX, IDC_COMBOarea2, m_comboarea2);
  48. DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
  49. DDX_Control(pDX, IDC_EDITtime3, m_datectrl3);
  50. DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2);
  51. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  52. DDX_Text(pDX, IDC_EDITaddr, m_addr1);
  53. DDX_Text(pDX, IDC_EDITaddr2, m_addr2);
  54. DDX_Text(pDX, IDC_EDITname, m_name1);
  55. DDX_Text(pDX, IDC_EDITname2, m_name2);
  56. DDX_Text(pDX, IDC_EDITOccupation, m_occupation1);
  57. DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2);
  58. DDX_Text(pDX, IDC_EDITphone, m_phone1);
  59. DDX_Text(pDX, IDC_EDITphone2, m_phone2);
  60. DDX_Text(pDX, IDC_EDITqq, m_qq1);
  61. DDX_Text(pDX, IDC_EDITqq2, m_qq2);
  62. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  63. DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2);
  64. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  65. DDX_CBString(pDX, IDC_COMBOarea, m_area);
  66. DDX_CBString(pDX, IDC_COMBOarea2, m_area2);
  67. DDX_Check(pDX, IDC_CHECK1, m_check1);
  68. DDX_Check(pDX, IDC_CHECK2, m_check2);
  69. DDX_Check(pDX, IDC_CHECK3, m_check3);
  70. //}}AFX_DATA_MAP
  71. }
  72. BEGIN_MESSAGE_MAP(BookingPage2, CDialog)
  73. //{{AFX_MSG_MAP(BookingPage2)
  74. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  75. ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
  76. ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
  77. ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
  78. ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
  79. //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // BookingPage2 message handlers
  83. void BookingPage2::OnCancel()
  84. {
  85. // TODO: Add extra cleanup here
  86. }
  87. void BookingPage2::OnOK()
  88. {
  89. // TODO: Add extra validation here
  90. }
  91. extern BOOL CALLBACK EnumChildProc3(HWND hwnd,LPARAM lParam);
  92. BOOL BookingPage2::OnInitDialog()
  93. {
  94. CDialog::OnInitDialog();
  95. // TODO: Add extra initialization here
  96. #ifdef LYFZ_VERSION
  97. GetDlgItem(IDC_STATIC1)->SetWindowText("老总姓名:");
  98. GetDlgItem(IDC_STATIC2)->SetWindowText("影楼名称:");
  99. GetDlgItem(IDC_STATIC3)->SetWindowText("快递单号:");
  100. GetDlgItem(IDC_STATIC4)->SetWindowText("短信账号:");
  101. GetDlgItem(IDC_STATIC5)->SetWindowText("域名:");
  102. GetDlgItem(IDC_STATIC6)->SetWindowText("座机:");
  103. #endif
  104. CRect rc2;
  105. GetWindowRect(rc2);
  106. MoveWindow(m_rc);
  107. g_WidthScale2 = (float)m_rc.Width()/(float)rc2.Width(); // new/Old
  108. g_HeightScale2 = (float)m_rc.Height()/(float)rc2.Height();
  109. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc3,0);
  110. m_comboarea.GetWindowRect (rc2);
  111. ScreenToClient(rc2);
  112. rc2.bottom +=200;
  113. m_comboarea.MoveWindow (rc2);
  114. m_comboarea2.GetWindowRect (rc2);
  115. ScreenToClient(rc2);
  116. rc2.bottom +=200;
  117. m_comboarea2.MoveWindow (rc2);
  118. for(int i=0; i<m_areaarray.GetSize(); i++)
  119. {
  120. m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  121. m_comboarea2.AddString(m_areaarray.ElementAt(i).ElementAt(0));
  122. }
  123. if(((Booking2*)GetParent())->m_bModify)
  124. {
  125. if(m_comboarea.FindString (0, m_area)==-1)
  126. m_comboarea.AddString (m_area);
  127. if(m_comboarea2.FindString (0, m_area2)==-1)
  128. m_comboarea2.AddString (m_area2);
  129. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  130. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  131. }
  132. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  133. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  134. m_bInit=1;
  135. return TRUE; // return TRUE unless you set the focus to a control
  136. // EXCEPTION: OCX Property Pages should return FALSE
  137. }
  138. BOOL BookingPage2::CheckOK()
  139. {
  140. UpdateData();
  141. if(m_name1.IsEmpty () && m_name2.IsEmpty ())
  142. {
  143. return 0;
  144. }
  145. if(m_phone1.IsEmpty () && m_phone2.IsEmpty ())
  146. {
  147. return 0;
  148. }
  149. if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1 )
  150. {
  151. AfxMessageBox("客人名字中不能有*号!", MB_ICONINFORMATION);
  152. return 0;
  153. }
  154. if(!CheckDateOK(m_birthday1))return 0;
  155. if(!CheckDateOK(m_birthday2))return 0;
  156. if(!CheckDateOK(m_time3))return 0;
  157. m_phone1.TrimLeft ();
  158. m_phone1.TrimRight ();
  159. m_phone2.TrimLeft ();
  160. m_phone2.TrimRight ();
  161. if(!m_phone1.IsEmpty ())
  162. {
  163. if(m_phone1.Left (1)=="1")
  164. {
  165. if(CheckPhoneType(m_phone1)==-1)
  166. {
  167. AfxMessageBox("手机号码:"+m_phone1+"错误!", MB_ICONINFORMATION);
  168. return 0;
  169. }
  170. }
  171. }
  172. if(!m_phone2.IsEmpty ())
  173. {
  174. if(m_phone2.Left (1)=="1")
  175. {
  176. if(CheckPhoneType(m_phone2)==-1)
  177. {
  178. AfxMessageBox("手机号码:"+m_phone2+"错误!", MB_ICONINFORMATION);
  179. return 0;
  180. }
  181. }
  182. }
  183. int pos=m_comboarea.GetCurSel();
  184. if(pos!=-1)
  185. m_comboarea.GetLBText(pos, m_area);
  186. else
  187. m_area.Empty();
  188. pos=m_comboarea2.GetCurSel();
  189. if(pos!=-1)
  190. m_comboarea2.GetLBText(pos, m_area2);
  191. else
  192. m_area2.Empty();
  193. return 1;
  194. }
  195. void BookingPage2::NewDan()
  196. {
  197. m_addr1 = _T("");
  198. m_addr2 = _T("");
  199. m_name1 = _T("");
  200. m_name2 = _T("");
  201. m_occupation1 = _T("");
  202. m_occupation2 = _T("");
  203. m_phone1 = _T("");
  204. m_phone2 = _T("");
  205. m_qq1 = _T("");
  206. m_qq2 = _T("");
  207. m_birthday1 = _T("");
  208. m_birthday2 = _T("");
  209. m_time3 = _T("");
  210. m_area = _T("");
  211. m_area2 = _T("");
  212. m_check1 = FALSE;
  213. m_check2 = FALSE;
  214. m_check3 = FALSE;
  215. UpdateData(0);
  216. m_comboarea.SetCurSel (-1);
  217. m_comboarea2.SetCurSel (-1);
  218. }
  219. void BookingPage2::OnChangeEDITname()
  220. {
  221. // TODO: If this is a RICHEDIT control, the control will not
  222. // send this notification unless you override the CDialog::OnInitDialog()
  223. // function and call CRichEditCtrl().SetEventMask()
  224. // with the ENM_CHANGE flag ORed into the mask.
  225. CompareClient();
  226. // TODO: Add your control notification handler code here
  227. }
  228. void BookingPage2::OnChangeEDITname2()
  229. {
  230. // TODO: If this is a RICHEDIT control, the control will not
  231. // send this notification unless you override the CDialog::OnInitDialog()
  232. // function and call CRichEditCtrl().SetEventMask()
  233. // with the ENM_CHANGE flag ORed into the mask.
  234. CompareClient();
  235. // TODO: Add your control notification handler code here
  236. }
  237. void BookingPage2::OnChangeEDITphone()
  238. {
  239. // TODO: If this is a RICHEDIT control, the control will not
  240. // send this notification unless you override the CDialog::OnInitDialog()
  241. // function and call CRichEditCtrl().SetEventMask()
  242. // with the ENM_CHANGE flag ORed into the mask.
  243. CompareClient();
  244. // TODO: Add your control notification handler code here
  245. }
  246. void BookingPage2::OnChangeEDITphone2()
  247. {
  248. // TODO: If this is a RICHEDIT control, the control will not
  249. // send this notification unless you override the CDialog::OnInitDialog()
  250. // function and call CRichEditCtrl().SetEventMask()
  251. // with the ENM_CHANGE flag ORed into the mask.
  252. CompareClient();
  253. // TODO: Add your control notification handler code here
  254. }
  255. void BookingPage2::CompareClient()
  256. {
  257. if(m_bInit==0)return;
  258. UpdateData();
  259. int cot=0;
  260. BOOL bExistsIntentionCustomer = FALSE;
  261. m_oldclientarray.RemoveAll();
  262. for(int i=0; i<g_oldclientarray.GetSize(); i++)
  263. {
  264. BOOL bFind=0;
  265. if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)!=-1 && m_name1!="")
  266. {
  267. if ( g_oldclientarray.ElementAt(i).ElementAt(20) == _T("系统意向") )
  268. bExistsIntentionCustomer = TRUE;
  269. bFind=1;
  270. }
  271. else if(g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1)==-1 && m_name1!="")
  272. {
  273. bFind=0;continue;
  274. }
  275. if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)!=-1 && m_name2!="")
  276. {
  277. if ( g_oldclientarray.ElementAt(i).ElementAt(20) == _T("系统意向") )
  278. bExistsIntentionCustomer = TRUE;
  279. bFind=1;
  280. }
  281. else if(g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2)==-1 && m_name2!="")
  282. {
  283. bFind=0;continue;
  284. }
  285. if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)!=-1 && m_phone1!="")
  286. {
  287. if ( g_oldclientarray.ElementAt(i).ElementAt(20) == _T("系统意向") )
  288. bExistsIntentionCustomer = TRUE;
  289. bFind=1;
  290. }
  291. else if(g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1)==-1 && m_phone1!="")
  292. {
  293. bFind=0;continue;
  294. }
  295. if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)!=-1 && m_phone2!="")
  296. {
  297. if ( g_oldclientarray.ElementAt(i).ElementAt(20) == _T("系统意向") )
  298. bExistsIntentionCustomer = TRUE;
  299. bFind=1;
  300. }
  301. else if(g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2)==-1 && m_phone2!="")
  302. {
  303. bFind=0;continue;
  304. }
  305. if(bFind)
  306. {
  307. cot++;
  308. m_oldclientarray.Add(i);
  309. }
  310. }
  311. if(cot)
  312. {
  313. CString str;
  314. if ( bExistsIntentionCustomer )
  315. str.Format("找到类似客户(含意向顾客):%d (根据名字和电话查找)", cot);
  316. else
  317. str.Format("找到类似客户(没有意向顾客):%d (根据名字和电话查找)", cot);
  318. SetDlgItemText(IDC_EDIT1, str);
  319. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
  320. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  321. }
  322. else
  323. {
  324. GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
  325. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  326. }
  327. }
  328. void BookingPage2::OnButton2() // 查看详情;
  329. {
  330. // TODO: Add your control notification handler code here
  331. ShowHistoryClient dlg;
  332. dlg.m_poldclientarray=&m_oldclientarray;
  333. if(dlg.DoModal()!=IDOK)return;
  334. int pos=m_oldclientarray.ElementAt(dlg.m_pos);
  335. m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
  336. m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
  337. m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
  338. m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
  339. m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
  340. m_qq2 = g_oldclientarray.ElementAt(pos).ElementAt(6);
  341. m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
  342. if ( g_oldclientarray.ElementAt(pos).ElementAt(20) == _T("老顾客") )
  343. {
  344. m_addr2 = g_oldclientarray.ElementAt(pos).ElementAt(8);
  345. m_occupation1 = g_oldclientarray.ElementAt(pos).ElementAt(9);
  346. m_occupation2 = g_oldclientarray.ElementAt(pos).ElementAt(10);
  347. m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(11);
  348. }
  349. else if ( g_oldclientarray.ElementAt(pos).ElementAt(20) == _T("系统意向") )
  350. {
  351. m_nIntentionPos = pos;
  352. //m_addr2 = g_oldclientarray.ElementAt(pos).ElementAt(8);//已用于意向顾客状态;
  353. //m_occupation1 = g_oldclientarray.ElementAt(pos).ElementAt(9);//已用于意向顾客业务员;
  354. //m_occupation2 = g_oldclientarray.ElementAt(pos).ElementAt(10);//已用于意向顾客记录生成日期;
  355. //m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(11);//已用于意向顾客备注;
  356. }
  357. m_birthday2 = g_oldclientarray.ElementAt(pos).ElementAt(12);
  358. m_area = g_oldclientarray.ElementAt(pos).ElementAt(13);
  359. m_area2 = g_oldclientarray.ElementAt(pos).ElementAt(14);
  360. m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(15));
  361. m_check2 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(16));
  362. m_check3 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(17));
  363. m_time3 = g_oldclientarray.ElementAt(pos).ElementAt(18);
  364. if(m_comboarea.FindString (0, m_area)==-1)
  365. m_comboarea.AddString (m_area);
  366. if(m_comboarea2.FindString (0, m_area2)==-1)
  367. m_comboarea2.AddString (m_area2);
  368. m_comboarea.SetCurSel (m_comboarea.FindString (0, m_area));
  369. m_comboarea2.SetCurSel (m_comboarea2.FindString (0, m_area2));
  370. UpdateData(0);
  371. }