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

书籍源码

开发平台:

Visual C++

  1. // OLEDBTextConsumerView.cpp : implementation of the COLEDBTextConsumerView class
  2. //
  3. #include "stdafx.h"
  4. #include "OLEDBTextConsumer.h"
  5. #include "OLEDBTextConsumerSet.h"
  6. #include "OLEDBTextConsumerDoc.h"
  7. #include "OLEDBTextConsumerView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // COLEDBTextConsumerView
  15. IMPLEMENT_DYNCREATE(COLEDBTextConsumerView, COleDBRecordView)
  16. BEGIN_MESSAGE_MAP(COLEDBTextConsumerView, COleDBRecordView)
  17. //{{AFX_MSG_MAP(COLEDBTextConsumerView)
  18. //}}AFX_MSG_MAP
  19. END_MESSAGE_MAP()
  20. /////////////////////////////////////////////////////////////////////////////
  21. // COLEDBTextConsumerView construction/destruction
  22. COLEDBTextConsumerView::COLEDBTextConsumerView()
  23. : COleDBRecordView(COLEDBTextConsumerView::IDD)
  24. {
  25. //{{AFX_DATA_INIT(COLEDBTextConsumerView)
  26. // NOTE: the ClassWizard will add member initialization here
  27. m_pSet = NULL;
  28. //}}AFX_DATA_INIT
  29. }
  30. COLEDBTextConsumerView::~COLEDBTextConsumerView()
  31. {
  32. }
  33. void COLEDBTextConsumerView::DoDataExchange(CDataExchange* pDX)
  34. {
  35. COleDBRecordView::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(COLEDBTextConsumerView)
  37. // NOTE: the ClassWizard will add DDX and DDV calls here
  38. //}}AFX_DATA_MAP
  39. //Added by Chuck Wood for data transfer
  40. DDX_Text(pDX, IDC_CLASS, m_pSet->m_strClass, 51);
  41. DDX_Text(pDX, IDC_SECTION, m_pSet->m_strSectionID, 12);
  42. DDX_Text(pDX, IDC_YEAR, m_pSet->m_strYear, 7);
  43. DDX_Text(pDX, IDC_TERM, m_pSet->m_strTerm, 31);
  44. DDX_Text(pDX, IDC_INSTRUCTOR, m_pSet->m_strInstructor, 51);
  45. DDX_Text(pDX, IDC_ASSIGNMENT, m_pSet->m_strAssignment, 256);
  46. DDX_Text(pDX, IDC_SCORE, m_pSet->m_strScore, 23);
  47. DDX_Text(pDX, IDC_STUDENT, m_pSet->m_strStudent, 36);
  48. DDV_MaxChars(pDX, m_pSet->m_strClass, 51);
  49. DDV_MaxChars(pDX, m_pSet->m_strSectionID, 12);
  50. DDV_MaxChars(pDX, m_pSet->m_strYear, 7);
  51. DDV_MaxChars(pDX, m_pSet->m_strTerm, 31);
  52. DDV_MaxChars(pDX, m_pSet->m_strInstructor, 51);
  53. DDV_MaxChars(pDX, m_pSet->m_strAssignment, 256);
  54. DDV_MaxChars(pDX, m_pSet->m_strScore, 23);
  55. DDV_MaxChars(pDX, m_pSet->m_strStudent, 36);
  56. }
  57. BOOL COLEDBTextConsumerView::PreCreateWindow(CREATESTRUCT& cs)
  58. {
  59. return COleDBRecordView::PreCreateWindow(cs);
  60. }
  61. void COLEDBTextConsumerView::OnInitialUpdate()
  62. {
  63. m_pSet = &GetDocument()->m_oLEDBTextConsumerSet;
  64. {
  65. CWaitCursor wait;
  66. HRESULT hr = m_pSet->Open();
  67. if (hr != S_OK)
  68. {
  69. AfxMessageBox(_T("Record set failed to open."), MB_OK);
  70. m_bOnFirstRecord = TRUE;
  71. m_bOnLastRecord = TRUE;
  72. }
  73. }
  74. COleDBRecordView::OnInitialUpdate();
  75. }
  76. /////////////////////////////////////////////////////////////////////////////
  77. // COLEDBTextConsumerView diagnostics
  78. #ifdef _DEBUG
  79. void COLEDBTextConsumerView::AssertValid() const
  80. {
  81. COleDBRecordView::AssertValid();
  82. }
  83. void COLEDBTextConsumerView::Dump(CDumpContext& dc) const
  84. {
  85. COleDBRecordView::Dump(dc);
  86. }
  87. COLEDBTextConsumerDoc* COLEDBTextConsumerView::GetDocument() // non-debug version is inline
  88. {
  89. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COLEDBTextConsumerDoc)));
  90. return (COLEDBTextConsumerDoc*)m_pDocument;
  91. }
  92. #endif //_DEBUG
  93. /////////////////////////////////////////////////////////////////////////////
  94. // COLEDBTextConsumerView database support
  95. CRowset* COLEDBTextConsumerView::OnGetRowset()
  96. {
  97. return m_pSet;
  98. }
  99. /////////////////////////////////////////////////////////////////////////////
  100. // COLEDBTextConsumerView message handlers
  101. BOOL COLEDBTextConsumerView::OnMove(UINT nIDMoveCommand) 
  102. {
  103. return COleDBRecordView::OnMove(nIDMoveCommand);
  104. }