?? 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 + -