// ClientDlg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "ClientDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CClientDlg dialog IDC_CHECK3 CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/) : CDialog(CClientDlg::IDD, pParent) { //{{AFX_DATA_INIT(CClientDlg) m_addr1 = _T(""); m_addr2 = _T(""); m_name1 = _T(""); m_name2 = _T(""); m_occupation1 = _T(""); m_occupation2 = _T(""); m_phone1 = _T(""); m_phone2 = _T(""); m_qq1 = _T(""); m_qq2 = _T(""); m_birthday1 = _T(""); m_birthday2 = _T(""); m_time3 = _T(""); m_bAdd = 1; m_area = _T(""); m_area2 = _T(""); m_check1 = FALSE; m_check2 = FALSE; m_check3 = FALSE; m_bNeedSendMsg = 0; m_bHistory = 0; //}}AFX_DATA_INIT } void CClientDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CClientDlg) DDX_Control(pDX, IDC_COMBOarea2, m_comboarea2); DDX_Control(pDX, IDC_COMBOarea, m_comboarea); DDX_Control(pDX, IDC_EDITtime3, m_datectrl3); DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2); DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1); DDX_Text(pDX, IDC_EDITaddr, m_addr1); DDX_Text(pDX, IDC_EDITaddr2, m_addr2); DDX_Text(pDX, IDC_EDITname, m_name1); DDX_Text(pDX, IDC_EDITname2, m_name2); DDX_Text(pDX, IDC_EDITOccupation, m_occupation1); DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2); 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_EDITqq2, m_qq2); DDX_Text(pDX, IDC_EDITBirthday, m_birthday1); DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2); DDX_Text(pDX, IDC_EDITtime3, m_time3); DDX_CBString(pDX, IDC_COMBOarea, m_area); DDX_CBString(pDX, IDC_COMBOarea2, m_area2); DDX_Check(pDX, IDC_CHECK1, m_check1); DDX_Check(pDX, IDC_CHECK2, m_check2); DDX_Check(pDX, IDC_CHECK3, m_check3); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CClientDlg, CDialog) //{{AFX_MSG_MAP(CClientDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CClientDlg message handlers BOOL CClientDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if (m_bHistory) { SetWindowText("历史客人信息"); GetDlgItem(IDOK)->EnableWindow(0); } CString filter = "id='" + id + "';id='" + id + "'"; g_sendhead.code[0] = 52; 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; CArraym_List1array; CArraym_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)); m_comboarea2.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_qq2 = g_List1array.ElementAt(0).ElementAt(6); m_addr1 = g_List1array.ElementAt(0).ElementAt(7); m_addr2 = g_List1array.ElementAt(0).ElementAt(8); m_occupation1 = g_List1array.ElementAt(0).ElementAt(9); m_occupation2 = g_List1array.ElementAt(0).ElementAt(10); m_birthday1 = g_List1array.ElementAt(0).ElementAt(11); m_birthday2 = g_List1array.ElementAt(0).ElementAt(12); m_time3 = m_List1array.ElementAt(0).ElementAt(12); m_area = g_List1array.ElementAt(0).ElementAt(13); m_area2 = g_List1array.ElementAt(0).ElementAt(14); m_check1 = atoi(g_List1array.ElementAt(0).ElementAt(15)); m_check2 = atoi(g_List1array.ElementAt(0).ElementAt(16)); m_check3 = atoi(g_List1array.ElementAt(0).ElementAt(17)); m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area)); m_comboarea2.SetCurSel(m_comboarea2.FindString(0, m_area2)); if (IsHasRights2new(31) == 0) { m_phone1 = "***"; m_phone2 = "***"; m_qq1 = "***"; m_qq2 = "***"; GetDlgItem(IDOK)->EnableWindow(0); } } UpdateData(false); this->CenterWindow(g_pMainWnd); GetDlgItem(IDC_EDITphone2)->SetFocus(); return false; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CClientDlg::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; if (!CheckDateOK(m_birthday2))return; if (!CheckDateOK(m_time3))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_comboarea2.GetCurSel(); if (pos != -1) m_comboarea2.GetLBText(pos, m_area2); else m_area2.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],[qq2],[addr1],[addr2],[occupation1],[occupation2],[birthday1],[birthday2],[id],[area],[area2],[check1],[check2],[check3])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%d','%d')", m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_addr1, m_addr2, m_occupation1, m_occupation2, m_birthday1, m_birthday2, id, m_area, m_area2, m_check1, m_check2, m_check3); else sql.Format("update [client] set [name1]='%s',[name2]='%s',[phone1]='%s',[phone2]='%s',[qq1]='%s',[qq2]='%s',[addr1]='%s',[addr2]='%s',[occupation1]='%s',[occupation2]='%s',[birthday1]='%s',[birthday2]='%s',[area]='%s',[area2]='%s',[check1]='%d',[check2]='%d',[check3]='%d',[time3]='%s' where [id]='%s' ", m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_addr1, m_addr2, m_occupation1, m_occupation2, m_birthday1, m_birthday2, m_area, m_area2, m_check1, m_check2, m_check3, m_time3, id); sql2.Format("***update dindan set name1='%s',name2='%s',pinyin1='%s',pinyin2='%s',phone1='%s',phone2='%s',[time3]='%s' where id='%s'", m_name1, m_name2, strRes1, strRes2, m_phone1, m_phone2, m_time3, id); sql += sql2; #ifndef CHILD_VERSION if(m_hqtime.IsEmpty ()==0) { sql2.Format ("***update dindansp set hqdate='%s' where id='%s' and hqdate is null", m_hqtime, id); sql+=sql2; } #endif 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"; int pos = m_content3.Find("xxx先生/女士"); if (pos != -1) { if (m_name1.IsEmpty() == 0 && CheckPhoneType(m_phone1) != -1 && CheckBadWords(m_name1, 0) ) { str = m_content3; str.Replace("xxx先生/女士", m_name1 + "先生"); 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 } if (m_name2.IsEmpty() == 0 && CheckPhoneType(m_phone2) != -1 && CheckBadWords(m_name2, 0) ) { str = m_content3; str.Replace("xxx先生/女士", m_name2 + "女士"); int count = GetLengthEx(str) / MSG_LENGTH; if (GetLengthEx(str) % MSG_LENGTH) count++; CString scount; scount.Format("%d", count); CTime tm = CTime::GetCurrentTime(); tm += CTimeSpan(0, 0, 0, 3); timestamp = tm.Format("%Y%m%d%H%M%S"); timestamp = "msgtimexxstamp"; #if JEFF_TEST_ON sql2.Format(INSERT_SENDREG, _T("3"), m_phone2, 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_phone2 + "','" + 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(); } void CClientDlg::OnCancel() { // TODO: Add extra cleanup here if (!m_hqtime.IsEmpty()) { CString sql; sql.Format("***update dindansp set hqdate='%s' where id='%s'", m_hqtime, id); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); } CDialog::OnCancel(); }