📄 unitdlg.cpp
字号:
// UnitDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HosptialMan.h"
#include "UnitDlg.h"
#include "BaseType.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUnitDlg dialog
CUnitDlg::CUnitDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUnitDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnitDlg)
m_UnitName = _T("");
//}}AFX_DATA_INIT
}
void CUnitDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnitDlg)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATALIST1, m_DataList);
DDX_Text(pDX, IDC_UNITNAME_EDIT, m_UnitName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnitDlg, CDialog)
//{{AFX_MSG_MAP(CUnitDlg)
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()
/////////////////////////////////////////////////////////////////////////////
// CUnitDlg message handlers
void CUnitDlg::OnAddButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//判断计量单位名称是否为空
if (m_UnitName == "")
{
MessageBox("请输入计量单位名称");
return;
}
CBaseType cBT;
cBT.SetTypeName(m_UnitName);
// 判断是否有相同的名称
if(cBT.HaveTypeName("3"))
{
MessageBox("已经存在此计量单位名称!");
return;
}
cBT.SetTypeId(3);
cBT.sql_Insert();
m_Adodc.Refresh();
}
void CUnitDlg::OnEditButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//判断是否选择了要修改的类别
if (m_DataList.GetText() == "")
{
MessageBox("请选择要修改的计量单位名称");
return;
}
//判断类别名称是否为空
if (m_UnitName == "")
{
MessageBox("请输入计量单位名称");
return;
} // 如果不同则查看数据库是否已经存在新的计量单位名称
if(cUNameOld!=m_UnitName)
{
CBaseType cBT;
cBT.SetTypeName(m_UnitName);
if(cBT.HaveTypeName("3"))
MessageBox("新的计量单位名称已经存在!");
else
{
cBT.sql_Update(cUId);
m_Adodc.Refresh();
}
}
}
void CUnitDlg::OnDeltButton()
{
// TODO: Add your control notification handler code here
// 删除计量单位信息
if (cUId=="")
{
MessageBox("请选择要删除的数据");
return;
}
if (MessageBox("是否删除当前记录?","请确认", MB_YESNO) == IDYES)
{
CBaseType cBT;
cBT.sql_Delete(cUId);
m_Adodc.Refresh();
}
}
BEGIN_EVENTSINK_MAP(CUnitDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CUnitDlg)
ON_EVENT(CUnitDlg, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CUnitDlg::OnClickDatalist1()
{
// TODO: Add your control notification handler code here
// 点击计量单位信息后将计量单位名称放入编辑框中
m_UnitName = m_DataList.GetText();
cUId = m_DataList.GetBoundText();
cUNameOld = m_DataList.GetText();
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -