// DLG_C_Pay_YS.cpp : implementation file // #include "stdafx.h" #include "smsmanager.h" #include "DLG_C_Pay_YS.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DLG_C_Pay_YS dialog DLG_C_Pay_YS::DLG_C_Pay_YS(CWnd* pParent /*=NULL*/) : CDialog(DLG_C_Pay_YS::IDD, pParent) { //{{AFX_DATA_INIT(DLG_C_Pay_YS) m_strBZ = _T(""); m_strPayMode = _T(""); m_tPayTime = COleDateTime::GetCurrentTime(); m_strPrice = _T(""); m_strPriceOne = _T(""); m_strSmsCount = _T(""); //}}AFX_DATA_INIT m_bMonPay = false; m_bAddMonPay = false; memset(&m_Pay,0,sizeof(m_Pay)); m_tPay.SetStatus(COleDateTime::null); } void DLG_C_Pay_YS::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DLG_C_Pay_YS) DDX_Text(pDX, IDD_C_PAY_YS_BZ, m_strBZ); DDV_MaxChars(pDX, m_strBZ, 30); DDX_CBString(pDX, IDD_C_PAY_YS_PAYMODE, m_strPayMode); DDV_MaxChars(pDX, m_strPayMode, 15); DDX_DateTimeCtrl(pDX, IDD_C_PAY_YS_TIME, m_tPayTime); DDX_Text(pDX, IDD_C_PAY_YS_PRICE, m_strPrice); DDV_MaxChars(pDX, m_strPrice, 10); DDX_Text(pDX, IDD_C_PAY_YS_PRICEONE, m_strPriceOne); DDV_MaxChars(pDX, m_strPriceOne, 10); DDX_Text(pDX, IDD_C_PAY_YS_SMSCOUNT, m_strSmsCount); DDV_MaxChars(pDX, m_strSmsCount, 10); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DLG_C_Pay_YS, CDialog) //{{AFX_MSG_MAP(DLG_C_Pay_YS) ON_WM_TIMER() ON_EN_CHANGE(IDD_C_PAY_YS_PRICE, OnChangeCPayYsPrice) ON_EN_CHANGE(IDD_C_PAY_YS_PRICEONE, OnChangeCPayYsPriceone) ON_EN_CHANGE(IDD_C_PAY_YS_SMSCOUNT, OnChangeCPayYsSmscount) //}}AFX_MSG_MAP ON_BN_CLICKED(IDOK, &DLG_C_Pay_YS::OnBnClickedOk) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DLG_C_Pay_YS message handlers BOOL DLG_C_Pay_YS::OnInitDialog() { CDialog::OnInitDialog(); m_strPayMode = _T("首易工行"); if ( m_tPay.GetStatus() == COleDateTime::valid ) { m_tPayTime = m_tPay; } if ( m_bMonPay ) { GetDlgItem(IDD_C_PAY_YS_S1)->ShowWindow(SW_SHOW); GetDlgItem(IDD_C_PAY_YS_S2)->ShowWindow(SW_SHOW); GetDlgItem(IDD_C_PAY_YS_S3)->ShowWindow(SW_SHOW); GetDlgItem(IDD_C_PAY_YS_PRICE)->ShowWindow(SW_SHOW); GetDlgItem(IDD_C_PAY_YS_PRICEONE)->ShowWindow(SW_SHOW); GetDlgItem(IDD_C_PAY_YS_SMSCOUNT)->ShowWindow(SW_SHOW); m_strPrice.Format( _T("%.2f") , m_Pay.fPrice ); m_strPriceOne.Format( _T("%.4f") , m_Pay.fPriceOne ); m_strSmsCount.Format( _T("%d") , m_Pay.lSMSCount ); } UpdateData(false); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DLG_C_Pay_YS::OnBnClickedOk() { if(!UpdateData(true)) return ; if ( m_bMonPay ) { double fPriceOne = _tstof(m_strPriceOne); if ( fPriceOne<=0.02f || fPriceOne>0.50f ) { MessageBox( _T("实收短信单价有误,请检查!") , _T("错误") , MB_ICONWARNING ); GetDlgItem(IDD_C_PAY_YS_PRICEONE)->SetFocus(); return ; } double fPrice = _tstof(m_strPrice); if ( fPrice!=m_Pay.fPrice ) { long iRet = MessageBox( _T("实收短信金额与帐单金额不符,是否继续?") , _T("提问") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 ); if ( iRet != IDYES ) return; } long lSmsCount = _ttol(m_strSmsCount); if ( lSmsCount!=m_Pay.lSMSCount ) { long iRet = MessageBox( _T("实收短信数量与帐单数量不符,是否继续?") , _T("提问") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 ); if ( iRet != IDYES ) return; } if ( lSmsCount0.50f ) { MessageBox( _T("实收短信单价有误,请检查!") , _T("错误") , MB_ICONWARNING ); GetDlgItem(IDD_C_PAY_YS_PRICEONE)->SetFocus(); return ; } long lSmsCount = fPrice / fPriceOne; m_strSmsCount.Format( _T("%d") , lSmsCount ); UpdateData(false); } if ( nIDEvent ==2 ) //单价改变,重新计算短信数量 { KillTimer(nIDEvent); if ( !UpdateData(true) ) return ; double fPrice = _tstof(m_strPrice); double fPriceOne = _tstof(m_strPriceOne); if ( fPriceOne<=0.02f || fPriceOne>0.50f ) { MessageBox( _T("实收短信单价有误,请检查!") , _T("错误") , MB_ICONWARNING ); GetDlgItem(IDD_C_PAY_YS_PRICEONE)->SetFocus(); return ; } long lSmsCount = fPrice / fPriceOne; m_strSmsCount.Format( _T("%d") , lSmsCount ); UpdateData(false); } if ( nIDEvent ==3 ) //短信数量改变,重新计算总价 { KillTimer(nIDEvent); if ( !UpdateData(true) ) return ; long lSmsCount = _ttol(m_strSmsCount); double fPriceOne = _tstof(m_strPriceOne); if ( fPriceOne<=0.02f || fPriceOne>0.50f ) { MessageBox( _T("实收短信单价有误,请检查!") , _T("错误") , MB_ICONWARNING ); GetDlgItem(IDD_C_PAY_YS_PRICEONE)->SetFocus(); return ; } double fPrice = (double)lSmsCount * fPriceOne; m_strPrice.Format( _T("%.2f") , fPrice ); UpdateData(false); } } void DLG_C_Pay_YS::OnChangeCPayYsPrice() { SetTimer( 1 , 50 , NULL ); } void DLG_C_Pay_YS::OnChangeCPayYsPriceone() { SetTimer( 2 , 50 , NULL ); } void DLG_C_Pay_YS::OnChangeCPayYsSmscount() { SetTimer( 3 , 50 , NULL ); } ANS_Corp_MonPayData DLG_C_Pay_YS::GetParam() { return m_Pay; } void DLG_C_Pay_YS::SetPayTime(COleDateTime payTime) { m_tPay = payTime; }