⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 querytime.cpp

📁 CT工作站具有打印报告、病历管理、图像处理专家词库等功能
💻 CPP
字号:
// QueryTime.cpp : implementation file
// 

#include "stdafx.h"
#include "bxt.h"
#include "QueryTime.h"
#include "bxtDlg.h"
#include "Query.h"

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

/////////////////////////////////////////////////////////////////////////////
// QueryTime dialog


QueryTime::QueryTime(CWnd* pParent /*=NULL*/)
	: CDialog(QueryTime::IDD, pParent)
{
	//{{AFX_DATA_INIT(QueryTime)
	m_radio = -1;
	m_mon = 0;
	m_start = 0;
	m_end = 0;
	m_year = 0;
	//}}AFX_DATA_INIT
	m_pCfg				= ((CBxtApp *)(AfxGetApp()))->GetConfig();
}

void QueryTime::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(QueryTime)
	DDX_Control(pDX, IDC_QUERYET, m_qend);
	DDX_Control(pDX, IDC_QUERYST, m_qstart);
	DDX_Control(pDX, IDC_QUERYMON, m_qmon);
	DDX_Control(pDX, IDC_QUERYYEAR, m_qyear);
	DDX_Radio(pDX, IDC_RADIO1, m_radio);
	DDX_DateTimeCtrl(pDX, IDC_QUERYMON, m_mon);
	DDX_DateTimeCtrl(pDX, IDC_QUERYST, m_start);
	DDX_DateTimeCtrl(pDX, IDC_QUERYET, m_end);
	DDX_DateTimeCtrl(pDX, IDC_QUERYYEAR, m_year);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(QueryTime, CDialog)
	//{{AFX_MSG_MAP(QueryTime)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// QueryTime message handlers

BOOL QueryTime::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	((CButton*)GetDlgItem(IDC_RADIO4))->SetCheck(1); 
	m_qyear.SetFormat("yyy");
	m_qmon.SetFormat("yyy-MM");
	m_qstart.SetFormat("yyy-MM-dd");
	m_qend.SetFormat("yyy-MM-dd");

	m_year	= m_mon	= m_start	= m_end	= CTime::GetCurrentTime();

	m_radio	= 3;
	UpdateData(false);

	m_qyear.EnableWindow(false);
	m_qmon.EnableWindow(false);
	m_qstart.EnableWindow(false);
	m_qend.EnableWindow(false);

	m_btnQuery.SubclassDlgItem(IDC_BUTTON_QUERY, this);
	m_btnQuery.SetIcon(IDI_ICON_QUERY, 96, 32);
	m_btnQuery.SetMouseOnColor(RGB(255, 0, 255));
	m_btnQuery.SetPressColor(RGB(0, 0, 255));
	m_btnQuery.SetWindowText("");
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void QueryTime::DisAll()
{
	m_qyear.EnableWindow(false);
	m_qmon.EnableWindow(false);
	m_qstart.EnableWindow(false);
	m_qend.EnableWindow(false);
}

void QueryTime::OnRadio1() 
{
	DisAll();
}

void QueryTime::OnRadio2() 
{
	DisAll();
	m_qyear.EnableWindow(true);
}

void QueryTime::OnRadio3() 
{
	DisAll();
	m_qmon.EnableWindow(true);	
}

void QueryTime::OnRadio4() 
{
	DisAll();
	m_qstart.EnableWindow(true);
	m_qend.EnableWindow(true);
}

CString QueryTime::MakeDataSQL()
{
	UpdateData(true);
	
	CString sql,temp;
	CString thetime;
	char buf[10];

	sql = "";

	switch(m_radio)
	{
	case 0:
		break;
	case 1:
		thetime = itoa(m_year.GetYear(),buf,10);
		sql += "CHECKDATE LIKE '";
		sql += thetime;
		sql += "年%'";
		break;
	case 2:
		thetime = itoa(m_mon.GetYear(),buf,10);
		thetime += "年";
		temp = itoa(m_mon.GetMonth(),buf,10);
		if (temp.GetLength() == 1) thetime += "0";
		thetime += temp;
		sql += "CHECKDATE LIKE '";
		sql += thetime;
		sql += "月%'";
		break;
	case 3:
		thetime = itoa(m_start.GetYear(),buf,10);
		thetime += "年";
		temp = itoa(m_start.GetMonth(),buf,10);
		if (temp.GetLength() == 1) thetime += "0";
		thetime += temp;
		thetime += "月";
		temp = itoa(m_start.GetDay(),buf,10);
		if (temp.GetLength() == 1) thetime += "0";
		thetime += temp;
		thetime += "日 00时00分00秒";
		sql += "CHECKDATE>='";
		sql += thetime;
		sql += "' AND\r\n";

		thetime = itoa(m_end.GetYear(),buf,10);
		thetime += "年";
		temp = itoa(m_end.GetMonth(),buf,10);
		if (temp.GetLength() == 1) thetime += "0";
		thetime += temp;
		thetime += "月";
		temp = itoa(m_end.GetDay(),buf,10);
		if (temp.GetLength() == 1) thetime += "0";
		thetime += temp;
		thetime += "日 99时99分99秒";
		sql += "CHECKDATE<='";
		sql += thetime;
		sql += "'";
		break;
	default:
		break;
	}

	return sql;
}

void
QueryTime::OnButtonQuery() 
{
	if	(m_pCfg->iUiType == UI_TYPE_SIMPLE)
		SimpleQuery();
	else
		NormalQuery();
}

BOOL
QueryTime::SimpleQuery()
{
	return	(FALSE);
}

BOOL
QueryTime::NormalQuery()
{
	CString		sDateWhere	= ((CBxtDlg *)AfxGetMainWnd())->querytime->MakeDataSQL();
	CString		sWhere;
	CString		sOrder;
	INT			iBaseLen;

//	->	Make Order
	sOrder		= (((CBxtDlg *)AfxGetMainWnd())->queryorder)->MakeSortSQL();
	if (!sOrder.IsEmpty())		sOrder	= "ORDER BY " + sOrder;
//	<-	Make Order
	
//	->	Make Where
	sWhere		+=	"WHERE ";

	iBaseLen	= sWhere.GetLength();
	if (!sDateWhere.IsEmpty())
	{
		sWhere	+= sDateWhere;
		sWhere	+= " AND ";
	}
//	<-	Make Where

	if (sWhere.GetLength() == iBaseLen)	sWhere	= _T("");
	else								sWhere	= sWhere.Left(sWhere.GetLength() - 4);	// Get Rid Of "AND ";

	CWnd	*pWnd	= ((CBxtDlg*)AfxGetMainWnd())->query;

	pWnd->SendMessage(WX_SETORDER, 0, (LPARAM)(sOrder.GetBuffer(sOrder.GetLength())));
	pWnd->SendMessage(WX_SETWHERE, 0, (LPARAM)(sWhere.GetBuffer(sWhere.GetLength())));
	pWnd->SendMessage(WX_QUERY, (WPARAM)(TRUE), 0);

	return	(TRUE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -