// DLG_Other_Add.cpp : implementation file
//

#include "stdafx.h"
#include "smsmanager.h"
#include "DLG_Other_Add.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// DLG_Other_Add dialog


DLG_Other_Add::DLG_Other_Add(CWnd* pParent /*=NULL*/)
	: CDialog(DLG_Other_Add::IDD, pParent)
	, m_bTDError(FALSE)
{
	//{{AFX_DATA_INIT(DLG_Other_Add)
	m_strMobile = _T("");
	m_strName = _T("");
	m_lEnable = -1;
	m_bCheckUp = FALSE;
	m_bCJ = FALSE;
	m_bCM = FALSE;
	m_bFuncChange = FALSE;
	m_bFuncSub = FALSE;
	m_bLL = FALSE;
	m_bYJ = FALSE;
	m_bManager = FALSE;
	m_strEmail = _T("");
	//}}AFX_DATA_INIT
	m_dwType = 0;
}


void DLG_Other_Add::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(DLG_Other_Add)
	DDX_Text(pDX, IDC_OHTER_ADD_MOBILE, m_strMobile);
	DDV_MaxChars(pDX, m_strMobile, 24);
	DDX_Text(pDX, IDC_OHTER_ADD_NAME, m_strName);
	DDV_MaxChars(pDX, m_strName, 24);
	DDX_CBIndex(pDX, IDC_OHTER_ADD_ENABLE, m_lEnable);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_CHECKUP, m_bCheckUp);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_CJ, m_bCJ);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_CM, m_bCM);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_FUNCCHANGE, m_bFuncChange);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_FUNCSUB, m_bFuncSub);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_LL, m_bLL);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_YJ, m_bYJ);
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_MANAGER, m_bManager);
	DDX_Text(pDX, IDC_OHTER_ADD_EMAIL, m_strEmail);
	DDV_MaxChars(pDX, m_strEmail, 60);
	DDX_Text(pDX, IDC_OHTER_ADD_WXWORK, m_strWxWork);
	DDV_MaxChars(pDX, m_strWxWork, 30);
	DDX_Check(pDX, IDC_OHTER_ADD_BSMS, m_bSms);
	DDX_Check(pDX, IDC_OHTER_ADD_BWXWORK, m_bWxWork);
	//}}AFX_DATA_MAP
	DDX_Check(pDX, IDC_OHTER_ADD_TYPE_TDERROR, m_bTDError);
}


BEGIN_MESSAGE_MAP(DLG_Other_Add, CDialog)
	//{{AFX_MSG_MAP(DLG_Other_Add)
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDOK, &DLG_Other_Add::OnBnClickedOk)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLG_Other_Add message handlers

BOOL DLG_Other_Add::OnInitDialog() 
{
	CDialog::OnInitDialog();
	

	if ( m_dwType & REPORT_CHECKUP )
		m_bCheckUp = true;
	if ( m_dwType & REPORT_CJ )
		m_bCJ = true;
	if ( m_dwType & REPORT_CM )
		m_bCM = true;
	if ( m_dwType & REPORT_FUNCCHANGE )
		m_bFuncChange = true;
	if ( m_dwType & REPORT_FUNCSUB )
		m_bFuncSub = true;
	if ( m_dwType & REPORT_LL )
		m_bLL = true;
	if ( m_dwType & REPORT_YJ )
		m_bYJ = true;
	if ( m_dwType & REPORT_MANAGER )
		m_bManager = true;
	if (m_dwType & REPORT_TDERROR)
		m_bTDError = true;

	
	UpdateData(false);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void DLG_Other_Add::SetParam(CString strName, CString strMobile,CString strEmail,CString strWxWork,long lEnable,BOOL bSms,BOOL bWxWork,DWORD dwType)
{
	m_strName = strName;
	m_strMobile = strMobile;
	m_strEmail  = strEmail;
	m_strWxWork = strWxWork;
	m_lEnable   = lEnable;
	m_bSms = bSms;
	m_bWxWork = bWxWork;
	m_dwType     = dwType;
}


void DLG_Other_Add::OnBnClickedOk()
{
	if (!UpdateData(true))
		return;

	if (m_strName.GetLength() <= 0)
	{
		MessageBox(_T("����Ա��������Ϊ�գ������룡"), _T("����"), MB_ICONWARNING);
		return;
	}
	if (m_strMobile.GetLength() <= 0)
	{
		MessageBox(_T("����Ա�ֻ����벻��Ϊ�գ������룡"), _T("����"), MB_ICONWARNING);
		return;
	}

	m_dwType = 0;
	if (m_bCheckUp) m_dwType |= REPORT_CHECKUP;
	if (m_bCJ) m_dwType |= REPORT_CJ;
	if (m_bCM) m_dwType |= REPORT_CM;
	if (m_bFuncChange) m_dwType |= REPORT_FUNCCHANGE;
	if (m_bFuncSub) m_dwType |= REPORT_FUNCSUB;
	if (m_bLL) m_dwType |= REPORT_LL;
	if (m_bYJ) m_dwType |= REPORT_YJ;
	if (m_bManager) m_dwType |= REPORT_MANAGER;
	if (m_bTDError) m_dwType |= REPORT_TDERROR;

	CDialog::OnOK();

}