courseview.cpp
来自「B/S架构的软件项目实训;包括全部详细文档合源程序」· C++ 代码 · 共 175 行
CPP
175 行
// courseView.cpp : implementation of the CCourseView class
//
#include "stdafx.h"
#include "course.h"
#include "courseSet.h"
#include "courseDoc.h"
#include "courseView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCourseView
IMPLEMENT_DYNCREATE(CCourseView, CRecordView)
BEGIN_MESSAGE_MAP(CCourseView, CRecordView)
//{{AFX_MSG_MAP(CCourseView)
ON_COMMAND(ID_RECORD_FIRST, OnRecordFirst)
ON_COMMAND(ID_RECORD_LAST, OnRecordLast)
ON_COMMAND(ID_RECORD_NEXT, OnRecordNext)
ON_COMMAND(ID_RECORD_PREV, OnRecordPrev)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCourseView construction/destruction
CCourseView::CCourseView()
: CRecordView(CCourseView::IDD)
{
//{{AFX_DATA_INIT(CCourseView)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CCourseView::~CCourseView()
{
}
void CCourseView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCourseView)
DDX_FieldText(pDX, IDC_STUDENTNO, m_pSet->m_studentNo, m_pSet);
DDX_FieldText(pDX, IDC_STUDENTNAME, m_pSet->m_stuName, m_pSet);
//}}AFX_DATA_MAP
}
BOOL CCourseView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CRecordView::PreCreateWindow(cs);
}
void CCourseView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_courseSet;
CRecordView::OnInitialUpdate();
LoadListBox();
}
/////////////////////////////////////////////////////////////////////////////
// CCourseView printing
BOOL CCourseView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCourseView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCourseView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCourseView diagnostics
#ifdef _DEBUG
void CCourseView::AssertValid() const
{
CRecordView::AssertValid();
}
void CCourseView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
CCourseDoc* CCourseView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCourseDoc)));
return (CCourseDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCourseView database support
CRecordset* CCourseView::OnGetRecordset()
{
return m_pSet;
}
/////////////////////////////////////////////////////////////////////////////
// CCourseView message handlers
//增加函数动态生成学生选课情况
void CCourseView::LoadListBox()
{
CCourseDoc * pDoc=GetDocument();
CListBox * pLB=(CListBox*) GetDlgItem(IDC_COURSE);
CElectiveCourseSet ec(&pDoc->m_database);
ec.m_strFilter="studentNo=?";
ec.m_studentNoParam=m_pSet->m_studentNo;
ec.Open(); pLB->ResetContent();
while(!ec.IsEOF())
{
pLB->AddString(ec.m_courseName);
ec.MoveNext();
}
}
void CCourseView::OnRecordFirst()
{
// TODO: Add your command handler code here
m_pSet->MoveFirst();
UpdateData(FALSE);
LoadListBox();
}
void CCourseView::OnRecordLast()
{
// TODO: Add your command handler code here
m_pSet->MoveLast();
UpdateData(FALSE);
LoadListBox();
}
void CCourseView::OnRecordNext()
{
// TODO: Add your command handler code here
m_pSet->MoveNext();
UpdateData(FALSE);
LoadListBox();
}
void CCourseView::OnRecordPrev()
{
// TODO: Add your command handler code here
m_pSet->MovePrev();
UpdateData(FALSE);
LoadListBox();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?