123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- // 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; i<m_pArray->GetSize (); 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; i<m_pArray->GetSize (); 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; i<phonearray.GetSize (); i++)
- {
- temp=phonearray.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
- {
- AfxMessageBox("号码"+temp+"不是正确的电话号码!", MB_ICONSTOP);
- continue;
- }
- m_strRecvMobi+=temp;
- m_strRecvMobi+=",";
- m_mobicount++;
- }
- if(bExist)AfxMessageBox("选中的号码中有重复的号码, 重复的号码已被忽略!");
- m_strRecvMobi.TrimRight (",");
- UpdateData(false);
- OnChangeEdtSms();*/
- }
- void SendMsgDlg::OnRadio2()
- {
- // TODO: Add your control notification handler code here
- OnRadio1();
- }
- void SendMsgDlg::OnRadio9()
- {
- // TODO: Add your control notification handler code here
- OnRadio1();
- }
- void SendMsgDlg::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- CDialog::OnCancel ();
- }
- void SendMsgDlg::OnBtnSend()
- {
- // TODO: Add your control notification handler code here
- if(!(IsHasRights2new(38) || IsHasRights2new(49)))return;
- UpdateData();
- if(CheckBadWords(m_strSendSms)==0 || CheckBadWords2(m_strSendSms)==0)
- {
- AfxMessageBox("信息服务商禁止的非法字符:("+g_temp+")希望您谅解!");
- return;
- }
- if(m_mobicount==0)
- {
- AfxMessageBox("手机号码不能为空!");
- return;
- }
- if(m_strSendSms.IsEmpty ())
- {
- AfxMessageBox("信息不能为空!");
- return;
- }
- CString str,timestamp;
- timestamp="msgtimestamp";//CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S"); msgxxtimestamp
- //if(CheckExist(m_strSendSms,m_strRecvMobi))
- {
- CString sql="select count(*) as cot from sendreg where [content]='"+m_strSendSms+"' and [phones]='"+m_strRecvMobi+"'";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(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; i<m_pIdArray->GetSize (); 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();
- }
|