123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- // SendMsg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SendMsg.h"
- #include "MyMdi.H"
- #include "GetPhone.h"
- #include "GetPhoneAge.h"
- #include "SelMsgContent.h"
- #include "InputPhones.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SendMsg IDC_LIST1
- IMPLEMENT_DYNCREATE(SendMsg, MyFormView)
- SendMsg::SendMsg()
- : MyFormView(SendMsg::IDD)
- {
- //{{AFX_DATA_INIT(SendMsg)
- m_strRecvMobi = _T("");
- m_strSendSms = _T("");
- m_mobicount = 0;
- m_nMobile=0;
- m_nPhone=0;
- m_count = 0;
- //}}AFX_DATA_INIT
- g_nYearposTemp=g_nYearpos;
- }
- SendMsg::~SendMsg()
- {
- g_nYearpos=g_nYearposTemp;
- }
- void SendMsg::DoDataExchange(CDataExchange* pDX)
- {
- MyFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SendMsg)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Control(pDX, IDC_STATIC1, m_static1);
- 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);
- //}}AFX_DATA_MAP
- }
- // DDV_MaxChars(pDX, m_strSendSms, 2000);
- BEGIN_MESSAGE_MAP(SendMsg, MyFormView)
- //{{AFX_MSG_MAP(SendMsg)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_BN_CLICKED(IDC_BTN_SEND, OnBtnSend)
- ON_BN_CLICKED(IDC_BTN_Sel, OnBtnSel)
- ON_EN_CHANGE(IDC_EDT_SMS, OnChangeEdtSms)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_BN_CLICKED(IDC_BUTTON3, OnSelAll)
- ON_BN_CLICKED(IDC_BUTTON4, OnReset)
- ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SendMsg diagnostics
- #ifdef _DEBUG
- void SendMsg::AssertValid() const
- {
- MyFormView::AssertValid();
- }
- void SendMsg::Dump(CDumpContext& dc) const
- {
- MyFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // SendMsg message handlers
- void SendMsg::OnInitialUpdate()
- {
- MyFormView::OnInitialUpdate();
- // TODO: Add your specialized code here and/or call the base class
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
-
- // Here we create the outbar control using the splitter as its parent
- // and setting its id to the first pane.
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
- m_static1.SetFont (&g_titlefont);
- if(IsHasRights2new(38) || IsHasRights2new(49))
- {
- GetDlgItem(IDC_BTN_SEND)->EnableWindow(1);
- }
- else
- GetDlgItem(IDC_BTN_SEND)->EnableWindow(0);
- #ifndef CHILD_VERSION
- GetDlgItem(IDC_BUTTON6)->ShowWindow(0);
- #endif
- }
- void SendMsg::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
- BOOL SendMsg::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- try
- {
- if(pMsg->message==WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case 0x43: // copy
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_COPY);
- return TRUE;
- }
- break;
- case 0x56: //Ctrl + V:
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_PASTE);
- return TRUE;
- }
- break;
- case 0x58: // cut
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_CUT);
- return TRUE;
- }
- break;
- case 0x5A: //undo
- case 0x59: //redo
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_UNDO);
- return TRUE;
- }
- break;
- }
- }
- return MyFormView::PreTranslateMessage(pMsg);
- }
- catch(...)
- {
- }
- }
- void SendMsg::OnChangeEdtSms()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the MyFormView::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 here
-
- }
- void SendMsg::OnButton2()
- {
- // TODO: Add your control notification handler code here
- CStringArray array;
- GetPhone dlg;
- dlg.m_pArray=&array;
- dlg.m_pArray2=&m_selitemarray;
- m_selitemarray.RemoveAll ();
- if(dlg.DoModal ()!=IDOK)return;
- CString str,temp;
- BOOL exist;int pos;
- for(int i=0; i<array.GetSize (); i+=2)
- {
- str=array.ElementAt (i);
- str+="\r\n";
- str+=array.ElementAt (i+1);
- if(array.ElementAt (i+1).IsEmpty ())continue;
- if(array.ElementAt (i+1).Left (1)!="1")continue;
- /* exist=0;
- for(int a=0; a<m_List1.GetCount (); a++)
- {
- m_List1.GetText (a, temp);
- pos=temp.Find ("\r\n");
- if(array.ElementAt (i+1)==temp.Right (temp.GetLength ()-pos-2))
- {
- exist=1;
- break;
- }
- }
- if(exist)continue;*/
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
- else
- m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
- }
- m_List1.Invalidate ();
- }
- void SendMsg::OnButton5()
- {
- // TODO: Add your control notification handler code here
- m_selitemarray.RemoveAll ();
- m_List1.ResetContent ();
- }
- void SendMsg::OnSelAll()
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetCount (); i++)
- m_List1.SetSel (i, 1);
- OnSelchangeList1();
- }
- void SendMsg::OnReset()
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetCount (); i++)
- m_List1.SetSel (i, 0);
- OnSelchangeList1();
- }
- void SendMsg::OnSelchangeList1()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int count= m_List1.GetSelCount() ;
- if(count==0)return;
- int *pIndex=new int[count];
- m_List1.GetSelItems(count, pIndex);
- 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<count; i++)
- {
- if(0)//m_nMobile>2999)
- {
- AfxMessageBox("一次最多能发送3000个手机, 部分选中的手机未生效, 请重新选择!", MB_ICONSTOP);
- break;
- }
- m_List1.GetText (pIndex[i], str);
- pos=str.Find ("\r\n");
- if(pos==-1)continue;
- temp=str.Right (str.GetLength ()-pos-2);
- 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);
- delete []pIndex;
- OnChangeEdtSms();
- CRect rc;
- GetDlgItem(IDC_EDT_RECV_MOBI)->GetWindowRect(rc);
- ScreenToClient(rc);
- InvalidateRect(rc);
- }
- void SendMsg::OnBtnSel()
- {
- SelMsgContent dlg;
- if(dlg.DoModal ()!=IDOK)return;
- SetDlgItemText(IDC_EDT_SMS, dlg.m_content);
- OnChangeEdtSms();
- }
- void SendMsg::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("手机号码不能为空, 请在联系人中选择, 按Ctrl或Shift键多选!");
- return;
- }
- if(m_strSendSms.IsEmpty ())
- {
- AfxMessageBox("信息不能为空!");
- return;
- }
- CString str,timestamp;
- timestamp="msgtimestamp";
- //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);
- if(atoi(g_cominfoarray.ElementAt(0).ElementAt(30))<m_count && m_count>1)
- {
- if(AfxMessageBox("提醒:您的余额可能不足, 继续发送吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- }
- 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_selitemarray.GetSize ()==4)
- sql+="***insert into [sendreg2]([phones],[content],[price],[yytime],[client],[type],[date],[ren])values('"+m_strRecvMobi+"','"+m_strSendSms+"','"+m_selitemarray.ElementAt (0)+"','"+m_selitemarray.ElementAt (1)+"','"+m_selitemarray.ElementAt (2)+"','"+m_selitemarray.ElementAt (3)+"','"+timestamp+"','"+g_user.name+"')";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- AfxMessageBox("发送成功! 请具体发送情况请查询发送记录!", MB_ICONINFORMATION);
- }
- void SendMsg::OnButton1()
- {
- // TODO: Add your control notification handler code here
- InputPhones dlg;
- if(dlg.DoModal ()==IDOK)
- {
- CStringArray array;
- CString str=dlg.m_phones;
- str.Replace (" ", "");
- str.Replace (" ", "");
- str.Replace ("\r\n", ",");
- str.Replace ("\r", ",");
- str.Replace ("\n", ",");
- str.Replace (";", ",");
- str.Replace (";", ",");
- str.Replace (",", ",");
- int pos=str.Find (",");
- CString temp;
- while(pos!=-1)
- {
- temp=str.Left (pos);
- array.Add (temp);
- str=str.Right (str.GetLength ()-pos-1);
- pos=str.Find (",");
- }
- array.Add (str);
- CStringArray *m_pArray=&array;
- m_strRecvMobi = _T("");
- m_mobicount = 0;
-
- 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
- {
- AfxMessageBox("号码"+temp+"不是正确的电话号码!", MB_ICONSTOP);
- continue;
- }
- m_strRecvMobi+=temp;
- m_strRecvMobi+=",";
- m_mobicount++;
- }
- if(bExist)AfxMessageBox("选中的号码中有重复的号码, 重复的号码已被忽略!");
- m_strRecvMobi.TrimRight (",");
- UpdateData(false);
- OnChangeEdtSms();
- }
- }
- void SendMsg::OnButton6()
- {
- // TODO: Add your control notification handler code here
- CStringArray array;
- GetPhoneAge dlg;
- dlg.m_pArray=&array;
- dlg.m_pArray2=&m_selitemarray;
- m_selitemarray.RemoveAll ();
- if(dlg.DoModal ()!=IDOK)return;
- CString str,temp;
- BOOL exist;int pos;
- for(int i=0; i<array.GetSize (); i+=2)
- {
- str=array.ElementAt (i);
- str+="\r\n";
- str+=array.ElementAt (i+1);
- if(array.ElementAt (i+1).IsEmpty ())continue;
- if(array.ElementAt (i+1).Left (1)!="1")continue;
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
- else
- m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
- }
- m_List1.Invalidate ();
- }
|