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

#include "stdafx.h"
#include "Verbpo.h"
#include "DialogAlmSearch.h"
#include "afxdialogex.h"
#include "ThreadDataAlmRec.h"

// CDialogAlmSearch 对话框

IMPLEMENT_DYNAMIC(CDialogAlmSearch, CDialogEx)

CDialogAlmSearch::CDialogAlmSearch(CWnd* pParent /*=NULL*/)
	: CDialogEx(CDialogAlmSearch::IDD, pParent)
	, m_i32Hour1(0)
	, m_i32Min1(0)
	, m_i32Hour2(0)
{

}

CDialogAlmSearch::~CDialogAlmSearch()
{
}

void CDialogAlmSearch::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_SPIN_ALM_SEARCH_HOU1, m_CSpinHour1);
	DDX_Control(pDX, IDC_SPIN_ALM_SEARCH_HOU2, m_CSpinMin1);
	DDX_Control(pDX, IDC_SPIN_ALM_SEARCH_HOU3, m_CSpinHour2);
	DDX_Control(pDX, IDC_SPIN_ALM_SEARCH_HOU4, m_CSpinMin2);
	DDX_Control(pDX, IDC_EDIT_HOUR1, m_CEdit32Hour1);
	DDX_Control(pDX, IDC_EDIT_MIN1, m_CEdit32Min1);
	DDX_Control(pDX, IDC_EDIT_HOUR3, m_CEdit32Hour2);
	DDX_Control(pDX, IDC_EDIT_MIN2, m_CEdit32Min2);
	DDX_Control(pDX, IDC_COMBO_ALM_SEARCH_TYPE, m_CComboType);
	DDX_Control(pDX, IDC_DATETIMEPICKER__PAT_INFO_BIRTH, m_CDateTimeCtrlDate1);
	DDX_Control(pDX, IDC_DATETIMEPICKER__PAT_INFO_BIRTH2, m_CDateTimeCtrlDate2);
}


BOOL CDialogAlmSearch::OnInitDialog()
{
	CRect rect;
	int i = 0;
	CDialogEx::OnInitDialog();

	

	m_CSpinHour1.GetWindowRect(&rect);//获取控件的屏幕坐标
	ScreenToClient(&rect);//转换为对话框上的客户坐标
	m_CSpinHour1.SetRange(0, 23);
	m_CSpinHour1.SetBuddy(this->GetDlgItem(IDC_EDIT_HOUR1));
	m_CSpinHour1.MoveWindow(rect.left, rect.top, 40, 40);

	m_CSpinMin1.GetWindowRect(&rect);//获取控件的屏幕坐标
	ScreenToClient(&rect);//转换为对话框上的客户坐标
	m_CSpinMin1.SetRange(0, 59);
	m_CSpinMin1.SetBuddy(this->GetDlgItem(IDC_EDIT_MIN1));
	m_CSpinMin1.MoveWindow(rect.left, rect.top, 40, 40);

	m_CSpinHour2.GetWindowRect(&rect);//获取控件的屏幕坐标
	ScreenToClient(&rect);//转换为对话框上的客户坐标
	m_CSpinHour2.SetRange(0, 23);
	m_CSpinHour2.SetBuddy(this->GetDlgItem(IDC_EDIT_HOUR3));
	m_CSpinHour2.MoveWindow(rect.left, rect.top, 40, 40);

	m_CSpinMin2.GetWindowRect(&rect);//获取控件的屏幕坐标
	ScreenToClient(&rect);//转换为对话框上的客户坐标
	m_CSpinMin2.SetRange(0, 59);
	m_CSpinMin2.SetBuddy(this->GetDlgItem(IDC_EDIT_MIN2));
	m_CSpinMin2.MoveWindow(rect.left, rect.top, 40, 40);

	//搜索的报警类型
	m_CComboType.AddString(CString(_T("心电报警")));
	m_CComboType.AddString(CString(_T("呼吸报警")));
	m_CComboType.AddString(CString(_T("血氧报警")));
	m_CComboType.AddString(CString(_T("体温报警")));
	m_CComboType.AddString(CString(_T("血压报警")));
	m_CComboType.AddString(CString(_T("氧浓度报警")));
	m_CComboType.AddString(CString(_T("ST报警")));
	m_CComboType.AddString(CString(_T("ARRA报警")));
	m_CComboType.SetCurSel(0);

	return TRUE;  // 除非将焦点设置到控件，否则返回 TRUE
}


BEGIN_MESSAGE_MAP(CDialogAlmSearch, CDialogEx)
	ON_BN_CLICKED(IDOK, &CDialogAlmSearch::OnBnClickedOk)
	ON_BN_CLICKED(IDC_BUTTON_ALM_SEARCH_SELECH, &CDialogAlmSearch::OnBnClickedButtonAlmSearchSelech)
END_MESSAGE_MAP()


// CDialogAlmSearch 消息处理程序


void CDialogAlmSearch::OnBnClickedOk()
{
	// TODO:  在此添加控件通知处理程序代码
	CDialogEx::OnOK();
}


void CDialogAlmSearch::OnBnClickedButtonAlmSearchSelech()
{
	// TODO:  在此添加控件通知处理程序代码
	CString a_cs,a_cs2;
	INT i = 0,j=0;
	CTime timeTime;

	//获得 搜索时间区间 的左值
	m_CDateTimeCtrlDate1.GetTime(timeTime);
	a_cs.Format(_T("%d-%02d-%02d"), timeTime.GetYear(), timeTime.GetMonth(), timeTime.GetDay());
	m_CEdit32Hour1.GetWindowTextW(a_cs2);
	i = _ttoi(a_cs2);
	m_CEdit32Min1.GetWindowTextW(a_cs2);
	j = _ttoi(a_cs2);
	a_cs2.Format(_T(" %02d:%02d:00"), i, j);
	a_cs = a_cs + a_cs2;
	wcscpy_s(m_stALM_SEARCH_PARA.cTimeFirst, 20, a_cs);

	//获得 搜索时间区间 的右值
	m_CDateTimeCtrlDate2.GetTime(timeTime);
	a_cs.Format(_T("%d-%02d-%02d"), timeTime.GetYear(), timeTime.GetMonth(), timeTime.GetDay());
	m_CEdit32Hour2.GetWindowTextW(a_cs2);
	i = _ttoi(a_cs2);
	m_CEdit32Min2.GetWindowTextW(a_cs2);
	j = _ttoi(a_cs2);
	a_cs2.Format(_T(" %02d:%02d:59"), i, j);
	a_cs = a_cs + a_cs2;
	wcscpy_s(m_stALM_SEARCH_PARA.cTimeLast, 20, a_cs);

	//搜索 报警 的类型
	m_stALM_SEARCH_PARA.u8AlmType = m_CComboType.GetCurSel()+1;

	//搜索报警的参数 复制
	m_stALM_SEARCH_PARA.u8SearchType = GET_ALM_SELECT;
	m_CDialogAlmRec.Copy_Alm_Search(&m_stALM_SEARCH_PARA);
	m_CDialogAlmRec.DoModal();
}
