OLEDBDepartmentMFCView.cpp
上传用户:benben_wyd
上传日期:2010-02-26
资源大小:1229k
文件大小:3k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // OLEDBDepartmentMFCView.cpp : implementation of the COLEDBDepartmentMFCView class
  2. //
  3. #include "stdafx.h"
  4. #include "OLEDBDepartmentMFC.h"
  5. #include "OLEDBDepartmentMFCSet.h"
  6. #include "OLEDBDepartmentMFCDoc.h"
  7. #include "OLEDBDepartmentMFCView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // COLEDBDepartmentMFCView
  15. IMPLEMENT_DYNCREATE(COLEDBDepartmentMFCView, COleDBRecordView)
  16. BEGIN_MESSAGE_MAP(COLEDBDepartmentMFCView, COleDBRecordView)
  17. //{{AFX_MSG_MAP(COLEDBDepartmentMFCView)
  18. // NOTE - the ClassWizard will add and remove mapping macros here.
  19. //    DO NOT EDIT what you see in these blocks of generated code!
  20. //}}AFX_MSG_MAP
  21. END_MESSAGE_MAP()
  22. /////////////////////////////////////////////////////////////////////////////
  23. // COLEDBDepartmentMFCView construction/destruction
  24. COLEDBDepartmentMFCView::COLEDBDepartmentMFCView()
  25. : COleDBRecordView(COLEDBDepartmentMFCView::IDD)
  26. {
  27. //{{AFX_DATA_INIT(COLEDBDepartmentMFCView)
  28. // NOTE: the ClassWizard will add member initialization here
  29. m_pSet = NULL;
  30. //}}AFX_DATA_INIT
  31. // TODO: add construction code here
  32. }
  33. COLEDBDepartmentMFCView::~COLEDBDepartmentMFCView()
  34. {
  35. }
  36. void COLEDBDepartmentMFCView::DoDataExchange(CDataExchange* pDX)
  37. {
  38. COleDBRecordView::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(COLEDBDepartmentMFCView)
  40. // NOTE: the ClassWizard will add DDX and DDV calls here
  41. //}}AFX_DATA_MAP
  42. DDX_Text(pDX, IDC_DEPARTMENTCODE, m_pSet->m_DepartmentCode, 5);
  43. DDV_MaxChars(pDX, m_pSet->m_DepartmentCode, 4);
  44. DDX_Text(pDX, IDC_DEPARTMENTNAME, m_pSet->m_DepartmentName, 51);
  45. DDV_MaxChars(pDX, m_pSet->m_DepartmentName, 51);
  46. }
  47. BOOL COLEDBDepartmentMFCView::PreCreateWindow(CREATESTRUCT& cs)
  48. {
  49. // TODO: Modify the Window class or styles here by modifying
  50. //  the CREATESTRUCT cs
  51. return COleDBRecordView::PreCreateWindow(cs);
  52. }
  53. void COLEDBDepartmentMFCView::OnInitialUpdate()
  54. {
  55. m_pSet = &GetDocument()->m_oLEDBDepartmentMFCSet;
  56. {
  57. CWaitCursor wait;
  58. HRESULT hr = m_pSet->Open();
  59. if (hr != S_OK)
  60. {
  61. AfxMessageBox(_T("Record set failed to open."), MB_OK);
  62. // Disable the Next and Previous record commands,
  63. // since attempting to change the current record without an
  64. // open RecordSet will cause a crash.
  65. m_bOnFirstRecord = TRUE;
  66. m_bOnLastRecord = TRUE;
  67. }
  68. }
  69. COleDBRecordView::OnInitialUpdate();
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // COLEDBDepartmentMFCView diagnostics
  73. #ifdef _DEBUG
  74. void COLEDBDepartmentMFCView::AssertValid() const
  75. {
  76. COleDBRecordView::AssertValid();
  77. }
  78. void COLEDBDepartmentMFCView::Dump(CDumpContext& dc) const
  79. {
  80. COleDBRecordView::Dump(dc);
  81. }
  82. COLEDBDepartmentMFCDoc* COLEDBDepartmentMFCView::GetDocument() // non-debug version is inline
  83. {
  84. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COLEDBDepartmentMFCDoc)));
  85. return (COLEDBDepartmentMFCDoc*)m_pDocument;
  86. }
  87. #endif //_DEBUG
  88. /////////////////////////////////////////////////////////////////////////////
  89. // COLEDBDepartmentMFCView database support
  90. CRowset* COLEDBDepartmentMFCView::OnGetRowset()
  91. {
  92. return m_pSet;
  93. }
  94. /////////////////////////////////////////////////////////////////////////////
  95. // COLEDBDepartmentMFCView message handlers