home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / dbvlist / dbvlistset.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.6 KB  |  115 lines

  1. // DBVListSet.cpp : implementation of the CDBVListSet class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "DBVList.h"
  15. #include "DBVListSet.h"
  16.  
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CDBVListSet implementation
  25.  
  26. IMPLEMENT_DYNAMIC(CDBVListSet, CDaoRecordset)
  27.  
  28. CDBVListSet::CDBVListSet(CDaoDatabase* pdb)
  29.     : CDaoRecordset(pdb)
  30. {
  31.     //{{AFX_FIELD_INIT(CDBVListSet)
  32.     m_Email = _T("");
  33.     m_Name = _T("");
  34.     m_Phone = _T("");
  35.     m_Location = _T("");
  36.     m_Title = _T("");
  37.     m_Department = _T("");
  38.     m_Division = _T("");
  39.     m_nFields = 7;
  40.     //}}AFX_FIELD_INIT
  41.     m_nDefaultType = dbOpenDynaset;
  42. }
  43.  
  44. CString CDBVListSet::GetDefaultDBName()
  45. {
  46.     return _T("emp_all.mdb");
  47. }
  48.  
  49.  
  50. CString CDBVListSet::GetDefaultSQL()
  51. {
  52.     return _T("[Employee8]");
  53. }
  54.  
  55. void CDBVListSet::DoFieldExchange(CDaoFieldExchange* pFX)
  56. {
  57.     //{{AFX_FIELD_MAP(CDBVListSet)
  58.     pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  59.     DFX_Text(pFX, _T("[Email]"), m_Email);
  60.     DFX_Text(pFX, _T("[Name]"), m_Name);
  61.     DFX_Text(pFX, _T("[Phone]"), m_Phone);
  62.     DFX_Text(pFX, _T("[Location]"), m_Location);
  63.     DFX_Text(pFX, _T("[Title]"), m_Title);
  64.     DFX_Text(pFX, _T("[Department]"), m_Department);
  65.     DFX_Text(pFX, _T("[Division]"), m_Division);
  66.     //}}AFX_FIELD_MAP
  67. }
  68.  
  69. void CDBVListSet::SetFilter(CString strCurQuery)
  70. {
  71.     // convenience function to set the SQL filter for the query
  72.  
  73.     if (strCurQuery == m_strFilter)
  74.         return;
  75.  
  76.     CWaitCursor wait;
  77.  
  78.     m_strFilter.Format(_T("[Division] = '%s'"), (LPCTSTR)strCurQuery);
  79.     if (!IsOpen())
  80.         Open();
  81.     Requery();
  82.  
  83.     // update record counts
  84.     while (!IsEOF())
  85.         MoveNext();
  86. }
  87.  
  88.  
  89. void CDBVListSet::SetSort(LPCTSTR pszSortField)
  90. {
  91.     // convenience function to set the SQL sort for the query
  92.  
  93.     m_strSort = pszSortField;
  94.     if (IsOpen())
  95.     {
  96.         CWaitCursor wait;
  97.         Requery();
  98.     }
  99. }
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CDBVListSet diagnostics
  103.  
  104. #ifdef _DEBUG
  105. void CDBVListSet::AssertValid() const
  106. {
  107.     CDaoRecordset::AssertValid();
  108. }
  109.  
  110. void CDBVListSet::Dump(CDumpContext& dc) const
  111. {
  112.     CDaoRecordset::Dump(dc);
  113. }
  114. #endif //_DEBUG
  115.