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

📄 patientselectiondlg.cpp

📁 医院管理系统在CV++条件下的完整性开发>>>
💻 CPP
字号:
// PatientSelectionDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HosptialMan.h"
#include "PatientSelectionDlg.h"
#include "columns.h"
#include "column.h"
#include "COMDEF.H"
#include "_recordset.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPatientSelectionDlg dialog


CPatientSelectionDlg::CPatientSelectionDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPatientSelectionDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPatientSelectionDlg)
	m_PName = _T("");
	//}}AFX_DATA_INIT
}


void CPatientSelectionDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPatientSelectionDlg)
	DDX_Control(pDX, IDC_ADODC1, m_Adodc);
	DDX_Control(pDX, IDC_PATIENTS_DATAGRID, m_DataGrid);
	DDX_Text(pDX, IDC_PATIENTNAME_EDIT, m_PName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPatientSelectionDlg, CDialog)
	//{{AFX_MSG_MAP(CPatientSelectionDlg)
	ON_BN_CLICKED(IDC_SEARCH_BUTTON, OnSearchButton)
	ON_BN_CLICKED(IDC_SEL_BUTTON, OnSelButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPatientSelectionDlg message handlers

void CPatientSelectionDlg::OnSearchButton() 
{
	// TODO: Add your control notification handler code here
	RefreshData();
}

void CPatientSelectionDlg::RefreshData()
{
	UpdateData(TRUE);
	CString cSql;
	cSql = "Select Id,Name AS 姓名,IdNum AS 身份证号,Sex AS 性别,Age AS 年龄,";
	cSql += "Marry AS 婚姻状况 From Patient";
	if(m_PName!="")
		cSql += " Where Name Like '%"+m_PName+"%'";
	m_Adodc.SetRecordSource(cSql);
	m_Adodc.Refresh();
	// 设置列宽度
	_variant_t vIndex;
	vIndex = long(0);
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(0);
	vIndex = long(1);  // 姓名
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
	vIndex = long(2);  // 身份证号
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);
	vIndex = long(3);  // 性别
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
	vIndex = long(4);  // 年龄
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
	vIndex = long(5);  // 婚姻状况
	m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);
}

BOOL CPatientSelectionDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	RefreshData();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BEGIN_EVENTSINK_MAP(CPatientSelectionDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CPatientSelectionDlg)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CPatientSelectionDlg::OnSelButton() 
{
	if(m_Adodc.GetRecordset().GetEof())
	{
		MessageBox("请选择记录!");
		return;
	}
	// 将数据返回
	PatientId = m_DataGrid.GetItem(0);			//编号
	PatientName = m_DataGrid.GetItem(1);		//患者姓名
	PatientIDNum = m_DataGrid.GetItem(2);		//身份证号
	PatientSex = m_DataGrid.GetItem(3);			//性别
	PatientAge = m_DataGrid.GetItem(4);			//年龄
	PatientMarry = m_DataGrid.GetItem(5);		//婚姻状态
	OnOK();	
}

⌨️ 快捷键说明

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