⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statics.cpp

📁 IP电话计费管理系统本地版
💻 CPP
字号:
/****************************************************************************

    编写日期:  2002-07-28
    代码编写:  by xiaolz
    代码功能:  话费统计,显示通话的总时长和通话的总话费

****************************************************************************/
#include "stdafx.h"
#include "IPCount.h"
#include "Statics.h"
#include "IPCountDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStatics dialog


CStatics::CStatics(CWnd* pParent /*=NULL*/)
	: CDialog(CStatics::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStatics)
	m_strDay1 = _T("");
	m_strDay2 = _T("");
	m_strShowCount = _T("");
	m_strShowTLen = _T("");
	m_strMon1 = _T("");
	m_strMon2 = _T("");
	//}}AFX_DATA_INIT
	nFlag=0;
	bDaySearch=FALSE;
    bMonSearch=FALSE; 
	nFlagRadio=0;
}


void CStatics::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStatics)
	DDX_Control(pDX, IDC_EDIT4, m_eStrMon2);
	DDX_Control(pDX, IDC_EDIT3, m_eStrMon1);
	DDX_Control(pDX, IDC_EDIT2, m_eStrDay2);
	DDX_Control(pDX, IDC_EDIT1, m_eStrDay1);
	DDX_Text(pDX, IDC_EDIT1, m_strDay1);
	DDX_Text(pDX, IDC_EDIT2, m_strDay2);
	DDX_Text(pDX, IDC_EDIT5, m_strShowCount);
	DDX_Text(pDX, IDC_EDIT6, m_strShowTLen);
	DDX_Text(pDX, IDC_EDIT3, m_strMon1);
	DDX_Text(pDX, IDC_EDIT4, m_strMon2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStatics, CDialog)
	//{{AFX_MSG_MAP(CStatics)
	ON_BN_CLICKED(IDC_BUTTON2, OnStatics)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStatics message handlers

BOOL CStatics::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_STATICS),TRUE);
	SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_STATICS),FALSE);
    CTime t=CTime::GetCurrentTime();
	m_strDay1=m_strDay2=t.Format("%Y-%m-%d");
	m_strMon1=m_strMon2=t.Format("%Y-%m");
    CButton * b1=(CButton *)GetDlgItem(IDC_RADIO1);
    b1->SetCheck(1);
	OnRadio1(); 
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


//统计一日,一月或一段时间的话费和通话时长
void CStatics::OnStatics() 
{
	// TODO: Add your control notification handler code here
    UpdateData(TRUE);
	CIPCountDlg *cdlg;
	cdlg=(CIPCountDlg *)GetParent();
	if(cdlg==NULL)
		return;
	if((!bDaySearch)&&(!bMonSearch))
	{
		AfxMessageBox("请选择查询的条件!");
		return;
	}
	if(bDaySearch)
	{
	    if((m_strDay1.GetLength()<9)||(m_strDay2.GetLength()<9))
		    return;
	    m_strSDay1=m_strDay1.Mid(8);
	    m_strSDay2=m_strDay2.Mid(8);
		if(m_strSDay1.GetLength()==1)//日期格式为7,而不是07,则转化成07
			m_strSDay1='0'+m_strSDay1;
		if(m_strSDay2.GetLength()==1)
			m_strSDay2='0'+m_strSDay2;
	    if(strcmp(m_strSDay1,m_strSDay2)==0)
		{
		    nFlag=1;//单日记录
            cdlg->ReadFromDb();
		}
	    else if(strcmp(m_strSDay1,m_strSDay2)<0)
		{
            nFlag=2;//从strDay1到strDay2的记录
		    cdlg->ReadFromDb();
		}
	    else
		{
			m_strShowCount="";
			m_strShowTLen="";
			AfxMessageBox("不能查询!");
		}
	}
	if(bMonSearch)
	{
        if((m_strMon1.GetLength()<6)||(m_strMon2.GetLength()<6))
			return;
	    m_strSMon1=m_strMon1.Mid(5);
	    m_strSMon2=m_strMon2.Mid(5);
		if(m_strSMon1.GetLength()==1)
			m_strSMon1='0'+m_strSMon1;
		if(m_strSMon2.GetLength()==1)
			m_strSMon2='0'+m_strSMon2;
	    if(strcmp(m_strSMon1,m_strSMon2)==0)
		{
		    nFlag=3;//单月记录
            cdlg->ReadFromDb();
		}
	    else if(strcmp(m_strSMon1,m_strSMon2)<0)
		{
            nFlag=4;//从m_strSMon1到m_strSMon2的记录
		    cdlg->ReadFromDb();
		}
	    else
		{
			m_strShowCount="";
			m_strShowTLen="";
			AfxMessageBox("不能查询!");
		}
	}
	UpdateData(FALSE);
}


//选择按日统计
void CStatics::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	nFlagRadio=1;
	bDaySearch=TRUE;
	bMonSearch=FALSE;
	m_eStrDay1.EnableWindow(TRUE);
	m_eStrDay2.EnableWindow(TRUE);
	m_eStrMon1.EnableWindow(FALSE);
	m_eStrMon2.EnableWindow(FALSE);
}

//选择按月统计
void CStatics::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	nFlagRadio=2;
	bDaySearch=FALSE;
	bMonSearch=TRUE;
	m_eStrDay1.EnableWindow(FALSE);
	m_eStrDay2.EnableWindow(FALSE);
	m_eStrMon1.EnableWindow(TRUE);
	m_eStrMon2.EnableWindow(TRUE);
}

HBRUSH CStatics::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	// TODO: Change any attributes of the DC here
	if(pWnd ->m_hWnd == GetDlgItem(IDC_EDIT5) ->m_hWnd)	
	{
		pDC ->SetTextColor(RGB(255,25,0));
	}
	if(pWnd ->m_hWnd == GetDlgItem(IDC_EDIT6) ->m_hWnd)	
	{
		pDC ->SetTextColor(RGB(255,25,0));
	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

void CStatics::OnCancel() 
{
	// TODO: Add extra cleanup here
	CIPCountDlg *cdlg;
	cdlg=(CIPCountDlg *)GetParent();
	if(cdlg==NULL)
		return;
	cdlg->bStatics=FALSE;
	
	CDialog::OnCancel();
	DestroyWindow();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -