// SendMsgDlg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "SendMsgDlg.h" #include "SelMsgContent.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // SendMsgDlg dialog IDC_EDT_RECV_MOBI SendMsgDlg::SendMsgDlg(CWnd* pParent /*=NULL*/) : CDialog(SendMsgDlg::IDD, pParent) { //{{AFX_DATA_INIT(SendMsgDlg) m_strRecvMobi = _T(""); m_strSendSms = _T(""); m_mobicount = 0; m_nMobile=0; m_nPhone=0; m_count = 0; m_radio = 0; m_mode=0; m_sendmode=0; m_pIdArray=NULL; //}}AFX_DATA_INIT } void SendMsgDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(SendMsgDlg) DDX_Radio(pDX, IDC_RADIO1, m_radio); DDX_Text(pDX, IDC_EDT_RECV_MOBI, m_strRecvMobi); DDX_Text(pDX, IDC_EDT_SMS, m_strSendSms); DDX_Text(pDX, IDC_EDT_NUM, m_mobicount); DDV_MaxChars(pDX, m_strSendSms, 2000); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(SendMsgDlg, CDialog) //{{AFX_MSG_MAP(SendMsgDlg) ON_EN_CHANGE(IDC_EDT_SMS, OnChangeEdtSms) ON_BN_CLICKED(IDC_RADIO1, OnRadio1) ON_BN_CLICKED(IDC_RADIO2, OnRadio2) ON_BN_CLICKED(IDC_RADIO9, OnRadio9) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_BN_CLICKED(IDC_BTN_SEND, OnBtnSend) ON_BN_CLICKED(IDC_BTN_Sel, OnBtnSel) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // SendMsgDlg message handlers BOOL SendMsgDlg::OnInitDialog() { CDialog::OnInitDialog(); #ifdef CHILD_VERSION GetDlgItem(IDC_RADIO1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_RADIO2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_RADIO9)->ShowWindow(SW_HIDE); #endif if(IsHasRights2new(38) || IsHasRights2new(49)) { GetDlgItem(IDC_BTN_SEND)->EnableWindow(1); } else GetDlgItem(IDC_BTN_SEND)->EnableWindow(0); // TODO: Add extra initialization here if(m_mode==1 || m_mode==2) { if(m_mode==1) SetWindowText("短信发送"); else SetWindowText("意向客户短信发送"); GetDlgItem(IDC_RADIO1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_RADIO2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_RADIO9)->ShowWindow(SW_HIDE); m_strRecvMobi = _T(""); m_mobicount = 0; CString str,temp; int pos; m_nMobile=0; m_nPhone=0; BOOL bExist=0; for(int i=0; iGetSize (); i++) { temp=m_pArray->ElementAt (i); if(m_strRecvMobi.Find (temp)!=-1) { bExist=1; continue; } if(CheckPhoneType(temp)==0 || CheckPhoneType(temp)==1 || CheckPhoneType(temp)==2) m_nMobile++; else if(CheckPhoneType(temp)==3) m_nPhone++; else { #ifndef CHILD_VERSION AfxMessageBox("号码"+temp+"不是正确的电话号码!", MB_ICONSTOP); #endif continue; } m_strRecvMobi+=temp; m_strRecvMobi+=","; m_mobicount++; } if(bExist)AfxMessageBox("选中的号码中有重复的号码, 重复的号码已被忽略!"); m_strRecvMobi.TrimRight (","); UpdateData(false); OnChangeEdtSms(); } else OnRadio1(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void SendMsgDlg::OnChangeEdtSms() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. UpdateData(); m_strSendSms.Replace ("'", "'"); m_strSendSms.Replace ("(", "("); m_strSendSms.Replace (")", ")"); UpdateData(false); CString str; int count=0; int leng=GetLengthEx(m_strSendSms); if(m_nMobile) { count+=m_nMobile*(leng/MSG_LENGTH); if(leng%MSG_LENGTH) count+=m_nMobile; } if(m_nPhone) { count+=m_nPhone*(leng/56); if(leng%56) count+=m_nPhone; } m_count=count; str.Format ("短信内容(手机%d字/条,小灵通56字/条)(现%d字,共%d条短信)", MSG_LENGTH, leng,count); GetDlgItem(IDC_STATIC2)->SetWindowText(str); CRect rc; GetDlgItem(IDC_STATIC2)->GetWindowRect (rc); ScreenToClient(rc); InvalidateRect(rc); // TODO: Add your control notification handler code hereds } void SendMsgDlg::OnRadio1() { // TODO: Add your control notification handler code here UpdateData(); m_strRecvMobi = _T(""); m_mobicount = 0; CString str,temp; int pos; m_nMobile=0; m_nPhone=0; BOOL bExist=0; for(int i=0; iGetSize (); i++) { temp=m_pArray->ElementAt (i); if(temp.IsEmpty ())continue; if(m_strRecvMobi.Find (temp)!=-1) { bExist=1; continue; } if(CheckPhoneType(temp)==0 || CheckPhoneType(temp)==1 || CheckPhoneType(temp)==2) m_nMobile++; else if(CheckPhoneType(temp)==3) m_nPhone++; else { #ifndef CHILD_VERSION AfxMessageBox("号码"+temp+"不是正确的电话号码!", MB_ICONSTOP); #endif continue; } if(m_radio==1 && i%2==0)continue; if(m_radio==2 && i%2 )continue; m_strRecvMobi+=temp; m_strRecvMobi+=","; m_mobicount++; } if(bExist)AfxMessageBox("选中的号码中有重复的号码, 重复的号码已被忽略!"); m_strRecvMobi.TrimRight (","); UpdateData(false); OnChangeEdtSms(); /* UpdateData(); m_strRecvMobi = _T(""); m_mobicount = 0; CString str,temp; int pos; m_nMobile=0; m_nPhone=0; BOOL bExist=0; CStringArray phonearray; if(m_radio==0) { if(!m_phone1.IsEmpty ())phonearray.Add (m_phone1); if(!m_phone2.IsEmpty ())phonearray.Add (m_phone2); } else if(m_radio==1) { if(!m_phone2.IsEmpty ())phonearray.Add (m_phone2); } else if(m_radio==2) { if(!m_phone1.IsEmpty ())phonearray.Add (m_phone1); } for(int i=0; iProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; if(g_ncount) if(AfxMessageBox("提醒:相似的信息已发送, 重复发送将再次收取短信费用, 继续吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return; } CString scount; scount.Format ("%d", m_count); CString sql="insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('"+m_strRecvMobi+"','"+m_strSendSms+"','"+timestamp+"','"+scount+"','0','0','0','"+g_user.name+"')"; if(m_pIdArray && m_sendmode) { CString temp; if(m_sendmode==1) sql+="***update dindan set [send1]='1' where "; else if(m_sendmode==2) sql+="***update dindan set [send2]='1' where "; else if(m_sendmode==3) sql+="***update dindan set [send3]='1' where "; else if(m_sendmode==4) sql+="***update dindan set [send4]=1 where "; else if(m_sendmode==5) sql+="***update dindan set [send5]=1 where "; for(int i=0; iGetSize (); i++) { temp.Format ("[id]='%s' or ", m_pIdArray->ElementAt (i)); sql+=temp; } sql.TrimRight (" or "); } g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("发送成功! 请具体发送情况请查询发送记录!", MB_ICONINFORMATION); } void SendMsgDlg::OnBtnSel() { SelMsgContent dlg; if(dlg.DoModal ()!=IDOK)return; SetDlgItemText(IDC_EDT_SMS, dlg.m_content); OnChangeEdtSms(); }