123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- // AddClient.cpp : implementation file
- //
- #include "stdafx.h"
- #include "UPhoneBox.h"
- #include "AddClient.h"
- #include "UPhoneBoxDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // AddClient dialog
- AddClient::AddClient(CWnd* pParent /*=NULL*/)
- : CDialog(AddClient::IDD, pParent)
- {
- //{{AFX_DATA_INIT(AddClient)
- m_addr1 = _T("");
- m_name1 = _T("");
- m_phone1 = _T("");
- m_qq1 = _T("");
- m_from = _T("");
- m_reason = _T("");
- m_bz = _T("");
- m_bAdd = 1;
- m_sex = _T("");
- //}}AFX_DATA_INIT
- }
- void AddClient::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(AddClient)
- DDX_Control(pDX, IDC_COMBOsex, m_combosex);
- DDX_Control(pDX, IDC_COMBOreason, m_comboreason);
- DDX_Control(pDX, IDC_COMBOfrom, m_combofrom);
- DDX_Text(pDX, IDC_EDITaddr, m_addr1);
- DDX_Text(pDX, IDC_EDITname, m_name1);
- DDX_Text(pDX, IDC_EDITphone, m_phone1);
- DDX_Text(pDX, IDC_EDITqq, m_qq1);
- DDX_CBString(pDX, IDC_COMBOfrom, m_from);
- DDX_CBString(pDX, IDC_COMBOreason, m_reason);
- DDX_Text(pDX, IDC_EDIT1, m_bz);
- DDX_CBString(pDX, IDC_COMBOsex, m_sex);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(AddClient, CDialog)
- //{{AFX_MSG_MAP(AddClient)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // AddClient message handlers
- BOOL AddClient::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_combofrom.AddString("广告");
- m_combofrom.AddString("报纸");
- m_combofrom.AddString("网络");
- m_combofrom.AddString("朋友介绍");
- m_combofrom.AddString("路过");
- m_combofrom.AddString("外展");
- m_comboreason.AddString("产品");
- m_comboreason.AddString("价格");
- m_comboreason.AddString("品牌");
- m_comboreason.AddString("服装");
- m_comboreason.AddString("外景");
- m_comboreason.AddString("随便逛逛");
- m_combosex.AddString("男");
- m_combosex.AddString("女");
- m_combosex.SetCurSel(m_combosex.FindString(0, m_sex));
- m_combofrom.SetCurSel(m_combofrom.FindString(0, m_from));
- m_comboreason.SetCurSel(m_comboreason.FindString(0, m_reason));
- CenterWindow();
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- /********************************************************************************************
- /* Syntax
- /* void FirstLetter(int nCode, CString& strLetter)
- /* Remarks:
- /* Get the first letter of pinyin according to specified Chinese character code.
- /* Parameters:
- /* nCode - the code of the chinese character.
- /* strLetter - a CString object that is to receive the string of the first letter.
- /* Return Values:
- /* None.
- /* Author:
- /* lixiaosan
- /* Create Date:
- /* 05-26-2006
- /********************************************************************************************/
- void FirstLetter(int nCode, CString& strLetter)
- {
- if (nCode >= 1601 && nCode < 1637) strLetter = _T("A");
- if (nCode >= 1637 && nCode < 1833) strLetter = _T("B");
- if (nCode >= 1833 && nCode < 2078) strLetter = _T("C");
- if (nCode >= 2078 && nCode < 2274) strLetter = _T("D");
- if (nCode >= 2274 && nCode < 2302) strLetter = _T("E");
- if (nCode >= 2302 && nCode < 2433) strLetter = _T("F");
- if (nCode >= 2433 && nCode < 2594) strLetter = _T("G");
- if (nCode >= 2594 && nCode < 2787) strLetter = _T("H");
- if (nCode >= 2787 && nCode < 3106) strLetter = _T("J");
- if (nCode >= 3106 && nCode < 3212) strLetter = _T("K");
- if (nCode >= 3212 && nCode < 3472) strLetter = _T("L");
- if (nCode >= 3472 && nCode < 3635) strLetter = _T("M");
- if (nCode >= 3635 && nCode < 3722) strLetter = _T("N");
- if (nCode >= 3722 && nCode < 3730) strLetter = _T("O");
- if (nCode >= 3730 && nCode < 3858) strLetter = _T("P");
- if (nCode >= 3858 && nCode < 4027) strLetter = _T("Q");
- if (nCode >= 4027 && nCode < 4086) strLetter = _T("R");
- if (nCode >= 4086 && nCode < 4390) strLetter = _T("S");
- if (nCode >= 4390 && nCode < 4558) strLetter = _T("T");
- if (nCode >= 4558 && nCode < 4684) strLetter = _T("W");
- if (nCode >= 4684 && nCode < 4925) strLetter = _T("X");
- if (nCode >= 4925 && nCode < 5249) strLetter = _T("Y");
- if (nCode >= 5249 && nCode < 5590) strLetter = _T("Z");
- }
- /********************************************************************************************
- /* Syntax
- /* GetFirstLetter(CString strName, CString& strFirstLetter)
- /* Remarks:
- /* Get the first letter of pinyin according to specified Chinese character.
- /* Parameters:
- /* strName - a CString object that is to be parsed.
- /* strFirstLetter - a CString object that is to receive the string of the first letter.
- /* Return Values:
- /* None.
- /* Author:
- /* lixiaosan
- /* Create Date:
- /* 05-26-2006
- /********************************************************************************************/
- void GetFirstLetter(CString strName, CString& strFirstLetter)
- {
- TBYTE ucHigh, ucLow;
- int nCode;
- CString strRet;
- strFirstLetter.Empty();
- for (int i = 0; i < strName.GetLength(); i++)
- {
- if ((TBYTE)strName[i] < 0x80)
- {
- strRet = strName.Mid(i, 1);
- strRet.MakeUpper();
- strFirstLetter += strRet;
- continue;
- }
- ucHigh = (TBYTE)strName[i];
- ucLow = (TBYTE)strName[i + 1];
- if (ucHigh < 0xa1 || ucLow < 0xa1)
- continue;
- else
- // Treat code by section-position as an int type parameter,
- // so make following change to nCode.
- nCode = (ucHigh - 0xa0) * 100 + ucLow - 0xa0;
- FirstLetter(nCode, strRet);
- strFirstLetter += strRet;
- i++;
- }
- }
- extern int g_nYearpos;
- extern BOOL g_bReturned2;
- extern CUPhoneBoxDlg *g_pMainWnd;
- void AddClient::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_name1.TrimLeft();
- m_name1.TrimRight();
- if (m_name1.IsEmpty())
- {
- AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
- }
- if (m_name1.Find("*") != -1)
- {
- AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
- return;
- }
- CString strRes1;
- GetFirstLetter(m_name1, strRes1);
- CString g_date = CTime::GetCurrentTime().Format("%Y-%m-%d");
- CString sql, sql2;
- sql.Format("insert into [client2]([name],[phone],[qq],[addr],[from],[reason],[bz],[pinyin],[date],[sex],[ren])values(\
- '%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", m_name1, m_phone1, m_qq1, m_addr1, m_from, m_reason, m_bz, strRes1, g_date, m_sex, "");
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i ;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- AfxMessageBox("保存失败!", MB_ICONINFORMATION);
- return;
- }
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
- void AddClient::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- }
|