home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c08 / lab02 / ex02 / employeepersonalset.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.3 KB  |  97 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.  
  40. CString CEmployeePersonalSet::GetDefaultDBName()
  41. {
  42.     // Search for the database 2 levels up...
  43.     struct _finddata_t c_file;
  44.     long hFile;
  45.     CString fname = "..\\..\\personnel.mdb";
  46.  
  47.     hFile = _findfirst(fname, &c_file);
  48.  
  49.     if( -1 != hFile )
  50.         return _T(fname);
  51.  
  52.     // and then one level up.
  53.     fname = "..\\personnel.mdb";
  54.  
  55.     hFile = _findfirst(fname, &c_file);
  56.  
  57.     if( -1 != hFile )
  58.         return _T(fname);
  59.  
  60.     return _T("");
  61. }
  62.  
  63. CString CEmployeePersonalSet::GetDefaultSQL()
  64. {
  65.     return _T("[Employee Personal Info Table]");
  66. }
  67.  
  68. void CEmployeePersonalSet::DoFieldExchange(CDaoFieldExchange* pFX)
  69. {
  70.     //{{AFX_FIELD_MAP(CEmployeePersonalSet)
  71.     pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  72.     DFX_Long(pFX, _T("[Employee Number]"), m_Employee_Number);
  73.     DFX_DateTime(pFX, _T("[Birthdate]"), m_Birthdate);
  74.     DFX_Byte(pFX, _T("[Sex & Marital Status]"), m_Sex___Marital_Status);
  75.     DFX_Double(pFX, _T("[Height]"), m_Height);
  76.     DFX_Double(pFX, _T("[Weight]"), m_Weight);
  77.     //}}AFX_FIELD_MAP
  78.  
  79.     pFX->SetFieldType(CDaoFieldExchange::param);
  80.     DFX_Long(pFX, _T("EmployeeNumberParam"), m_EmployeeNumberParam);
  81. }
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CEmployeePersonalSet diagnostics
  85.  
  86. #ifdef _DEBUG
  87. void CEmployeePersonalSet::AssertValid() const
  88. {
  89.     CDaoRecordset::AssertValid();
  90. }
  91.  
  92. void CEmployeePersonalSet::Dump(CDumpContext& dc) const
  93. {
  94.     CDaoRecordset::Dump(dc);
  95. }
  96. #endif //_DEBUG
  97.