⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 图书出版管理系统view.cpp

📁 图书馆出版管理系统
💻 CPP
字号:
// 图书出版管理系统View.cpp : implementation of the CMyView class
//

#include "stdafx.h"
#include "图书出版管理系统.h"
#include "MyDlg1.h"
#include "MyDlg2.h"
#include "图书出版管理系统Set.h"
#include "图书出版管理系统Doc.h"
#include "图书出版管理系统View.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_BUTTONADDNEW, OnButtonaddnew)
	ON_BN_CLICKED(IDC_BUTTONDELETE, OnButtondelete)
	ON_BN_CLICKED(IDC_BUTTONPDATE, OnButtonpdate)
	ON_BN_CLICKED(IDC_BUTTONFIRST, OnButtonfirst)
	ON_BN_CLICKED(IDC_BUTTONNEXT, OnButtonnext)
	ON_BN_CLICKED(IDC_BUTTONPREV, OnButtonprev)
	ON_BN_CLICKED(IDC_BUTTONLAST, OnButtonlast)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_BUTTONEXIT, OnButtonexit)
	//}}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;
	//}}AFX_DATA_INIT
	// TODO: add construction code here
	MessageBox("欢迎使用图书出版管理系统!");
}

CMyView::~CMyView()
{
}

void CMyView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyView)
	DDX_FieldText(pDX, IDC_EDIT_BH, m_pSet->m___ID, m_pSet);
	DDX_FieldText(pDX, IDC_EDITFLH, m_pSet->m___ID2, m_pSet);
	DDX_FieldText(pDX, IDC_EDITBOOKNAME, m_pSet->m_column1, m_pSet);
	DDX_FieldText(pDX, IDC_EDITAUTHER, m_pSet->m_column6, m_pSet);
	DDX_FieldText(pDX, IDC_EDITBOOKPRICE, m_pSet->m_column5, m_pSet);
	DDX_FieldText(pDX, IDC_EDITBOOKADDRESS, m_pSet->m_column4, m_pSet);
	DDX_FieldText(pDX, IDC_EDITPUBNAME, m_pSet->m_column3, m_pSet);
	DDX_FieldText(pDX, IDC_EDITISBN, m_pSet->m_ISBN, m_pSet);
	DDX_FieldText(pDX, IDC_EDITDATE, m_pSet->m_column2, m_pSet);
	//}}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::OnButtonaddnew() 
{
	m_pSet->AddNew();
	UpdateData(true);
	if(m_pSet->CanUpdate())
		m_pSet->Update();
	UpdateData(false);
}

void CMyView::OnButtondelete() 
{
	m_pSet->Delete();
	m_pSet->MoveNext();
	if(m_pSet->IsEOF())
	{
		m_pSet->Requery();
		m_pSet->MoveLast();
	}
	if(m_pSet->IsEOF())
		m_pSet->SetFieldNull(NULL);
//	m_pSet->Requery();
	UpdateData(false);
}

void CMyView::OnButtonpdate() 
{
	m_pSet->m_strSort="图书ID";
	m_pSet->Requery();
	UpdateData(false);
	//m_pSet->CancelUpdate();
}

void CMyView::OnButtonfirst() 
{
	m_pSet->MovePrev();
	if(m_pSet->IsBOF())
	{
		MessageBox("记录已经在第一条!");
		m_pSet->MoveNext();
		UpdateData(false);
		return;
	}
	m_pSet->MoveFirst();
	UpdateData(false);
}

void CMyView::OnButtonnext() 
{
	m_pSet->MoveNext();
	if(m_pSet->IsEOF())
	{
		MessageBox("记录已经在最后一条!");
		m_pSet->MovePrev();
		UpdateData(false);
		return;
	}
	UpdateData(false);
}

void CMyView::OnButtonprev() 
{
	m_pSet->MovePrev();
	if(m_pSet->IsBOF())
	{
		MessageBox("记录已经在第一条!");
		m_pSet->MoveNext();
		UpdateData(false);
		return;
	}
	UpdateData(false);
}

void CMyView::OnButtonlast() 
{
    m_pSet->MoveNext();
	if(m_pSet->IsEOF())
	{
		MessageBox("记录已经在最后一条!");
		m_pSet->MovePrev();
		UpdateData(false);
		return;
	}
	m_pSet->MoveLast();
	UpdateData(false);
}

void CMyView::OnRadio1() 
{
	CMyDlg1 MyDlg1;
	MyDlg1.DoModal();
}

void CMyView::OnRadio2() 
{
	CMyDlg2 MyDlg2;
	MyDlg2.DoModal();
}

void CMyView::OnButtonexit() 
{
	exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -