123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- // ClientDlg2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ClientDlg2.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CClientDlg2 dialog
- CClientDlg2::CClientDlg2(CWnd* pParent /*=NULL*/)
- : CDialog(CClientDlg2::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CClientDlg2)
- 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_bAdd = 1;
- m_area = _T("");
- m_check1 = FALSE;
- m_bNeedSendMsg = 0;
- m_bHistory = 0;
- //}}AFX_DATA_INIT
- }
- void CClientDlg2::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CClientDlg2)
- 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);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CClientDlg2, CDialog)
- //{{AFX_MSG_MAP(CClientDlg2)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CClientDlg2 message handlers
- BOOL CClientDlg2::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- if (m_bHistory)
- {
- SetWindowText("历史客人信息");
- GetDlgItem(IDOK)->EnableWindow(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("女");
- CString filter = "id='" + id + "';id='" + id + "'";
- g_sendhead.code[0] = 94;
- g_sendhead.code[1] = 11;
- g_sendhead.code[2] = 82;
- g_sendhead.tabcount = 3;
- g_sendhead.bsql = 0;
- g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
- CArray<CStringArray, CStringArray>m_List1array;
- CArray<CStringArray, CStringArray>m_List2array;
- DataToArray(&g_List1array, &m_List1array, &m_List2array);
- for (int i = 0; i < m_List2array.GetSize(); i++)
- {
- m_comboarea.AddString(m_List2array.ElementAt(i).ElementAt(0));
- }
- if (g_List1array.GetSize())
- {
- m_bAdd = 0;
- m_name1 = g_List1array.ElementAt(0).ElementAt(1);
- m_name2 = g_List1array.ElementAt(0).ElementAt(2);
- if (m_bNeedSendMsg == 0)
- {
- m_phone1 = g_List1array.ElementAt(0).ElementAt(3);
- m_phone2 = g_List1array.ElementAt(0).ElementAt(4);
- }
- m_qq1 = g_List1array.ElementAt(0).ElementAt(5);
- m_addr1 = g_List1array.ElementAt(0).ElementAt(6);
- m_birthday1 = g_List1array.ElementAt(0).ElementAt(7);
- m_area = g_List1array.ElementAt(0).ElementAt(8);
- m_sex = g_List1array.ElementAt(0).ElementAt(9);
- m_zodiac = g_List1array.ElementAt(0).ElementAt(10);
- m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(11));
- //#ifdef LKAY_VERSION
- if (IsHasRights2new(31) == 0)
- {
- m_phone1 = "***";
- m_phone2 = "***";
- m_qq1 = "***";
- m_addr1 = "***";
- m_area = "***";
- GetDlgItem(IDOK)->EnableWindow(0);
- }
- //#endif
- UpdateData(false);
- 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));
- }
- this->CenterWindow(g_pMainWnd);
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CClientDlg2::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_name1.TrimLeft();
- m_name1.TrimRight();
- m_name2.TrimLeft();
- m_name2.TrimRight();
- if (m_name1.IsEmpty() && m_name2.IsEmpty())
- {
- AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
- }
- if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
- {
- AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
- return;
- }
- if (!CheckDateOK(m_birthday1))return;
- 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;
- }
- }
- }
- if (!m_phone2.IsEmpty())
- {
- if (m_phone2.Left(1) == "1")
- {
- if (CheckPhoneType(m_phone2) == -1)
- {
- AfxMessageBox("手机号码:" + m_phone2 + "错误!", MB_ICONINFORMATION);
- return;
- }
- }
- }
- 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();
- CString strRes1, strRes2;
- ChinesePinYin::GetFirstLetter(m_name1, strRes1);
- ChinesePinYin::GetFirstLetter(m_name2, strRes2);
- CString sql, sql2;
- if (m_bAdd)
- sql.Format("insert into [client]([name1],[name2],[phone1],[phone2],[qq1],[addr1],[birthday1],[id],[area],[sex],[zodiac],[check1])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d')",
- m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, id, m_area, m_sex, m_zodiac, m_check1);
- else
- sql.Format("update [client] set [name1]='%s',[name2]='%s',[phone1]='%s',[phone2]='%s',[qq1]='%s',[addr1]='%s',[birthday1]='%s',[area]='%s',[sex]='%s',[zodiac]='%s',[check1]='%d' where [id]='%s' ",
- m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_addr1, m_birthday1, m_area, m_sex, m_zodiac, m_check1, id);
- sql2.Format("***update dindan set name1='%s',name2='%s',pinyin1='%s',pinyin2='%s',phone1='%s',phone2='%s' where id='%s'", m_name1, m_name2, strRes1, strRes2, m_phone1, m_phone2, id);
- sql += sql2;
- if (m_bNeedSendMsg && atoi(g_cominfoarray.ElementAt(0).ElementAt(39))) // 39==[version].[msgcheck3].是否在客人订单后立即发送短信;
- {
- CString m_content3 = g_cominfoarray.ElementAt(0).ElementAt(40);
- CString str, timestamp;
- timestamp = "msgtimestamp";
- {
- CString name;
- if (!m_name1.IsEmpty())
- name = m_name1 + ",";
- name += m_name2;
- name.TrimRight(",");
- if (name.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(name, 0) )
- {
- str = name + "您好," + m_content3;
- int count = GetLengthEx(str) / MSG_LENGTH;
- if (GetLengthEx(str) % MSG_LENGTH)
- count++;
- CString scount;
- scount.Format("%d", count);
- #if JEFF_TEST_ON
- sql2.Format(INSERT_SENDREG, _T("3"), m_phone1, str, timestamp, scount, _T("0"), _T("0"), _T("0"), _T("系统自动发送"));
- sql += _T("***") + sql2;
- #else
- sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + m_phone1 + "','" + str + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- sql += sql2;
- #endif
- }
- }
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
|