📄 药品信息管理系统view.cpp
字号:
// 药品信息管理系统View.cpp : implementation of the CMyView class
//
#include "stdafx.h"
#include "药品信息管理系统.h"
#include "deleteornot.h"
#include "药品信息管理系统Set.h"
#include "药品信息管理系统Doc.h"
#include "药品信息管理系统View.h"
#include "Kucun.h"
#include "ChangeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyView
IMPLEMENT_DYNCREATE(CMyView, CRecordView)
BEGIN_MESSAGE_MAP(CMyView, CRecordView)
//{{AFX_MSG_MAP(CMyView)
ON_BN_CLICKED(IDC_tuichu, Ontuichu)
ON_BN_CLICKED(IDC_queding, Onchaxun)
ON_BN_CLICKED(IDC_REC_DEL, OnRecDel)
ON_BN_CLICKED(IDC_REC_ADD, OnRecAdd)
ON_BN_CLICKED(IDC_REC_EDIT, OnRecEdit)
ON_BN_CLICKED(IDC_BUTTON_KUCUN, OnButtonKucun)
ON_WM_TIMER()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction
CMyView::CMyView()
: CRecordView(CMyView::IDD)
{
//{{AFX_DATA_INIT(CMyView)
m_pSet = NULL;
// m_bAddmode=FALSE;
m_chaxun = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CMyView::~CMyView()
{
}
void CMyView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyView)
DDX_FieldText(pDX, IDC_EDIT1yaopinming, m_pSet->m_yaopinming, m_pSet);
DDX_FieldText(pDX, IDC_EDIT2xingzhuang, m_pSet->m_xingzhuang, m_pSet);
DDX_FieldText(pDX, IDC_EDIT3guige, m_pSet->m_guige, m_pSet);
DDX_FieldText(pDX, IDC_EDIT4youxiaoqi, m_pSet->m_youxiaoqi, m_pSet);
DDX_FieldText(pDX, IDC_EDIT5shiyingzheng, m_pSet->m_shiyingzheng, m_pSet);
DDX_FieldText(pDX, IDC_EDIT6yongfayongiang, m_pSet->m_yongfayongliang, m_pSet);
DDX_FieldText(pDX, IDC_EDIT7jinji, m_pSet->m_jinji, m_pSet);
DDX_Text(pDX, IDC_chaxun, m_chaxun);
//}}AFX_DATA_MAP
}
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CMyView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_mySet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CMyView printing
BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics
#ifdef _DEBUG
void CMyView::AssertValid() const
{
CRecordView::AssertValid();
}
void CMyView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyView database support
CRecordset* CMyView::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
void CMyView::Ontuichu()
{
exit(0);
// TODO: Add your control notification handler code here
}
void CMyView::Onchaxun()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_chaxun.IsEmpty())
{
MessageBox("要查询的药品名不能为空!");
return;
}
if(m_pSet->IsOpen())
m_pSet->Close(); //如果纪录集打开,则先关闭
m_pSet->m_strFilter.Format("yaopinming='%s'",m_chaxun);
m_pSet->m_strSort="yongfayongliang";
m_pSet->Open();
if(!m_pSet->IsEOF())
UpdateData(FALSE);
else
MessageBox("没有查到你要找的药品纪录!");
}
void CMyView::OnRecDel()
{
Cdeleteornot aaa;
if(aaa.DoModal()==IDOK)
{
CRecordsetStatus status;
m_pSet->GetStatus(status); //获取当前纪录集状态
m_pSet->Delete(); //删除当前纪录
if(status.m_lCurrentRecord==0) //当前纪录索引号,0表示第一条纪录
m_pSet->MoveNext(); //下移一条纪录
m_pSet->MoveFirst(); //移动到第一个记录处
UpdateData(FALSE);
}
else
m_pSet->Requery();
return;
// TODO: Add your control notification handler code here
}
void CMyView::OnRecAdd()
{
// TODO: Add your control notification handler code here
CChangeDlg dlg;
CMySet *cSet=new CMySet;
if(cSet->IsOpen())
cSet->Close();
cSet->Open();
if(dlg.DoModal()==IDOK)
{
TRY
{
cSet->AddNew();
cSet->m_bianhao =dlg.m_bh;
cSet->m_guige =dlg.m_gg;
cSet->m_jinji =dlg.m_jj;
cSet->m_shiyingzheng =dlg.m_shyzh;
cSet->m_xingzhuang =dlg.m_xzh;
cSet->m_yaopinming =dlg.m_ypm;
cSet->m_yongfayongliang =dlg.m_yfyl;
cSet->m_youxiaoqi =dlg.m_yxq;
cSet->Update();
cSet->Requery();
}
CATCH(CDBException,pe)
{
if(m_pSet->m_bianhao==dlg.m_bh)
throw "编号已存在!请输入新的编号";//判断编号是否已存在
MessageBox("编号已存在!请输入新的编号!");
dlg.DoModal();
}
END_CATCH
}
cSet->Close();
}
void CMyView::OnRecEdit()
{
// TODO: Add your control notification handler code here
CChangeDlg dlg;
dlg.m_bh =m_pSet->m_bianhao;
dlg.m_gg =m_pSet->m_guige;
dlg.m_jj =m_pSet->m_jinji;
dlg.m_shyzh =m_pSet->m_shiyingzheng;
dlg.m_xzh =m_pSet->m_xingzhuang;
dlg.m_ypm =m_pSet->m_yaopinming;
dlg.m_yfyl =m_pSet->m_yongfayongliang;
dlg.m_yxq =m_pSet->m_youxiaoqi;
if(dlg.DoModal()==IDOK)
{
m_pSet->Edit();
m_pSet->m_bianhao =dlg.m_bh;
m_pSet->m_guige =dlg.m_gg;
m_pSet->m_jinji =dlg.m_jj;
m_pSet->m_shiyingzheng =dlg.m_shyzh;
m_pSet->m_xingzhuang =dlg.m_xzh;
m_pSet->m_yaopinming =dlg.m_ypm;
m_pSet->m_yongfayongliang =dlg.m_yfyl;
m_pSet->m_youxiaoqi =dlg.m_yxq;
m_pSet->Update();
UpdateData(false);
}
}
void CMyView::OnButtonKucun()
{
// TODO: Add your control notification handler code here
UpdateData();
CKucun dlg;
if(dlg.DoModal()==IDOK)
return ;
CMySet *cSet=new CMySet;
if(m_pSet->IsOpen())
m_pSet->Close(); //如果纪录集打开,则先关闭
m_pSet->m_strFilter.Format("yaopinming='%s'",m_chaxun);
m_pSet->m_strSort="yongfayongliang";
m_pSet->Open();
}
void CMyView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CRecordView::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -