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

📄 typedlg.cpp

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

#include "stdafx.h"
#include "HosptialMan.h"
#include "TypeDlg.h"
#include "BaseType.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTypeDlg dialog


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


void CTypeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTypeDlg)
	DDX_Control(pDX, IDC_ADODC1, m_Adodc);
	DDX_Control(pDX, IDC_DATALIST1, m_DataList);
	DDX_Text(pDX, IDC_TYPENAME_EDIT, m_TypeName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTypeDlg, CDialog)
	//{{AFX_MSG_MAP(CTypeDlg)
	ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton)
	ON_BN_CLICKED(IDC_EDIT_BUTTON, OnEditButton)
	ON_BN_CLICKED(IDC_DELT_BUTTON, OnDeltButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTypeDlg message handlers

void CTypeDlg::OnAddButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	//判断科室名称是否为空
	if (m_TypeName == "")
	{
		MessageBox("请输入类别名称");
		return;
	}
	CBaseType cBT;
	cBT.SetTypeName(m_TypeName);
	// 判断是否有相同的名称
	if(cBT.HaveTypeName("2"))
	{
		MessageBox("已经存在此类别名称!");
		return;
	}
	cBT.SetTypeId(2);
	cBT.sql_Insert();
	m_Adodc.Refresh();
}

void CTypeDlg::OnEditButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	//判断是否选择了要修改的类别
	if (m_DataList.GetText() == "")
	{
		MessageBox("请选择要修改的类别名称");
		return;
	}
	//判断类别名称是否为空
	if (m_TypeName == "")
	{
		MessageBox("请输入类别名称");
		return;
	}
	// 如果不同则查看数据库是否已经存在新的类别名称
	if(cTNameOld!=m_TypeName)
	{
		CBaseType cBT;
		cBT.SetTypeName(m_TypeName);
		if(cBT.HaveTypeName("2"))
			MessageBox("新的类别名称已经存在!");
		else
		{
			cBT.sql_Update(cTId);
			m_Adodc.Refresh();
		}
	}
}

void CTypeDlg::OnDeltButton() 
{
	// TODO: Add your control notification handler code here
	// 删除类别信息
	if (cTId=="") 
	{
		MessageBox("请选择要删除的数据");
		return;
	}

	if (MessageBox("是否删除当前记录?","请确认", MB_YESNO) == IDYES)
	{
		CBaseType cBT;
		cBT.sql_Delete(cTId);
		m_Adodc.Refresh();
	}
}

BEGIN_EVENTSINK_MAP(CTypeDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CTypeDlg)
	ON_EVENT(CTypeDlg, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CTypeDlg::OnClickDatalist1() 
{
	// TODO: Add your control notification handler code here
	// 点击类别信息后将类别名称放入编辑框中
	m_TypeName = m_DataList.GetText();
	cTId = m_DataList.GetBoundText();
	cTNameOld = m_DataList.GetText();
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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