home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c08 / lab02 / ex01 / employeepersonalset.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.3 KB  |  96 lines

  1. // EmployeePersonalSet.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Employee.h"
  6. #include "EmployeePersonalSet.h"
  7.  
  8. #include <io.h>    // for _findfirst
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CEmployeePersonalSet
  18.  
  19. IMPLEMENT_DYNAMIC(CEmployeePersonalSet, CDaoRecordset)
  20.  
  21. CEmployeePersonalSet::CEmployeePersonalSet(CDaoDatabase* pdb)
  22.     : CDaoRecordset(pdb)
  23. {
  24.     //{{AFX_FIELD_INIT(CEmployeePersonalSet)
  25.     m_Employee_Number = 0;
  26.     m_Sex___Marital_Status = 0;
  27.     m_Height = 0.0;
  28.     m_Weight = 0.0;
  29.     m_nFields = 5;
  30.     //}}AFX_FIELD_INIT
  31.     m_nDefaultType = dbOpenDynaset;
  32.  
  33.     //set up a parameterized query 
  34.     m_strFilter = "[Employee Number] = EmployeeNumberParam";
  35.     m_nParams    = 1;
  36.     m_EmployeeNumberParam = 0;
  37. }
  38.  
  39. CString CEmployeePersonalSet::GetDefaultDBName()
  40. {
  41.     // Search for the database 2 levels up...
  42.     struct _finddata_t c_file;
  43.     long hFile;
  44.     CString fname = "..\\..\\personnel.mdb";
  45.  
  46.     hFile = _findfirst(fname, &c_file);
  47.  
  48.     if( -1 != hFile )
  49.         return _T(fname);
  50.  
  51.     // and then one level up.
  52.     fname = "..\\personnel.mdb";
  53.  
  54.     hFile = _findfirst(fname, &c_file);
  55.  
  56.     if( -1 != hFile )
  57.         return _T(fname);
  58.  
  59.     return _T("");
  60. }
  61.  
  62. CString CEmployeePersonalSet::GetDefaultSQL()
  63. {
  64.     return _T("[Employee Personal Info Table]");
  65. }
  66.  
  67. void CEmployeePersonalSet::DoFieldExchange(CDaoFieldExchange* pFX)
  68. {
  69.     //{{AFX_FIELD_MAP(CEmployeePersonalSet)
  70.     pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  71.     DFX_Long(pFX, _T("[Employee Number]"), m_Employee_Number);
  72.     DFX_DateTime(pFX, _T("[Birthdate]"), m_Birthdate);
  73.     DFX_Byte(pFX, _T("[Sex & Marital Status]"), m_Sex___Marital_Status);
  74.     DFX_Double(pFX, _T("[Height]"), m_Height);
  75.     DFX_Double(pFX, _T("[Weight]"), m_Weight);
  76.     //}}AFX_FIELD_MAP
  77.  
  78.     pFX->SetFieldType(CDaoFieldExchange::param);
  79.     DFX_Long(pFX, _T("EmployeeNumberParam"), m_EmployeeNumberParam);
  80. }
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CEmployeePersonalSet diagnostics
  84.  
  85. #ifdef _DEBUG
  86. void CEmployeePersonalSet::AssertValid() const
  87. {
  88.     CDaoRecordset::AssertValid();
  89. }
  90.  
  91. void CEmployeePersonalSet::Dump(CDumpContext& dc) const
  92. {
  93.     CDaoRecordset::Dump(dc);
  94. }
  95. #endif //_DEBUG
  96.