SmsManager/DLG_Corp_PayToUser.cpp
2025-01-14 10:46:18 +08:00

158 lines
3.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// DLG_Corp_PayToUser.cpp : implementation file
//
#include "stdafx.h"
#include "smsmanager.h"
#include "DLG_Corp_PayToUser.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DLG_Corp_PayToUser dialog
DLG_Corp_PayToUser::DLG_Corp_PayToUser(CWnd* pParent /*=NULL*/)
: CDialog(DLG_Corp_PayToUser::IDD, pParent)
{
//{{AFX_DATA_INIT(DLG_Corp_PayToUser)
m_strType = _T("");
m_strBZ = _T("");
m_strName = _T("");
m_strPrice = _T("");
m_strPriceOne = _T("");
m_strSmsCount = _T("");
m_strTHCount = _T("");
//}}AFX_DATA_INIT
memset(&m_HSSms,0,sizeof(m_HSSms));
}
void DLG_Corp_PayToUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DLG_Corp_PayToUser)
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE, m_strType);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_BZ, m_strBZ);
DDV_MaxChars(pDX, m_strBZ, 250);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_NAME, m_strName);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_PRICE, m_strPrice);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_PRICEONE, m_strPriceOne);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_SMSCOUNT, m_strSmsCount);
DDX_Text(pDX, IDC_CORP_PAYTOUSER_TYPE_THCOUNT, m_strTHCount);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DLG_Corp_PayToUser, CDialog)
//{{AFX_MSG_MAP(DLG_Corp_PayToUser)
ON_WM_TIMER()
ON_EN_CHANGE(IDC_CORP_PAYTOUSER_TYPE_THCOUNT, OnChangeCorpPaytouserTypeThcount)
ON_EN_CHANGE(IDC_CORP_PAYTOUSER_TYPE_PRICEONE, OnChangeCorpPaytouserTypePriceone)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLG_Corp_PayToUser message handlers
BOOL DLG_Corp_PayToUser::OnInitDialog()
{
CDialog::OnInitDialog();
m_strType = _T("Öն˿ͻ§");
if ( m_HSSms.lUserType == 1 )
{
m_strType = _T("´úÀíÉÌ") ;
}
if ( m_HSSms.lUserType == 10 )
{
m_strType = _T("ADC¿Í»§");
}
m_strName = m_HSSms.szCorpName;
m_strSmsCount.Format(_T("%d") , m_HSSms.lSmsCount );
m_strTHCount.Format( _T("%d") , m_HSSms.lSmsCount );
m_strPriceOne.Format( _T("%.4f") , m_HSSms.fPriceOne );
UpdateData(false);
SetTimer(1,100,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DLG_Corp_PayToUser::SetParam(REQ_Corp_HSSms HSSms)
{
m_HSSms = HSSms;
}
void DLG_Corp_PayToUser::OnTimer(UINT nIDEvent)
{
CDialog::OnTimer(nIDEvent);
if ( nIDEvent == 1 )
{
KillTimer(nIDEvent);
ResetSMSUsed();
}
}
void DLG_Corp_PayToUser::ResetSMSUsed()
{
UpdateData( true );
m_HSSms.lSmsUsed = _ttol( m_strTHCount );
m_HSSms.fPriceOne = _tstof( m_strPriceOne );
if ( m_HSSms.fPriceOne < 0.02f || m_HSSms.fPriceOne > 0.20f )
{
MessageBox( _T("Í˿¼ÛÓÐÎó£¬Çë¼ì²é£¡") , _T("´íÎó") , MB_ICONWARNING) ;
return ;
}
if ( m_HSSms.lSmsUsed <=0 || m_HSSms.lSmsUsed > m_HSSms.lSmsCount )
{
MessageBox( _T("ÍË¿îÊýÁ¿²»ÔÊÐí´óÓÚÊ£Óà¶ÌÐÅÁ¿Óë²»ÄÜСÓÚ0£¡") , _T("´íÎó") , MB_ICONWARNING) ;
m_strTHCount = m_strSmsCount;
UpdateData(false);
return ;
}
m_strPrice.Format( _T("%.4f") , (double)m_HSSms.lSmsUsed * m_HSSms.fPriceOne );
this->UpdateData( false );
}
void DLG_Corp_PayToUser::OnOK()
{
ResetSMSUsed();
if ( m_HSSms.fPriceOne < 0.02f || m_HSSms.fPriceOne > 0.20f )
return ;
if ( m_HSSms.lSmsUsed > m_HSSms.lSmsCount )
return ;
int iRet = MessageBox( _T("È·ÈÏÒªÍË¿î´Ë±Ê¿îÏ") , _T("ÌáÎÊ") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 );
if ( iRet != IDYES )
return ;
_tcscpy(m_HSSms.szBZ , m_strBZ );
CDialog::OnOK();
}
void DLG_Corp_PayToUser::OnChangeCorpPaytouserTypeThcount()
{
SetTimer(1 , 100 , NULL );
}
void DLG_Corp_PayToUser::OnChangeCorpPaytouserTypePriceone()
{
SetTimer(1 , 100 , NULL );
}