376 lines
9.5 KiB
C++
376 lines
9.5 KiB
C++
// C_JCB.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "smsmanager.h"
|
||
#include "C_JCB.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CC_JCB dialog
|
||
#include "MainFrm.h"
|
||
#include "ProcessSocket.h"
|
||
|
||
CC_JCB::CC_JCB(CWnd* pParent /*=NULL*/)
|
||
: CDialog(CC_JCB::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CC_JCB)
|
||
m_lCorp = -1;
|
||
m_tBegin = COleDateTime::GetCurrentTime();
|
||
m_lQueryType = -1;
|
||
m_tEnd = COleDateTime::GetCurrentTime();
|
||
//}}AFX_DATA_INIT
|
||
m_bInit = false;
|
||
m_bRefresh = false;
|
||
m_bProcess = false;
|
||
}
|
||
|
||
|
||
void CC_JCB::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CC_JCB)
|
||
DDX_Control(pDX, IDC_C_JCB_QUERYTYPE, m_L_QueryType);
|
||
DDX_Control(pDX, IDC_C_JCB_MSG, m_E_Msg);
|
||
DDX_Control(pDX, IDC_C_JCB_S1, m_S_S1);
|
||
DDX_Control(pDX, IDC_C_JCB_LIST, m_wndList);
|
||
DDX_Control(pDX, IDC_C_JCB_CORPID, m_E_CorpID);
|
||
DDX_Control(pDX, IDC_C_JCB_CORP, m_L_Corp);
|
||
DDX_CBIndex(pDX, IDC_C_JCB_CORP, m_lCorp);
|
||
DDX_DateTimeCtrl(pDX, IDC_C_JCB_TBEGIN, m_tBegin);
|
||
DDX_CBIndex(pDX, IDC_C_JCB_QUERYTYPE, m_lQueryType);
|
||
DDX_DateTimeCtrl(pDX, IDC_C_JCB_TEND, m_tEnd);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CC_JCB, CDialog)
|
||
//{{AFX_MSG_MAP(CC_JCB)
|
||
ON_WM_SIZE()
|
||
ON_BN_CLICKED(IDC_C_JCB_QUERY2, OnCJcbQuery2)
|
||
ON_BN_CLICKED(IDC_C_JCB_QUERY, OnCJcbQuery)
|
||
ON_CBN_SELCHANGE(IDC_C_JCB_QUERYTYPE, OnSelchangeCJcbQuerytype)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CC_JCB message handlers
|
||
|
||
BOOL CC_JCB::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
//È¡µÃ¹²ÓòÎÊý
|
||
//CMainFrame * pFrame = static_cast <CMainFrame *>((CMainFrame *)AfxGetMainWnd());
|
||
this->GetParent()->GetParentFrame();
|
||
m_pMainFrame = (CMainFrame *)this->GetParent()->GetParentFrame();
|
||
m_pSocket = &m_pMainFrame->m_Socket;
|
||
|
||
//³õʼ»¯List
|
||
m_Image.Create(16,16,ILC_COLOR16|ILC_MASK,5,5);
|
||
m_Image.Add(AfxGetApp()->LoadIcon(IDI_L_LIST) );
|
||
m_wndList.SubClassWindow2();
|
||
m_wndList.SetHeadings(_T("ÐòºÅ,40;ÆóÒµID,70; ÆóÒµÃû³Æ,150;ÉÏÆÚ½á´æ,80;±¾ÆÚ´æÈë,80;±¾ÆÚÔùËÍ,80;±¾ÆÚʹÓÃ,80;±¾ÆÚ½á´æ,80;"));
|
||
m_wndList.SetGridLines(true);
|
||
// m_wndList.SetImageList(&m_Image,LVSIL_SMALL);
|
||
|
||
m_bInit = true;
|
||
|
||
/*
|
||
//ĬÈÏÈ¡ÉÏÔµÄÄÚÈÝ
|
||
SYSTEMTIME t; ::GetLocalTime(&t);
|
||
t.wDay = 1;//´Ó1ºÅÆð
|
||
t.wMonth = t.wMonth-1;
|
||
if ( t.wMonth <=0 )
|
||
{
|
||
t.wMonth = 12;
|
||
t.wYear = t.wYear-1;
|
||
}
|
||
m_tBegin.SetDate( t.wYear,t.wMonth,t.wDay ); //Æðʼ
|
||
if ( t.wMonth == 1 ||
|
||
t.wMonth == 3 ||
|
||
t.wMonth == 5 ||
|
||
t.wMonth == 7 ||
|
||
t.wMonth == 8 ||
|
||
t.wMonth == 10 ||
|
||
t.wMonth == 12 )
|
||
{
|
||
t.wDay = 31;
|
||
}
|
||
else
|
||
if (t.wMonth == 2 )
|
||
t.wDay = 28;
|
||
else
|
||
t.wDay = 30;
|
||
m_tEnd.SetDate( t.wYear,t.wMonth,t.wDay );//½áÊø
|
||
*/
|
||
|
||
SYSTEMTIME t; ::GetLocalTime(&t);
|
||
m_tBegin.SetDate( t.wYear,t.wMonth,1 ); //Æðʼ
|
||
m_tEnd.SetDate( t.wYear,t.wMonth,t.wDay );//½áÊø
|
||
m_tEnd = m_tEnd - COleDateTimeSpan(3,0,0,0); //¼õ3ÈÕ
|
||
|
||
m_lQueryType = 0; //ĬÈϲ鿴ËùÓÐÊÖ»úÀàÐÍ
|
||
|
||
UpdateData(false);
|
||
|
||
OnSelchangeCJcbQuerytype();
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
|
||
BOOL CC_JCB::ReHide()
|
||
{
|
||
ShowWindow( SW_HIDE );
|
||
return true;
|
||
}
|
||
|
||
BOOL CC_JCB::ReShow(BOOL bRefresh)
|
||
{
|
||
ShowWindow( SW_SHOW );
|
||
if ( bRefresh || !m_bRefresh )
|
||
{
|
||
RefreshInfo();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
BOOL CC_JCB::RefreshInfo()
|
||
{
|
||
if ( !m_pMainFrame->GetUserPurview(PURVIEW_TAB) )
|
||
{
|
||
return false;
|
||
}
|
||
m_pMainFrame->SendFrame(SMSFUNC_CORP_NAME,NULL,0);
|
||
return true;
|
||
}
|
||
|
||
BOOL CC_JCB::ProcessSocket(Socket_Head *pHead)
|
||
{
|
||
CString strTemp;
|
||
//È¡¹ýÂËÐÅÏ¢
|
||
if (pHead->lFuncType == SMSFUNC_CORP_NAME)
|
||
{
|
||
m_bRefresh = true; //ÒѾˢйý
|
||
ANS_Corp_Name * pCorp = (ANS_Corp_Name *)pHead->pFrame;
|
||
ANS_Corp_NameData * pData = (ANS_Corp_NameData *)(pHead->pFrame+sizeof(ANS_Corp_Name));
|
||
m_L_Corp.ResetContent(); //ɾ³ýÔÒÑÓÐµÄÆóÒµ
|
||
m_L_Corp.AddString( _T("ËùÓÐÆóÒµ") );
|
||
this->Close(); //¹Ø±ÕÔ¶ÓÁÐ
|
||
for ( int i=0;i<pCorp->lCount;i++ )
|
||
{
|
||
ANS_Corp_NameData * pNewData = new ANS_Corp_NameData;
|
||
*pNewData = *pData;
|
||
POSITION pos = m_Corp.AddTail(pNewData);
|
||
strTemp.Format( _T("%d-%s"),pData->lCorpID,pData->szCorpName);
|
||
long lItem = m_L_Corp.AddString( strTemp );
|
||
m_L_Corp.SetItemData( lItem , (DWORD_PTR)pos);
|
||
pData ++;
|
||
}
|
||
m_L_Corp.SetCurSel(0);
|
||
return true;
|
||
}
|
||
if ( pHead->lFuncType == SMSFUNC_JCB_SEE )
|
||
{
|
||
ANS_JCB_See * pJCB = (ANS_JCB_See *)pHead->pFrame;
|
||
ANS_JCB_SeeData * pData= (ANS_JCB_SeeData *)(pHead->pFrame+sizeof(ANS_JCB_See));
|
||
m_wndList.ShowWindow( SW_HIDE ); //¼Ó¿ìËÙ¶È
|
||
m_wndList.DeleteAllItems();
|
||
TCHAR Buf[128]={0};
|
||
long lSmsAdd=0;
|
||
long lPresent=0;
|
||
long lSmsSend=0;
|
||
long lSmsAll=0;
|
||
CString strMsg;
|
||
for ( int i=0 ; i<pJCB->lCount ; i++ )
|
||
{
|
||
lSmsAdd += pData->lAddCount;
|
||
lPresent += pData->lPresentCount;
|
||
lSmsSend += pData->lSendCount;
|
||
lSmsAll += pData->lUseCount;
|
||
strMsg+=_T("\r\n\r\n---------------------------------------------------------------");
|
||
_stprintf( Buf ,_T("\r\n ÆóÒµ¶ÌÐÅÕʵ¥ %04d.%02d.%02d - %04d.%02d.%02d"),pJCB->tBegin.wYear,pJCB->tBegin.wMonth,pJCB->tBegin.wDay,pJCB->tEnd.wYear,pJCB->tEnd.wMonth,pJCB->tEnd.wDay );
|
||
strMsg+= Buf;
|
||
strMsg+= _T("\r\n (µ¥Î»:Ìõ)\r\n");
|
||
//m_wndList.SetHeadings(_T("ÐòºÅ,40;ÆóÒµID,70; ÆóÒµÃû³Æ,150;ÉÏÆÚ½á´æ,80;±¾ÆÚ´æÈë,80;±¾ÆÚÔùËÍ,80;±¾ÆÚʹÓÃ,80;±¾ÆÚ½á´æ,80;"));
|
||
_stprintf( Buf , _T("%d") , i+1 );
|
||
m_wndList.InsertItem( i , Buf , 0 ); //ItemΪ0µÄÔÒòÊǵ¹×ªÏÔʾ
|
||
_stprintf( Buf , _T("%d"),pData->lCorpID);
|
||
m_wndList.SetItemText( i , 1 , Buf);
|
||
strMsg+= _T("\r\n ÆóÒµID:");
|
||
strMsg+= Buf;
|
||
m_wndList.SetItemText( i , 2 , pData->szCorpName );
|
||
strMsg+= _T("\r\n ÆóÒµÃû³Æ:");
|
||
strMsg+= pData->szCorpName;
|
||
_stprintf( Buf , _T("%8d") , pData->lOldCount);
|
||
m_wndList.SetItemText( i , 3 , Buf );
|
||
strMsg+= _T("\r\n ÉÏÆÚ½á´æ:");
|
||
strMsg+= Buf;
|
||
_stprintf( Buf , _T("%8d") , pData->lAddCount);
|
||
m_wndList.SetItemText( i , 4 , Buf );
|
||
strMsg+= _T("\r\n ±¾ÆÚ´æÈë:");
|
||
strMsg+= Buf;
|
||
_stprintf( Buf , _T("%8d") , pData->lPresentCount);
|
||
m_wndList.SetItemText( i , 5 , Buf );
|
||
strMsg+= _T("\r\n ±¾ÆÚÔùËÍ:");
|
||
strMsg+= Buf;
|
||
_stprintf( Buf , _T("%8d") , pData->lSendCount);
|
||
m_wndList.SetItemText( i , 6 , Buf );
|
||
strMsg+= _T("\r\n ±¾ÆÚʹÓÃ:");
|
||
strMsg+= Buf;
|
||
|
||
_stprintf( Buf , _T("%8d") , pData->lUseCount);
|
||
m_wndList.SetItemText( i , 7 , Buf );
|
||
strMsg+= _T("\r\n ±¾ÆÚ½á´æ:");
|
||
strMsg+= Buf;
|
||
|
||
pData ++;
|
||
}
|
||
|
||
m_wndList.InsertItem( i , _T("") , 0 ); //ItemΪ0µÄÔÒòÊǵ¹×ªÏÔʾ
|
||
i++;
|
||
_stprintf( Buf , _T("%d") , i+1 );
|
||
m_wndList.InsertItem( i , Buf , 0 ); //ItemΪ0µÄÔÒòÊǵ¹×ªÏÔʾ
|
||
_stprintf( Buf , _T("%8d") , lSmsAdd);
|
||
m_wndList.SetItemText( i , 4 , Buf );
|
||
_stprintf( Buf , _T("%8d") , lPresent);
|
||
m_wndList.SetItemText( i , 5 , Buf );
|
||
_stprintf( Buf , _T("%8d") , lSmsSend);
|
||
m_wndList.SetItemText( i , 6 , Buf );
|
||
_stprintf( Buf , _T("%8d") , lSmsAll);
|
||
m_wndList.SetItemText( i , 7 , Buf );
|
||
|
||
|
||
m_wndList.ShowWindow( SW_SHOW ); //¼Ó¿ìËÙ¶È
|
||
m_E_Msg.SetWindowText(strMsg);
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void CC_JCB::OnSize(UINT nType, int cx, int cy)
|
||
{
|
||
CDialog::OnSize(nType, cx, cy);
|
||
|
||
if ( m_bInit )
|
||
{
|
||
CRect rect;
|
||
m_S_S1.GetWindowRect(&rect);
|
||
m_wndList.MoveWindow( 0 , 0+rect.Height()+5 , cx,cy-rect.Height()-5);
|
||
m_E_Msg.MoveWindow( 0 , 0+rect.Height()+5 , cx,cy-rect.Height()-5);
|
||
}
|
||
}
|
||
|
||
void CC_JCB::Close()
|
||
{
|
||
//Çå³ý¶ÓÁÐÖеÄÄÚÈÝ
|
||
while (!m_Corp.IsEmpty())
|
||
{
|
||
ANS_Corp_NameData * pData = m_Corp.GetHead();
|
||
m_Corp.RemoveHead();
|
||
delete pData;
|
||
}
|
||
}
|
||
|
||
void CC_JCB::OnCJcbQuery2()
|
||
{
|
||
CString strTemp;
|
||
CString strFind;
|
||
m_E_CorpID.GetWindowText(strFind);
|
||
if ( strFind.GetLength()<=0 )
|
||
return ;
|
||
long lSel = m_L_Corp.GetCurSel();
|
||
long lCount = m_L_Corp.GetCount();
|
||
for ( int i=lSel+1 ; i<lCount ; i++ )
|
||
{
|
||
m_L_Corp.GetLBText(i,strTemp);
|
||
if ( strTemp.Find(strFind)>=0 )
|
||
{
|
||
m_L_Corp.SetCurSel(i);
|
||
return ;
|
||
}
|
||
}
|
||
for ( i=0 ; i<lSel ; i++ )
|
||
{
|
||
m_L_Corp.GetLBText(i,strTemp);
|
||
if ( strTemp.Find(strFind)>=0 )
|
||
{
|
||
m_L_Corp.SetCurSel(i);
|
||
return ;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CC_JCB::OnCJcbQuery()
|
||
{
|
||
MessageBox(_T("½á´æ±í¹¦ÄÜÒÑ×ªÒÆµ½\"Õʵ¥²éѯ\"¹¦ÄÜÖУ¬ÇëÒÆ²½!\r\nÕʵ¥²éѯ->½á´æ±í->Á¢¼´²éѯ") , _T("ÐÅÏ¢") , MB_ICONWARNING );
|
||
return ;
|
||
|
||
UpdateData(true);
|
||
if ( m_tEnd > (COleDateTime::GetCurrentTime() - COleDateTimeSpan(3,0,0,0)) )
|
||
{
|
||
MessageBox( _T("½á´æ±íµÄ½áÊøÈÕÆÚ±ØÐëÊÇÁ½Ììǰ£¬Çë¸ÄÕý!") , _T("´íÎó") , MB_ICONWARNING );
|
||
//m_tEnd = m_tEnd - COleDateTime(0,0,3,0,0,0); //¼õ3ÈÕ
|
||
UpdateData(false);
|
||
return ;
|
||
}
|
||
|
||
if ( m_tEnd < m_tBegin )
|
||
{
|
||
MessageBox( _T("²éѯ½áÊøÈÕÆÚ²»ÄÜСÓÚÆðʼÈÕÆÚ£¬Çë¸ÄÕý!") , _T("´íÎó") , MB_ICONWARNING );
|
||
return ;
|
||
}
|
||
REQ_JCB_See * pJCB = new REQ_JCB_See;memset(pJCB,0,sizeof(REQ_JCB_See));
|
||
|
||
pJCB->lCorpID = -1;
|
||
if ( m_lCorp >= 0 )
|
||
{
|
||
if ( m_lCorp == 0 ) //Ñ¡ÁËËùÓÐÆóÒµ
|
||
{
|
||
pJCB->lCorpID = -1;
|
||
}
|
||
else
|
||
{
|
||
POSITION pos = (POSITION)m_L_Corp.GetItemData(m_lCorp);
|
||
POSITION pos2 = pos;
|
||
ANS_Corp_NameData * pData = m_Corp.GetNext( pos );
|
||
if (pData)
|
||
{
|
||
pJCB->lCorpID = pData->lCorpID;
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
m_tBegin.GetAsSystemTime( pJCB->tBegin );
|
||
m_tEnd.GetAsSystemTime( pJCB->tEnd );
|
||
pJCB->lQueryType = m_lQueryType;
|
||
m_pMainFrame->SendFrame(SMSFUNC_JCB_SEE,(BYTE*)pJCB,sizeof(REQ_JCB_See));
|
||
|
||
return ;
|
||
}
|
||
|
||
void CC_JCB::OnSelchangeCJcbQuerytype()
|
||
{
|
||
if ( m_L_QueryType.GetCurSel() == 0 )
|
||
{
|
||
m_wndList.ShowWindow( SW_SHOW );
|
||
m_E_Msg.ShowWindow( SW_HIDE );
|
||
}
|
||
else
|
||
{
|
||
m_wndList.ShowWindow( SW_HIDE );
|
||
m_E_Msg.ShowWindow( SW_SHOW );
|
||
}
|
||
|
||
}
|