CorpSms/DLG_MasSetup.cpp
2025-02-27 16:58:16 +08:00

173 lines
4.3 KiB
C++

// DLG_MasSetup.cpp : implementation file
//
#include "stdafx.h"
#include "corpsms.h"
#include "DLG_MasSetup.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DLG_MasSetup dialog
DLG_MasSetup::DLG_MasSetup(CWnd* pParent /*=NULL*/)
: CDialog(DLG_MasSetup::IDD, pParent)
{
//{{AFX_DATA_INIT(DLG_MasSetup)
m_strCode = _T("");
m_strCount = _T("");
m_strDBName = _T("");
m_bEnable = FALSE;
m_strIP = _T("");
m_strPasswd = _T("");
m_lProv = -1;
m_strUser = _T("");
m_lMaxLen = 0;
m_bCM = FALSE;
m_lMaxSend = 0;
m_bWW = FALSE;
//}}AFX_DATA_INIT
memset(&m_Setup,0,sizeof(m_Setup));
}
void DLG_MasSetup::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DLG_MasSetup)
DDX_Text(pDX, IDC_MASSETUP_CODE, m_strCode);
DDV_MaxChars(pDX, m_strCode, 7);
DDX_Text(pDX, IDC_MASSETUP_COUNT, m_strCount);
DDX_Text(pDX, IDC_MASSETUP_DBNAME, m_strDBName);
DDV_MaxChars(pDX, m_strDBName, 7);
DDX_Check(pDX, IDC_MASSETUP_ENABLE, m_bEnable);
DDX_Text(pDX, IDC_MASSETUP_IP, m_strIP);
DDV_MaxChars(pDX, m_strIP, 22);
DDX_Text(pDX, IDC_MASSETUP_PASSWD, m_strPasswd);
DDV_MaxChars(pDX, m_strPasswd, 7);
DDX_CBIndex(pDX, IDC_MASSETUP_PROV, m_lProv);
DDX_Text(pDX, IDC_MASSETUP_USER, m_strUser);
DDV_MaxChars(pDX, m_strUser, 7);
DDX_Text(pDX, IDC_MASSETUP_MAXLEN, m_lMaxLen);
DDX_Check(pDX, IDC_MASSETUP_CM, m_bCM);
DDX_Text(pDX, IDC_MASSETUP_MAXSEND, m_lMaxSend);
DDV_MinMaxLong(pDX, m_lMaxSend, 0, 9999999);
DDX_Check(pDX, IDC_MASSETUP_WW, m_bWW);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DLG_MasSetup, CDialog)
//{{AFX_MSG_MAP(DLG_MasSetup)
ON_BN_CLICKED(IDC_MASSETUP_RESET, OnMassetupReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLG_MasSetup message handlers
BOOL DLG_MasSetup::OnInitDialog()
{
CDialog::OnInitDialog();
m_bEnable = m_Setup.Mas_Enable; //ÊÇ·ñÆôÓÃ
m_lProv = m_Setup.Mas_Prov; //ÆôÓÃÊ¡·Ý
m_strCount.Format( _T("%d") , m_Setup.Mas_Count );
m_strIP = m_Setup.Mas_IP;
m_strCode = m_Setup.Mas_Code;
m_strUser = m_Setup.Mas_User;
m_strPasswd = m_Setup.Mas_Passwd;
m_strDBName = m_Setup.Mas_DBName;
m_lMaxLen = m_Setup.Mas_MaxLen;
m_bCM = m_Setup.Mas_CM;
m_lMaxSend = m_Setup.Mas_MaxSend;
m_bWW = m_Setup.Mas_WW;
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void DLG_MasSetup::SetParam(SM_Setup setup)
{
m_Setup = setup;
}
SM_Setup DLG_MasSetup::GetParam()
{
return m_Setup;
}
void DLG_MasSetup::OnOK()
{
if ( !UpdateData(true ) )
return ;
if (m_strIP.GetLength()<=0 )
{
MessageBox( _T("±ØÐëÌîÈëIPµØÖ·£¡") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_IP)->SetFocus();
return ;
}
if (m_strCode.GetLength()<=0 )
{
MessageBox( _T("±ØÐëÌîÈëAPI±àÂ룡") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_CODE)->SetFocus();
return ;
}
if (m_strUser.GetLength()<=0 )
{
MessageBox( _T("±ØÐëÌîÈëÓû§Ãû£¡") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_USER)->SetFocus();
return ;
}
if (m_strPasswd.GetLength()<=0 )
{
MessageBox( _T("±ØÐëÌîÈëÃÜÂ룡") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_PASSWD)->SetFocus();
return ;
}
if (m_strDBName.GetLength()<=0 )
{
MessageBox( _T("±ØÐëÌîÈëÊý¾Ý¿âÃû³Æ£¡") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_DBNAME)->SetFocus();
return ;
}
if (m_lMaxLen<30 || m_lMaxLen>70 )
{
MessageBox( _T("×î´ó×ÖÊýÊäÈëÓÐÎó£¬Çë¼ì²é!") , _T("´íÎó") , MB_ICONWARNING );
GetDlgItem(IDC_MASSETUP_MAXLEN)->SetFocus();
return ;
}
m_Setup.Mas_Enable = m_bEnable; //ÊÇ·ñÆôÓÃ
m_Setup.Mas_Prov = m_lProv; //ÆôÓÃÊ¡·Ý
_tcscpy(m_Setup.Mas_IP,m_strIP);
_tcscpy(m_Setup.Mas_Code,m_strCode);
_tcscpy(m_Setup.Mas_User,m_strUser);
_tcscpy(m_Setup.Mas_Passwd,m_strPasswd);
_tcscpy(m_Setup.Mas_DBName,m_strDBName);
m_Setup.Mas_MaxLen = m_lMaxLen;
m_Setup.Mas_CM = m_bCM;
m_Setup.Mas_MaxSend= m_lMaxSend;
m_Setup.Mas_WW = m_bWW;
CDialog::OnOK();
}
void DLG_MasSetup::OnMassetupReset()
{
UpdateData(true);
m_Setup.Mas_Count = 0;
m_strCount.Format( _T("%d") , m_Setup.Mas_Count );
UpdateData(false);
}