home *** CD-ROM | disk | FTP | other *** search
- // BiblioView.cpp : implementation of the CBiblioView class
- //
-
- #include "stdafx.h"
- #include "Biblio.h"
- #include "QueryDlg.h"
- #include "BibSet.h"
- #include "BibDoc.h"
- #include "BibView.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CBiblioView
-
- IMPLEMENT_DYNCREATE(CBiblioView, CDaoRecordView)
-
- BEGIN_MESSAGE_MAP(CBiblioView, CDaoRecordView)
- //{{AFX_MSG_MAP(CBiblioView)
- ON_COMMAND(ID_RECORD_QUERY, OnRecordQuery)
- ON_UPDATE_COMMAND_UI(ID_RECORD_QUERY, OnUpdateRecordQuery)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CBiblioView construction/destruction
-
- CBiblioView::CBiblioView()
- : CDaoRecordView(CBiblioView::IDD)
- {
- //{{AFX_DATA_INIT(CBiblioView)
- m_pSet = NULL;
- //}}AFX_DATA_INIT
- // TODO: add construction code here
-
- }
-
- CBiblioView::~CBiblioView()
- {
- }
-
- void CBiblioView::DoDataExchange(CDataExchange* pDX)
- {
- CDaoRecordView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBiblioView)
- DDX_FieldText(pDX, IDC_TITLE, m_pSet->m_Title, m_pSet);
- DDX_FieldText(pDX, IDC_ISBN, m_pSet->m_ISBN, m_pSet);
- DDX_FieldText(pDX, IDC_YEAR_PUBLISHED, m_pSet->m_Year_Published, m_pSet);
- DDX_FieldText(pDX, IDC_SUBJECT, m_pSet->m_Subject, m_pSet);
- DDX_FieldText(pDX, IDC_NOTES, m_pSet->m_Notes, m_pSet);
- DDX_FieldText(pDX, IDC_COMMENTS, m_pSet->m_Comments, m_pSet);
- DDX_FieldText(pDX, IDC_DESCRIPTION, m_pSet->m_Description, m_pSet);
- DDX_FieldText(pDX, IDC_PUBID, m_pSet->m_PubID, m_pSet);
- //}}AFX_DATA_MAP
- }
-
- BOOL CBiblioView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CDaoRecordView::PreCreateWindow(cs);
- }
-
- void CBiblioView::OnInitialUpdate()
- {
- m_pSet = &GetDocument()->m_biblioSet;
-
- CDaoRecordView::OnInitialUpdate();
-
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CBiblioView diagnostics
-
- #ifdef _DEBUG
- void CBiblioView::AssertValid() const
- {
- CDaoRecordView::AssertValid();
- }
-
- void CBiblioView::Dump(CDumpContext& dc) const
- {
- CDaoRecordView::Dump(dc);
- }
-
- CBiblioDoc* CBiblioView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBiblioDoc)));
- return (CBiblioDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CBiblioView database support
- CDaoRecordset* CBiblioView::OnGetRecordset()
- {
- return m_pSet;
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CBiblioView message handlers
-
- void CBiblioView::OnRecordQuery()
- {
- ASSERT(m_pSet->IsOpen());
-
- CQueryDlg dlg;
-
- dlg.m_strWhere = m_pSet->m_strFilter;
- dlg.m_pSet = m_pSet;
- if(IDOK == dlg.DoModal())
- {
- m_pSet->m_strFilter = dlg.m_strWhere;
- try
- {
- m_pSet->Requery();
-
- if (m_pSet->IsEOF())
- {
- // Recordset is empty. Set the current record to NON-NULL
- m_pSet->SetFieldNull(NULL, FALSE);
- }
- else
- {
- // Move to the first record is the recordset is NOT empty
- m_pSet->MoveFirst();
- }
- UpdateData(FALSE);
- }
- catch(CDaoException* e)
- {
- MessageBox(e->m_pErrorInfo->m_strDescription);
- e->Delete();
- }
- catch(CMemoryException* e)
- {
- MessageBox("Memory Exception Occurred");
- e->Delete();
- }
- }
- }
-
- void CBiblioView::OnUpdateRecordQuery(CCmdUI* pCmdUI)
- {
- // Allow requery is the recordset is open AND can restart
- pCmdUI->Enable(m_pSet->IsOpen() && m_pSet->CanRestart());
- }
-