123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- // BookingPage22.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "BookingPage22.h"
- #include "Booking2.h"
- #include "ShowHistoryClient.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- BookingPage22::BookingPage22(CWnd* pParent) :CDialog(BookingPage22::IDD, pParent)
- {
- m_addr1 = _T("");
- m_name1 = _T("");
- m_name2 = _T("");
- m_phone1 = _T("");
- m_phone2 = _T("");
- m_qq1 = _T("");
- m_birthday1 = _T("");
- m_zodiac = _T("");
- m_sex = _T("");
- m_area = _T("");
- m_check1 = FALSE;
- m_bInit = 0;
- }
- void BookingPage22::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBOzodiac, m_combozodiac);
- DDX_Control(pDX, IDC_COMBOsex, m_combosex);
- DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
- DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
- DDX_Text(pDX, IDC_EDITaddr, m_addr1);
- DDX_Text(pDX, IDC_EDITname, m_name1);
- DDX_Text(pDX, IDC_EDITname2, m_name2);
- DDX_Text(pDX, IDC_EDITphone, m_phone1);
- DDX_Text(pDX, IDC_EDITphone2, m_phone2);
- DDX_Text(pDX, IDC_EDITqq, m_qq1);
- DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
- DDX_CBString(pDX, IDC_COMBOarea, m_area);
- DDX_Check(pDX, IDC_CHECK1, m_check1);
- }
- BEGIN_MESSAGE_MAP(BookingPage22, CDialog)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_EN_CHANGE(IDC_EDITname, OnChangeEDITname)
- ON_EN_CHANGE(IDC_EDITname2, OnChangeEDITname2)
- ON_EN_CHANGE(IDC_EDITphone, OnChangeEDITphone)
- ON_EN_CHANGE(IDC_EDITphone2, OnChangeEDITphone2)
- END_MESSAGE_MAP()
- void BookingPage22::OnOK()
- {
- }
- void BookingPage22::OnCancel()
- {
- }
- extern BOOL CALLBACK EnumChildProc3(HWND hwnd, LPARAM lParam);
- BOOL BookingPage22::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_bInit = 1;
- CRect rc2;
- GetWindowRect(rc2);
- MoveWindow(m_rc);
- g_WidthScale2 = (float)m_rc.Width() / (float)rc2.Width(); // new/Old
- g_HeightScale2 = (float)m_rc.Height() / (float)rc2.Height();
- //EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProcBPage2, 0);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc3, 0);
- m_combozodiac.AddString("鼠");
- m_combozodiac.AddString("牛");
- m_combozodiac.AddString("虎");
- m_combozodiac.AddString("兔");
- m_combozodiac.AddString("龙");
- m_combozodiac.AddString("蛇");
- m_combozodiac.AddString("马");
- m_combozodiac.AddString("羊");
- m_combozodiac.AddString("猴");
- m_combozodiac.AddString("鸡");
- m_combozodiac.AddString("狗");
- m_combozodiac.AddString("猪");
- m_combosex.AddString("男");
- m_combosex.AddString("女");
- m_comboarea.GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.bottom += 200;
- m_comboarea.MoveWindow(rc2);
- for (int i = 0; i < m_areaarray.GetSize(); i++)
- {
- m_comboarea.AddString(m_areaarray.ElementAt(i).ElementAt(0));
- }
- if (((Booking2*)GetParent())->m_bModify)
- {
- if (m_comboarea.FindString(0, m_area) == -1)
- m_comboarea.AddString(m_area);
- m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
- m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
- m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
- }
- GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
- return TRUE;
- }
- // 只改变位置,不改变高度;
- // 填充式?
- BOOL BookingPage22::EnumChildProcBPage2(HWND hwnd,LPARAM lParam)
- {
- CRect rtCtrl,rtWnd;
- static float fWidthScale = ((float)g_rc.Width()) / 720.0;
- static float fHeightScale = ((float)g_rc.Height()) / 430.0;
- if(hwnd)
- {
- TCHAR szClassName[MAX_PATH];
- ::GetClassName(hwnd, szClassName, MAX_PATH);
- ::GetWindowRect(hwnd,&rtCtrl);
- ::GetWindowRect(::GetParent(hwnd),&rtWnd);
-
- rtCtrl.OffsetRect(-rtWnd.left,-rtWnd.top);
-
- float temp;
- temp= (float)rtCtrl.left*fWidthScale;
- rtCtrl.left = (int)temp;
-
- temp= (float)rtCtrl.top*fHeightScale;
- rtCtrl.top = (int)temp;
-
- temp = (float)rtCtrl.right*fWidthScale;
- rtCtrl.right = (int)temp;
-
- temp =(float)rtCtrl.bottom*fHeightScale;
- rtCtrl.bottom =(int)temp;
-
- ::MoveWindow(hwnd,rtCtrl.left,rtCtrl.top,rtCtrl.Width(),rtCtrl.Height(),TRUE);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- //
- // Jeff add this function;
- // 函数:IllegalChar
- // 描述:判断字符是否含有创建文件夹时的非法字符
- // 注:此类函数需要做为Gloabl function;
- //
- int IllegalChar(const CString &strSource)
- {
- if (strSource.Find("\\") != -1)
- {
- return 1;
- }
- if (strSource.Find("/") != -1)
- {
- return 2;
- }
- if (strSource.Find(":") != -1)
- {
- return 3;
- }
- if (strSource.Find("*") != -1)
- {
- return 4;
- }
- if (strSource.Find("?") != -1)
- {
- return 5;
- }
- if (strSource.Find("\"") != -1)
- {
- return 6;
- }
- if (strSource.Find("<") != -1)
- {
- return 7;
- }
- if (strSource.Find(">") != -1)
- {
- return 8;
- }
- if (strSource.Find("|") != -1)
- {
- return 9;
- }
- return 0;
- }
- BOOL BookingPage22::CheckOK()
- {
- UpdateData();
- m_name1.TrimLeft();
- m_name1.TrimRight();
- m_name2.TrimLeft();
- m_name2.TrimRight();
- #if 0 // original code;
- if(m_name1.IsEmpty () && m_name2.IsEmpty ())
- {
- AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return 0;
- }
- if(m_name1.Find("*")!=-1 || m_name2.Find("*")!=-1)
- {
- AfxMessageBox("客人名字不能有*号!", MB_ICONINFORMATION);
- return 0;
- }
- #else // Jeff.判断姓名是否含有创建文件夹时的非法字符;
- if (m_name1.IsEmpty() /*|| m_name2.IsEmpty()*/)
- {
- AfxMessageBox("家长姓名不能为空!", MB_ICONINFORMATION);
- return 0;
- }
- if ((IllegalChar(m_name1) != 0) || (IllegalChar(m_name2) != 0))
- {
- AfxMessageBox("姓名不能有\\ / : * ? \" < > | 字符", MB_ICONINFORMATION);
- return 0;
- }
-
- // 2014.12.18 有客户反应儿童版本手机必填不合理,担心手机信息会泄露了或收到影楼的广告短信什么的;
- if (m_phone1.IsEmpty() || m_phone1.GetLength() != 11) // Jeff.modify:添加判断手机位数(不含小灵通之类非11位长度的手机号)
- {
- AfxMessageBox("手机不能为空或位数不是11位!", MB_ICONINFORMATION);
- return 0;
- }
- /*
- if( m_birthday1.IsEmpty() )
- {
- AfxMessageBox("宝宝生日不能为空!", MB_ICONINFORMATION);
- return 0;
- }
- */
- #endif
- if (!CheckDateOK(m_birthday1, m_check1))
- {
- AfxMessageBox("日期无效:" + m_birthday1, MB_ICONINFORMATION);
- return 0;
- }
- m_phone1.TrimLeft();
- m_phone1.TrimRight();
- m_phone2.TrimLeft();
- m_phone2.TrimRight();
- if (!m_phone1.IsEmpty())
- {
- if (m_phone1.Left(1) == "1")
- {
- if (CheckPhoneType(m_phone1) == -1)
- {
- AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
- return 0;
- }
- }
- }
- if (!m_phone2.IsEmpty())
- {
- if (m_phone2.Left(1) == "1")
- {
- if (CheckPhoneType(m_phone2) == -1)
- {
- AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
- return 0;
- }
- }
- }
- int pos = m_comboarea.GetCurSel();
- if (pos != -1)
- m_comboarea.GetLBText(pos, m_area);
- else
- m_area.Empty();
- pos = m_combosex.GetCurSel();
- if (pos != -1)
- m_combosex.GetLBText(pos, m_sex);
- else
- m_sex.Empty();
- pos = m_combozodiac.GetCurSel();
- if (pos != -1)
- m_combozodiac.GetLBText(pos, m_zodiac);
- else
- m_zodiac.Empty();
- return 1;
- }
- void BookingPage22::NewDan()
- {
- m_addr1 = _T("");
- m_name1 = _T("");
- m_name2 = _T("");
- m_phone1 = _T("");
- m_phone2 = _T("");
- m_qq1 = _T("");
- m_birthday1 = _T("");
- m_zodiac = _T("");
- m_sex = _T("");
- m_area = _T("");
- m_check1 = FALSE;
- UpdateData(0);
- m_comboarea.SetCurSel(-1);
- m_combozodiac.SetCurSel(-1);
- m_combosex.SetCurSel(-1);
- }
- void BookingPage22::OnChangeEDITname()
- {
- CompareClient();
- }
- void BookingPage22::OnChangeEDITname2()
- {
- CompareClient();
- }
- void BookingPage22::OnChangeEDITphone()
- {
- CompareClient();
- }
- void BookingPage22::OnChangeEDITphone2()
- {
- CompareClient();
- }
- void BookingPage22::CompareClient()
- {
- if (m_bInit == 0)return;
- UpdateData();
- int cot = 0;
- m_oldclientarray.RemoveAll();
- for (int i = 0; i < g_oldclientarray.GetSize(); i++)
- {
- BOOL bFind = 0;
- if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) != -1 && m_name1 != "")
- {
- bFind = 1;
- }
- else if (g_oldclientarray.ElementAt(i).ElementAt(1).Find(m_name1) == -1 && m_name1 != "")
- {
- bFind = 0; continue;
- }
- if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) != -1 && m_name2 != "")
- {
- bFind = 1;
- }
- else if (g_oldclientarray.ElementAt(i).ElementAt(2).Find(m_name2) == -1 && m_name2 != "")
- {
- bFind = 0; continue;
- }
- if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) != -1 && m_phone1 != "")
- {
- bFind = 1;
- }
- else if (g_oldclientarray.ElementAt(i).ElementAt(3).Find(m_phone1) == -1 && m_phone1 != "")
- {
- bFind = 0; continue;
- }
- if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) != -1 && m_phone2 != "")
- {
- bFind = 1;
- }
- else if (g_oldclientarray.ElementAt(i).ElementAt(4).Find(m_phone2) == -1 && m_phone2 != "")
- {
- bFind = 0; continue;
- }
- if (bFind)
- {
- cot++;
- m_oldclientarray.Add(i);
- }
- }
- if (cot)
- {
- CString str;
- str.Format("找到类似客户:%d (根据名字和电话查找)", cot);
- SetDlgItemText(IDC_EDIT1, str);
- GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
- GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
- }
- else
- {
- GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
- }
- }
- void BookingPage22::OnButton2()
- {
- ShowHistoryClient dlg;
- dlg.m_poldclientarray = &m_oldclientarray;
- if (dlg.DoModal() != IDOK)return;
- int pos = m_oldclientarray.ElementAt(dlg.m_pos);
- // str.Format("客人:%s 单号:%s", +g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
- m_name1 = g_oldclientarray.ElementAt(pos).ElementAt(1);
- m_name2 = g_oldclientarray.ElementAt(pos).ElementAt(2);
- m_phone1 = g_oldclientarray.ElementAt(pos).ElementAt(3);
- m_phone2 = g_oldclientarray.ElementAt(pos).ElementAt(4);
- m_qq1 = g_oldclientarray.ElementAt(pos).ElementAt(5);
- m_addr1 = g_oldclientarray.ElementAt(pos).ElementAt(6);
- m_birthday1 = g_oldclientarray.ElementAt(pos).ElementAt(7);
- m_area = g_oldclientarray.ElementAt(pos).ElementAt(8);
- m_sex = g_oldclientarray.ElementAt(pos).ElementAt(9);
- m_zodiac = g_oldclientarray.ElementAt(pos).ElementAt(10);
- m_check1 = atoi(g_oldclientarray.ElementAt(pos).ElementAt(11));
- if (m_comboarea.FindString(0, m_area) == -1)
- m_comboarea.AddString(m_area);
- m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
- m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
- m_combozodiac.SetCurSel(m_combozodiac.FindString(0, m_zodiac));
- UpdateData(0);
- }
|