// DLG_WxWorkSetup.cpp: 实现文件
//

#include "stdafx.h"
#include "SmsManager.h"
#include "DLG_WxWorkSetup.h"
#include "afxdialogex.h"


// DLG_WxWorkSetup 对话框

IMPLEMENT_DYNAMIC(DLG_WxWorkSetup, CDialogEx)

DLG_WxWorkSetup::DLG_WxWorkSetup(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_WXWORKSETUP, pParent)
{

}

DLG_WxWorkSetup::~DLG_WxWorkSetup()
{
}

void DLG_WxWorkSetup::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);

	DDX_Text(pDX, IDC_WXWORKSETUP_USER, m_strUser);
	DDX_Text(pDX, IDC_WXWORKSETUP_SETTIME, m_strSetTime);

	DDX_Text(pDX, IDC_WXWORKSETUP_TIMER, m_lTimer);
	DDV_MinMaxUInt(pDX, m_lTimer, 1, 100);
	DDX_Text(pDX, IDC_WXWORKSETUP_AUTOEND, m_lAutoEnd);
	DDV_MinMaxUInt(pDX, m_lAutoEnd, 0, 1000);

	DDX_Check(pDX, IDC_WXWORKSETUP_CHECKUP, m_bCheckUp);
	DDX_Check(pDX, IDC_WXWORKSETUP_SEND, m_bSend);

}


BEGIN_MESSAGE_MAP(DLG_WxWorkSetup, CDialogEx)
	ON_BN_CLICKED(IDOK, &DLG_WxWorkSetup::OnBnClickedOk)
END_MESSAGE_MAP()


// DLG_WxWorkSetup 消息处理程序


void DLG_WxWorkSetup::OnBnClickedOk()
{

	if (!UpdateData(true))
		return;

	if (m_lTimer <= 0 || m_lTimer > 100)
	{
		MessageBox(_T("审核提醒间隔时间有误,请检查"), _T("提醒"), MB_ICONINFORMATION);
		GetDlgItem(IDC_WXWORKSETUP_TIMER)->SetFocus();
	}

	if (m_lAutoEnd < 0 || m_lAutoEnd > 1000)
	{
		MessageBox(_T("自动撤消时间有误,请检查"), _T("提醒"), MB_ICONINFORMATION);
		GetDlgItem(IDC_WXWORKSETUP_AUTOEND)->SetFocus();
	}
	m_Setup.bCheckUp = m_bCheckUp;
	m_Setup.bSend = m_bSend;
	m_Setup.lTimer = m_lTimer;
	m_Setup.lAutoEnd = m_lAutoEnd;

	CDialogEx::OnOK();
}


BOOL DLG_WxWorkSetup::OnInitDialog()
{
	CDialogEx::OnInitDialog();


	m_bCheckUp = m_Setup.bCheckUp;
	m_bSend = m_Setup.bSend;
	m_lTimer = m_Setup.lTimer;
	m_lAutoEnd = m_Setup.lAutoEnd;

	m_strUser = m_Setup.szUser + CString(_T(" - ")) + m_Setup.szWxName;
	m_strSetTime.Format(_T("%04d.%02d.%02d %02d:%02d"), m_Setup.tStart.wYear, m_Setup.tStart.wMonth, m_Setup.tStart.wDay, m_Setup.tStart.wHour, m_Setup.tStart.wMinute);

	if (m_lTimer <= 0 || m_lTimer > 100)
		m_lTimer = 8;

	if (m_lTimer < 0 || m_lTimer > 1000)
		m_lTimer = 500;

	UpdateData(false);



	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void DLG_WxWorkSetup::SetSetup(REQ_WxWork_Setup setup)
{
	m_Setup = setup;
}
REQ_WxWork_Setup DLG_WxWorkSetup::GetSetup()
{
	return m_Setup;
}