2025-02-27 16:58:16 +08:00
// FMmsDF.cpp : implementation file
//
# include "stdafx.h"
# include "CorpSms.h"
# include "FMmsDF.h"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
static char THIS_FILE [ ] = __FILE__ ;
# endif
/////////////////////////////////////////////////////////////////////////////
// CFMmsDF dialog
# include "MainFrm.h"
# include "ProcessSocket.h"
# include "DLG_Find_SmsBox.h"
# include "DLG_SmsList_Export.h"
CFMmsDF : : CFMmsDF ( CWnd * pParent /*=NULL*/ )
: CDialog ( CFMmsDF : : IDD , pParent )
{
//{{AFX_DATA_INIT(CFMmsDF)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bInit = false ;
m_bRefresh = false ;
}
void CFMmsDF : : DoDataExchange ( CDataExchange * pDX )
{
CDialog : : DoDataExchange ( pDX ) ;
//{{AFX_DATA_MAP(CFMmsDF)
DDX_Control ( pDX , IDC_MMSDF_LIST , m_wndList ) ;
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP ( CFMmsDF , CDialog )
//{{AFX_MSG_MAP(CFMmsDF)
ON_WM_SIZE ( )
ON_NOTIFY ( NM_RCLICK , IDC_MMSDF_LIST , OnRclickSmsdfList )
ON_NOTIFY ( NM_DBLCLK , IDC_MMSDF_LIST , OnDblclkSmsdfList )
ON_NOTIFY ( LVN_KEYDOWN , IDC_MMSDF_LIST , OnKeydownSmsdfList )
//}}AFX_MSG_MAP
ON_COMMAND ( MENU_DF_ADD , On_User_Add )
ON_COMMAND ( MENU_DF_MODIFY , On_User_Modify )
ON_COMMAND ( MENU_DF_RESEND , On_User_ReSend )
ON_COMMAND ( MENU_DF_DEL , On_User_Del )
ON_COMMAND ( MENU_DF_REFRESH , On_User_Refresh )
ON_COMMAND ( MENU_DF_FIND , On_User_Find )
ON_COMMAND ( MENU_DF_EXPORT , On_User_Export )
END_MESSAGE_MAP ( )
/////////////////////////////////////////////////////////////////////////////
// CFMmsDF message handlers
BOOL CFMmsDF : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( ) ;
//ȡ<> ù<EFBFBD> <C3B9> ò<EFBFBD> <C3B2> <EFBFBD>
//CMainFrame * pFrame = static_cast <CMainFrame *>((CMainFrame *)AfxGetMainWnd());
this - > GetParent ( ) - > GetParentFrame ( ) ;
m_pMainFrame = ( CMainFrame * ) this - > GetParent ( ) - > GetParentFrame ( ) ;
m_pSocket = & m_pMainFrame - > m_Socket ;
m_AdoRS . SetAdoConnection ( & m_pMainFrame - > m_adoConnection ) ;
m_AdoRS2 . SetAdoConnection ( & m_pMainFrame - > m_adoConnection ) ;
//<2F> <> ʼ <EFBFBD> <CABC> List
m_Image . Create ( 16 , 16 , ILC_COLOR32 | ILC_MASK , 5 , 5 ) ;
m_Image . Add ( AfxGetApp ( ) - > LoadIcon ( IDI_L_MMSDF ) ) ;
m_Image . Add ( AfxGetApp ( ) - > LoadIcon ( IDI_L_LOCK ) ) ;
m_wndList . SubClassWindow2 ( ) ;
m_wndList . SetHeadings ( _T ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,50; дʱ<D0B4> <CAB1> ,135;<3B> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,60;<3B> <> <EFBFBD> Ŵ<EFBFBD> С ,100; <20> <> ʱʱ<CAB1> <CAB1> ,135; <20> <> <EFBFBD> ű<EFBFBD> <C5B1> <EFBFBD> ,200;" ) ) ;
m_wndList . SetGridLines ( true ) ;
m_wndList . SetImageList ( & m_Image , LVSIL_SMALL ) ;
//m_wndList.SetBkColor( RGB(237,191,175) );
//m_wndList.SetTextBkColor( RGB(237,191,175) );
m_bInit = true ;
return TRUE ; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CFMmsDF : : ReHide ( )
{
ShowWindow ( SW_HIDE ) ;
return true ;
}
BOOL CFMmsDF : : ReShow ( BOOL bRefresh )
{
ShowWindow ( SW_SHOW ) ;
if ( bRefresh | | ! m_bRefresh )
{
RefreshInfo ( ) ;
}
return true ;
}
BOOL CFMmsDF : : RefreshInfo ( )
{
m_wndList . ShowWindow ( SW_HIDE ) ; //Ϊ<> ˼ӿ<CBBC> <D3BF> <EFBFBD> ʾ <EFBFBD> ٶ<EFBFBD>
m_bRefresh = true ;
m_wndList . DeleteAllItems ( ) ;
CString str ;
str . Format ( _T ( " select * from mmsbox where BoxType='0' %s order by CreateTime " ) , m_strFindAdd ) ; //<2F> <> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
BOOL b = m_AdoRS . Open ( str ) ;
CAdoRecordSet AdoRS ;
AdoRS . SetAdoConnection ( & m_pMainFrame - > m_adoConnection ) ;
long lCount = 0 ;
COleDateTime ot ;
SYSTEMTIME t = { 0 } ;
long lBoxID = 0 ;
long lSMSCount = 0 ;
long lSize = 0 ;
CString strID ;
CString strCreateTime ;
CString strUserCount ;
CString strTitle ;
CString strSize ;
COleDateTime tTimer ;
CString strTimer ;
if ( b & & m_AdoRS . GetRecordCount ( ) )
{
m_AdoRS . MoveFirst ( ) ;
while ( ! m_AdoRS . IsEOF ( ) )
{
m_AdoRS . GetCollect ( _T ( " BoxID " ) , lBoxID ) ;
m_AdoRS . GetCollect ( _T ( " CreateTime " ) , ot ) ; ot . GetAsSystemTime ( t ) ;
lSize = 0 ;
strTitle = CString ( _T ( " " ) ) ;
m_AdoRS . GetCollect ( _T ( " mmSize " ) , lSize ) ; strSize . Format ( _T ( " %6.1fk " ) , ( double ) lSize / 1024.0f ) ;
m_AdoRS . GetCollect ( _T ( " Title " ) , strTitle ) ;
m_AdoRS . GetCollect ( _T ( " Timer " ) , tTimer ) ;
/*
m_wndList . InsertItem ( 0 , _itot ( lCount + 1 , szTemp , 10 ) , 0 ) ;
m_AdoRS . GetCollect ( " BoxID " , lBoxID ) ;
m_AdoRS . GetCollect ( " CreateTime " , ot ) ; ot . GetAsSystemTime ( t ) ;
_stprintf ( szTemp , " %04d.%02d.%02d %02d:%02d " , t . wYear , t . wMonth , t . wDay , t . wHour , t . wMinute ) ;
m_wndList . SetItemText ( 0 , 1 , szTemp ) ;
m_AdoRS . GetCollect ( " Msg " , szMsg ) ;
m_wndList . SetItemText ( 0 , 3 , szMsg ) ;
*/
//ȡ<> <C8A1> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD>
lSMSCount = 0 ;
str . Format ( _T ( " select Count(*) from mmsitem where BoxID=%d " ) , lBoxID ) ;
BOOL b2 = AdoRS . Open ( str ) ;
if ( b2 & & AdoRS . GetRecordCount ( ) )
{
AdoRS . MoveFirst ( ) ;
long lIndex = 0 ;
AdoRS . GetCollect ( lIndex , lSMSCount ) ;
}
strID . Format ( _T ( " %d " ) , lCount + 1 ) ;
strCreateTime . Format ( _T ( " %04d.%02d.%02d %02d:%02d " ) , t . wYear , t . wMonth , t . wDay , t . wHour , t . wMinute ) ;
strUserCount . Format ( _T ( " %d " ) , lSMSCount ) ;
strTimer = _T ( " " ) ;
if ( tTimer . GetStatus ( ) = = COleDateTime : : valid )
{
strTimer . Format ( _T ( " %04d.%02d.%02d %02d:%02d " ) , tTimer . GetYear ( ) , tTimer . GetMonth ( ) , tTimer . GetDay ( ) , tTimer . GetHour ( ) , tTimer . GetMinute ( ) ) ;
}
2025-04-14 17:24:47 +08:00
m_wndList . InsertItemAndCol ( 0 , strID , strCreateTime , strUserCount , strSize , strTimer , strTitle ) ;
2025-02-27 16:58:16 +08:00
m_wndList . SetItemData ( 0 , lBoxID ) ;
/*
//<2F> <> ʾ <EFBFBD> <CABE> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD>
m_wndList . SetItemText ( 0 , 2 , _itot ( lSMSCount , szTemp , 10 ) ) ;
*/
lCount + + ;
m_AdoRS . MoveNext ( ) ;
}
}
m_wndList . ShowWindow ( SW_SHOW ) ; //Ϊ<> ˼ӿ<CBBC> <D3BF> <EFBFBD> ʾ <EFBFBD> ٶ<EFBFBD>
return true ;
}
void CFMmsDF : : OnSize ( UINT nType , int cx , int cy )
{
CDialog : : OnSize ( nType , cx , cy ) ;
if ( m_bInit )
{
m_wndList . MoveWindow ( 0 , 0 , cx , cy ) ;
}
}
void CFMmsDF : : OnRclickSmsdfList ( NMHDR * pNMHDR , LRESULT * pResult )
{
* pResult = 0 ;
ShowRMenu ( ) ;
}
void CFMmsDF : : ShowRMenu ( )
{
// if (!m_pMainFrame->GetUserPurview(PURVIEW_GADDRESS_SEE,false)) //û<> в鿴Ȩ<E9BFB4> <C8A8>
// return ;
CMenu menu ;
menu . CreatePopupMenu ( ) ;
BOOL bLock = false ;
long lItem = this - > GetCurrentSelected ( ) ;
menu . AppendMenu ( MF_STRING , MENU_DF_ADD , _T ( " <20> ½<EFBFBD> <C2BD> б <EFBFBD> " ) ) ;
if ( lItem > = 0 )
{
menu . AppendMenu ( MF_STRING , MENU_DF_MODIFY , _T ( " <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
menu . AppendMenu ( MF_STRING , MENU_DF_RESEND , _T ( " <20> <> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> " ) ) ;
menu . AppendMenu ( MF_STRING , MENU_DF_DEL , _T ( " ɾ <20> <> " ) ) ;
}
else
{
menu . AppendMenu ( MF_STRING | MF_DISABLED | MF_GRAYED , MENU_DF_MODIFY , _T ( " <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
menu . AppendMenu ( MF_STRING | MF_DISABLED | MF_GRAYED , MENU_DF_RESEND , _T ( " <20> <> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> " ) ) ;
menu . AppendMenu ( MF_STRING | MF_DISABLED | MF_GRAYED , MENU_DF_DEL , _T ( " ɾ <20> <> " ) ) ;
}
menu . AppendMenu ( MF_SEPARATOR ) ;
//ˢ<> <CBA2>
menu . AppendMenu ( MF_STRING , MENU_DF_EXPORT , _T ( " <20> <> <EFBFBD> <EFBFBD> ... " ) ) ;
menu . AppendMenu ( MF_STRING , MENU_DF_FIND , _T ( " <20> <> <EFBFBD> <EFBFBD> ... " ) ) ;
menu . AppendMenu ( MF_SEPARATOR ) ;
//ˢ<> <CBA2>
menu . AppendMenu ( MF_STRING , MENU_DF_REFRESH , _T ( " ˢ <20> <> " ) ) ;
//<2F> <> ʾ <EFBFBD> ˵<EFBFBD>
POINT pt ;
: : GetCursorPos ( & pt ) ;
//this->ClientToScreen( &pt);
menu . TrackPopupMenu ( TPM_LEFTBUTTON | TPM_RIGHTBUTTON , pt . x , pt . y , this , NULL ) ;
menu . DestroyMenu ( ) ;
}
long CFMmsDF : : GetCurrentSelected ( )
{
POSITION pos = m_wndList . GetFirstSelectedItemPosition ( ) ;
if ( pos )
{
return m_wndList . GetNextSelectedItem ( pos ) ;
}
return - 1 ;
}
void CFMmsDF : : On_User_Add ( )
{
m_pMainFrame - > m_pFuncView - > On_User_List_Add_Mms ( ) ;
}
void CFMmsDF : : On_User_Modify ( )
{
long lItem = GetCurrentSelected ( ) ;
if ( lItem < 0 )
return ;
CString strTemp = _T ( " <EFBFBD> <EFBFBD> ѡ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \" <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \" <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> δ<EFBFBD> <EFBFBD> <EFBFBD> Ķ<EFBFBD> <EFBFBD> Ž<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͣ<EFBFBD> \r \n " ) \
_T ( " <EFBFBD> Ƿ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
int iRet = MessageBox ( strTemp , _T ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) , MB_ICONQUESTION | MB_YESNO ) ;
if ( iRet ! = IDYES )
return ;
long lBoxID = m_wndList . GetItemData ( lItem ) ;
if ( lBoxID < = 0 )
return ;
m_pMainFrame - > m_pFuncView - > On_User_List_Read_Mms ( lBoxID ) ;
}
void CFMmsDF : : On_User_ReSend ( )
{
long lItem = GetCurrentSelected ( ) ;
if ( lItem < 0 )
return ;
CString strTemp = _T ( " <EFBFBD> <EFBFBD> ѡ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \" <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> \" <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD> <EFBFBD> Ž<EFBFBD> <EFBFBD> ᱻ<EFBFBD> ٴ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> ͣ<EFBFBD> \r \n " ) \
_T ( " <EFBFBD> Ƿ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
int iRet = MessageBox ( strTemp , _T ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) , MB_ICONQUESTION | MB_YESNO ) ;
if ( iRet ! = IDYES )
return ;
long lBoxID = m_wndList . GetItemData ( lItem ) ;
if ( lBoxID < = 0 )
return ;
m_pMainFrame - > m_pFuncView - > On_User_List_ReSend_Mms ( lBoxID ) ;
}
void CFMmsDF : : On_User_Del ( )
{
long lCount = m_wndList . GetSelectedCount ( ) ;
long * lDel = new long [ lCount + 2 ] ;
POSITION pos = m_wndList . GetFirstSelectedItemPosition ( ) ;
long i = 0 ;
while ( pos )
{
lDel [ i ] = m_wndList . GetNextSelectedItem ( pos ) ;
i + + ;
}
//<2F> <> תɾ<D7AA> <C9BE>
m_wndList . ShowWindow ( SW_HIDE ) ; //<2F> ӿ<EFBFBD> <D3BF> <EFBFBD> ʾ <EFBFBD> <CABE> <EFBFBD> ٶ<EFBFBD>
for ( i = lCount ; i > 0 ; i - - )
{
long lBoxID = m_wndList . GetItemData ( lDel [ i - 1 ] ) ;
if ( lBoxID < = 0 )
continue ;
if ( m_pMainFrame - > m_pFuncView - > m_DLGSendMms . GetBoxID ( ) = = lBoxID )
{
long lRet = MessageBox ( _T ( " Ҫɾ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> б <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> б ༭<EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> ȷʵɾ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) , _T ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) , MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 ) ;
if ( lRet ! = IDYES )
continue ;
if ( ! m_pMainFrame - > m_pFuncView - > m_DLGSendMms . List_Save ( ) )
continue ;
if ( ! m_pMainFrame - > m_pFuncView - > m_DLGSendMms . List_New ( ) )
continue ;
}
TCHAR szSelect [ 128 ] = { 0 } ;
_stprintf ( szSelect , _T ( " delete from mmsbox where BoxID=%d " ) , lBoxID ) ; //<2F> <> ɾ<EFBFBD> <C9BE> smsBox
BOOL b = m_AdoRS . Open ( szSelect ) ;
_stprintf ( szSelect , _T ( " delete from mmsitem where BoxID=%d " ) , lBoxID ) ; //<2F> <> ɾ<EFBFBD> <C9BE> BoxItem
b = m_AdoRS . Open ( szSelect ) ;
m_wndList . DeleteItem ( lDel [ i - 1 ] ) ; //ɾ<> <C9BE> List<73> е <EFBFBD> Item
}
m_wndList . ShowWindow ( SW_SHOW ) ; //<2F> ӿ<EFBFBD> <D3BF> <EFBFBD> ʾ <EFBFBD> <CABE> <EFBFBD> ٶ<EFBFBD>
delete lDel ;
}
void CFMmsDF : : On_User_Refresh ( )
{
RefreshInfo ( ) ;
}
void CFMmsDF : : On_User_Find ( )
{
CString strTemp ;
DLG_Find_SmsBox dlg ( this ) ;
if ( dlg . DoModal ( ) = = IDOK )
{
strTemp . Format ( _T ( " AND CreateTime>=#%04d-%02d-%02d# AND CreateTime<=#%04d-%02d-%02d 23:59:59# " ) , dlg . m_TBegin . GetYear ( ) , dlg . m_TBegin . GetMonth ( ) , dlg . m_TBegin . GetDay ( ) , dlg . m_TEnd . GetYear ( ) , dlg . m_TEnd . GetMonth ( ) , dlg . m_TEnd . GetDay ( ) ) ;
m_strFindAdd = strTemp ;
if ( dlg . m_strMsg . GetLength ( ) > 0 )
{
strTemp . Format ( _T ( " AND Msg like '%%%s%%' " ) , dlg . m_strMsg ) ;
m_strFindAdd + = strTemp ;
}
On_User_Refresh ( ) ;
m_strFindAdd = _T ( " " ) ; //ˢ<> º<C2BA> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD>
}
}
void CFMmsDF : : On_User_Export ( )
{
DLG_SmsList_Export dlg ( this ) ;
dlg . SetParam ( & m_AdoRS2 , & m_wndList , 1 ) ;
dlg . DoModal ( ) ;
}
void CFMmsDF : : OnDblclkSmsdfList ( NMHDR * pNMHDR , LRESULT * pResult )
{
* pResult = 0 ;
On_User_Modify ( ) ;
}
void CFMmsDF : : OnKeydownSmsdfList ( NMHDR * pNMHDR , LRESULT * pResult )
{
LV_KEYDOWN * pLVKeyDow = ( LV_KEYDOWN * ) pNMHDR ;
* pResult = 0 ;
if ( pLVKeyDow - > wVKey = = VK_DELETE )
{
On_User_Del ( ) ;
}
if ( pLVKeyDow - > wVKey = = VK_INSERT )
{
On_User_Add ( ) ;
}
if ( pLVKeyDow - > wVKey = = VK_SPACE )
{
On_User_Modify ( ) ;
}
if ( pLVKeyDow - > wVKey = = ' S ' | | pLVKeyDow - > wVKey = = ' s ' )
{
On_User_ReSend ( ) ;
}
if ( pLVKeyDow - > wVKey = = ' R ' | | pLVKeyDow - > wVKey = = ' r ' )
{
On_User_Refresh ( ) ;
}
if ( pLVKeyDow - > wVKey = = ' F ' | | pLVKeyDow - > wVKey = = ' f ' )
{
On_User_Find ( ) ;
}
if ( pLVKeyDow - > wVKey = = ' A ' | | pLVKeyDow - > wVKey = = ' a ' )
{
m_wndList . SelectAllItems ( ) ;
}
}
void CFMmsDF : : OnOK ( )
{
//CDialog::OnOK();
}
void CFMmsDF : : OnCancel ( )
{
//CDialog::OnCancel();
}