?? typedlg.cpp
字號(hào):
// 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("請(qǐng)輸入類別名稱");
return;
}
CBaseType cBT;
cBT.SetTypeName(m_TypeName);
// 判斷是否有相同的名稱
if(cBT.HaveTypeName("2"))
{
MessageBox("已經(jīng)存在此類別名稱!");
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("請(qǐng)選擇要修改的類別名稱");
return;
}
//判斷類別名稱是否為空
if (m_TypeName == "")
{
MessageBox("請(qǐng)輸入類別名稱");
return;
}
// 如果不同則查看數(shù)據(jù)庫(kù)是否已經(jīng)存在新的類別名稱
if(cTNameOld!=m_TypeName)
{
CBaseType cBT;
cBT.SetTypeName(m_TypeName);
if(cBT.HaveTypeName("2"))
MessageBox("新的類別名稱已經(jīng)存在!");
else
{
cBT.sql_Update(cTId);
m_Adodc.Refresh();
}
}
}
void CTypeDlg::OnDeltButton()
{
// TODO: Add your control notification handler code here
// 刪除類別信息
if (cTId=="")
{
MessageBox("請(qǐng)選擇要?jiǎng)h除的數(shù)據(jù)");
return;
}
if (MessageBox("是否刪除當(dāng)前記錄?","請(qǐng)確認(rèn)", 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
// 點(diǎn)擊類別信息后將類別名稱放入編輯框中
m_TypeName = m_DataList.GetText();
cTId = m_DataList.GetBoundText();
cTNameOld = m_DataList.GetText();
UpdateData(FALSE);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -