📄 rmsview.cpp
字号:
// RmsView.cpp : implementation of the CRmsView class
//
#include "stdafx.h"
#include "Rms.h"
#include "RmsSet.h"
#include "RmsDoc.h"
#include "RmsView.h"
#include "Dlg.h"
#include "Dlg2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRmsView
IMPLEMENT_DYNCREATE(CRmsView, CRecordView)
BEGIN_MESSAGE_MAP(CRmsView, CRecordView)
//{{AFX_MSG_MAP(CRmsView)
ON_BN_CLICKED(IDC_BUTTONADDNEW, OnButtonaddnew)
ON_BN_CLICKED(IDC_BUTTONDELETE, OnButtondelete)
ON_BN_CLICKED(IDC_BUTTONUPDATE, OnButtonupdate)
ON_BN_CLICKED(IDC_BUTTONFIRST, OnButtonfirst)
ON_BN_CLICKED(IDC_BUTTONNEXT, OnButtonnext)
ON_BN_CLICKED(IDC_BUTTONPREV, OnButtonprev)
ON_BN_CLICKED(IDC_BUTTONQUERY, OnButtonquery)
ON_BN_CLICKED(IDC_BUTTONTUIFANG, OnButtontuifang)
//}}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)
ON_WM_TIMER()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTTON1, &CRmsView::OnBnClickedButton1)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRmsView construction/destruction
CRmsView::CRmsView()
: CRecordView(CRmsView::IDD)
, brush(NULL)
{
//{{AFX_DATA_INIT(CRmsView)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CRmsView::~CRmsView()
{
}
void CRmsView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRmsView)
DDX_FieldText(pDX, IDC_EDITFANGHAO, m_pSet->m_FANGHAO, m_pSet);
// DDX_FieldText(pDX, IDC_EDITGUOJI, m_pSet->m_GUOJI, m_pSet);
// DDX_FieldText(pDX, IDC_EDITKEHUNIANLING, m_pSet->m_NIANLING, m_pSet);
DDX_FieldText(pDX, IDC_EDITKEHUXINGBIE, m_pSet->m_XINGBIE, m_pSet);
DDX_FieldText(pDX, IDC_EDITKEHUXINGMING, m_pSet->m_XINGMING, m_pSet);
DDX_FieldText(pDX, IDC_EDITZHUSUTIANSHU, m_pSet->m_YONGFANGTIANSHU, m_pSet);
DDX_FieldText(pDX, IDC_EDITLIDIANRIQI, m_pSet->m_LIDIANRIQI, m_pSet);
DDX_FieldText(pDX, IDC_EDITZHUDIANRIQI, m_pSet->m_ZHUDIANRIQI, m_pSet);
//}}AFX_DATA_MAP
}
BOOL CRmsView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CRmsView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_rmsSet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CBitmap bit;
bit.LoadBitmapA(IDC_BUTTONADDNEW);
brush = new CBrush(&bit);
this->SetTimer(100,100,NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CRmsView printing
BOOL CRmsView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CRmsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CRmsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CRmsView diagnostics
#ifdef _DEBUG
void CRmsView::AssertValid() const
{
CRecordView::AssertValid();
}
void CRmsView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CRmsDoc* CRmsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRmsDoc)));
return (CRmsDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRmsView database support
CRecordset* CRmsView::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CRmsView message handlers
void CRmsView::OnButtonaddnew()
{
// TODO: Add your control notification handler code here
//新客户命令按钮代码
m_pSet->AddNew();
UpdateData(FALSE);
}
void CRmsView::OnButtondelete()
{
// TODO: Add your control notification handler code here
//删除命令按钮代码
if(MessageBox("确定退房?","提示",MB_YESNO)==IDNO)
return;
if(m_pSet!=NULL)
{
m_pSet->Delete();
m_pSet->Requery();
UpdateData(false);
}
/* m_pSet->Delete();
m_pSet->MoveNext();
if(m_pSet->IsBOF())
m_pSet->MoveLast();
if(m_pSet->IsBOF())
m_pSet->SetFieldNull(NULL);
UpdateData(FALSE);
*/
}
void CRmsView::OnButtonupdate()
{
// TODO: Add your control notification handler code here
//确认命令按钮代码
//m_pSet->Edit();
UpdateData();
m_pSet->Update();
m_pSet->Requery();
MessageBox("订房成功");
//m_pSet->CancelUpdate();
}
void CRmsView::OnButtonfirst()
{
// TODO: Add your control notification handler code here
//第一条命令按钮代码
m_pSet->MoveFirst();
if(m_pSet->IsBOF())
{
MessageBox("纪录已经在第一条!");
m_pSet->MoveNext();
UpdateData(FALSE);
return;
}
UpdateData(FALSE);
}
void CRmsView::OnButtonnext()
{
// TODO: Add your control notification handler code here
//下一条命令按钮代码
m_pSet->MoveNext();
if(m_pSet->IsEOF())
{
MessageBox("纪录已经在最后一条!");
m_pSet->MovePrev();
UpdateData(FALSE);
return;
}
UpdateData(FALSE);
}
void CRmsView::OnButtonprev()
{
// TODO: Add your control notification handler code here
//上一条命令按钮代码
m_pSet->MovePrev();
if(m_pSet->IsBOF())
{
MessageBox("纪录已经在第一条!");
m_pSet->MoveNext();
UpdateData(FALSE);
return;
}
UpdateData(FALSE);
}
void CRmsView::OnButtonquery()
{
// TODO: Add your control notification handler code here
//查询命令按钮代码
Cdlg dlg1;
// dlg1.DoModal();
CString value;
if(dlg1.DoModal()==IDOK)
{
//value="客户姓名=+"+dlg1.m_query+" ";
value.Format("姓名 = '%s'",dlg1.m_query);
m_pSet->m_strFilter=value;
m_pSet->Requery();
if(m_pSet->IsEOF())
{
MessageBox("无此人");
}
UpdateData(FALSE);
m_pSet->m_strFilter="";
m_pSet->Requery();
}
}
void CRmsView::OnButtontuifang()
{
// TODO: Add your control notification handler code here
//退房命令按钮代码
Cdlg2 dlg2;
dlg2.DoModal();
}
void CRmsView::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CClientDC dc(this);
static int x=10;
CRect r;
this->GetWindowRect(&r);
x+=1;
if(x>r.Width())
x=0;
CRect irect(x-1,0,x+119,35);
this->InvalidateRect(&irect);
this->UpdateWindow();
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(255,255,0));
dc.TextOutA(x,0,"客房管理系统");
this->FlashWindow(false);
CRecordView::OnTimer(nIDEvent);
}
HBRUSH CRmsView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// HBRUSH hbr = CRecordView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何属性
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
// return hbr;
return (HBRUSH)(*brush);
}
void CRmsView::OnBnClickedButton1()
{
this->m_pSet->m_strFilter="";
this->m_pSet->Requery();
UpdateData(FALSE);
// TODO: 在此添加控件通知处理程序代码
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -