2025-02-27 16:58:16 +08:00
// FFaxDF.cpp : implementation file
//
# include "stdafx.h"
# include "CorpSms.h"
# include "FFaxDF.h"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
static char THIS_FILE [ ] = __FILE__ ;
# endif
/////////////////////////////////////////////////////////////////////////////
// CFFaxDF dialog
# include "MainFrm.h"
# include "ProcessSocket.h"
# include "DLG_Find_SmsBox.h"
# include "DLG_SmsList_Export.h"
CFFaxDF : : CFFaxDF ( CWnd * pParent /*=NULL*/ )
: CDialog ( CFFaxDF : : IDD , pParent )
{
//{{AFX_DATA_INIT(CFFaxDF)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bInit = false ;
m_bRefresh = false ;
}
void CFFaxDF : : DoDataExchange ( CDataExchange * pDX )
{
CDialog : : DoDataExchange ( pDX ) ;
//{{AFX_DATA_MAP(CFFaxDF)
DDX_Control ( pDX , IDC_FAXDF_LIST , m_wndList ) ;
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP ( CFFaxDF , CDialog )
//{{AFX_MSG_MAP(CFFaxDF)
ON_WM_SIZE ( )
ON_NOTIFY ( NM_RCLICK , IDC_FAXDF_LIST , OnRclickSmsdfList )
ON_NOTIFY ( NM_DBLCLK , IDC_FAXDF_LIST , OnDblclkSmsdfList )
ON_NOTIFY ( LVN_KEYDOWN , IDC_FAXDF_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 ( )
/////////////////////////////////////////////////////////////////////////////
// CFFaxDF message handlers
BOOL CFFaxDF : : 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_SMSDF ) ) ;
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; <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,200; <20> <> <EFBFBD> <EFBFBD> 1,120; <20> <> <EFBFBD> <EFBFBD> 2,120; <20> <> <EFBFBD> <EFBFBD> 3,120; <20> <> <EFBFBD> <EFBFBD> 4,120; <20> <> <EFBFBD> <EFBFBD> 5,120;" ) ) ;
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 CFFaxDF : : ReHide ( )
{
ShowWindow ( SW_HIDE ) ;
return true ;
}
BOOL CFFaxDF : : ReShow ( BOOL bRefresh )
{
ShowWindow ( SW_SHOW ) ;
if ( bRefresh | | ! m_bRefresh )
{
RefreshInfo ( ) ;
}
return true ;
}
BOOL CFFaxDF : : RefreshInfo ( )
{
m_wndList . ShowWindow ( SW_HIDE ) ; //Ϊ<> ˼ӿ<CBBC> <D3BF> <EFBFBD> ʾ <EFBFBD> ٶ<EFBFBD>
m_bRefresh = true ;
m_wndList . DeleteAllItems ( ) ;
CString str ;
str . Format ( _T ( " select * from faxbox 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 } ;
TCHAR szTemp [ 64 ] = { 0 } ;
CString strTitle ;
CString strAttach1 , strAttach2 , strAttach3 , strAttach4 , strAttach5 ;
long lBoxID = 0 ;
long lSMSCount = 0 ;
CString strID ;
CString strCreateTime ;
CString strUserCount ;
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 ) ;
m_AdoRS . GetCollect ( _T ( " Title " ) , strTitle ) ;
m_AdoRS . GetCollect ( _T ( " FileName1 " ) , strAttach1 ) ;
m_AdoRS . GetCollect ( _T ( " FileName2 " ) , strAttach2 ) ;
m_AdoRS . GetCollect ( _T ( " FileName3 " ) , strAttach3 ) ;
m_AdoRS . GetCollect ( _T ( " FileName4 " ) , strAttach4 ) ;
m_AdoRS . GetCollect ( _T ( " FileName5 " ) , strAttach5 ) ;
strAttach1 = ExPath ( strAttach1 ) ;
strAttach2 = ExPath ( strAttach2 ) ;
strAttach3 = ExPath ( strAttach3 ) ;
strAttach4 = ExPath ( strAttach4 ) ;
strAttach5 = ExPath ( strAttach5 ) ;
//ȡ<> <C8A1> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD>
lSMSCount = 0 ;
_stprintf ( szTemp , _T ( " select Count(*) from faxitem where BoxID=%d " ) , lBoxID ) ;
BOOL b2 = AdoRS . Open ( szTemp ) ;
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 ) ;
2025-04-14 17:24:47 +08:00
m_wndList . InsertItemAndCol ( 0 , strID , strCreateTime , strUserCount , strTitle , strAttach1 , strAttach2 , strAttach3 , strAttach4 , strAttach5 ) ;
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 CFFaxDF : : OnSize ( UINT nType , int cx , int cy )
{
CDialog : : OnSize ( nType , cx , cy ) ;
if ( m_bInit )
{
m_wndList . MoveWindow ( 0 , 0 , cx , cy ) ;
}
}
void CFFaxDF : : OnRclickSmsdfList ( NMHDR * pNMHDR , LRESULT * pResult )
{
* pResult = 0 ;
ShowRMenu ( ) ;
}
void CFFaxDF : : 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 CFFaxDF : : GetCurrentSelected ( )
{
POSITION pos = m_wndList . GetFirstSelectedItemPosition ( ) ;
if ( pos )
{
return m_wndList . GetNextSelectedItem ( pos ) ;
}
return - 1 ;
}
void CFFaxDF : : On_User_Add ( )
{
m_pMainFrame - > m_pFuncView - > On_User_List_Add_Fax ( ) ;
}
void CFFaxDF : : 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> \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_Fax ( lBoxID ) ;
}
void CFFaxDF : : 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> \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_Fax ( lBoxID ) ;
}
void CFFaxDF : : 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_DLGSendFax . 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_DLGSendFax . List_Save ( ) )
continue ;
if ( ! m_pMainFrame - > m_pFuncView - > m_DLGSendFax . List_New ( ) )
continue ;
}
TCHAR szSelect [ 128 ] = { 0 } ;
_stprintf ( szSelect , _T ( " delete from faxbox where BoxID=%d " ) , lBoxID ) ; //<2F> <> ɾ<EFBFBD> <C9BE> smsBox
BOOL b = m_AdoRS . Open ( szSelect ) ;
_stprintf ( szSelect , _T ( " delete from faxitem 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 CFFaxDF : : On_User_Refresh ( )
{
RefreshInfo ( ) ;
}
void CFFaxDF : : On_User_Find ( )
{
CString strTemp ;
DLG_Find_SmsBox dlg ( this ) ;
dlg . SetType ( 2 ) ; //fax
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 Title like '%%%s%%' " ) , dlg . m_strMsg ) ;
m_strFindAdd + = strTemp ;
}
On_User_Refresh ( ) ;
m_strFindAdd = _T ( " " ) ; //ˢ<> º<C2BA> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD>
}
}
void CFFaxDF : : On_User_Export ( )
{
DLG_SmsList_Export dlg ( this ) ;
dlg . SetParam ( & m_AdoRS2 , & m_wndList , 2 ) ;
dlg . DoModal ( ) ;
}
void CFFaxDF : : OnDblclkSmsdfList ( NMHDR * pNMHDR , LRESULT * pResult )
{
* pResult = 0 ;
On_User_Modify ( ) ;
}
void CFFaxDF : : 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 CFFaxDF : : OnOK ( )
{
//CDialog::OnOK();
}
void CFFaxDF : : OnCancel ( )
{
//CDialog::OnCancel();
}
CString CFFaxDF : : ExPath ( CString strFileName )
{
CString strRet = strFileName ;
long lLen = strFileName . GetLength ( ) ;
for ( int i = lLen - 1 ; i > = 0 ; i - - )
{
CString str = strFileName . Mid ( i , 1 ) ;
if ( str = = CString ( _T ( " \\ " ) ) | | str = = CString ( _T ( " / " ) ) )
{
strRet = strFileName . Right ( lLen - i - 1 ) ;
break ;
}
}
return strRet ;
}