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

  1. // JoinSet.cpp : implementation of the CJoinSet class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Join.h"
  6. #include "JoinSet.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. // CJoinSet implementation
  18.  
  19. IMPLEMENT_DYNAMIC(CJoinSet, CDaoRecordset)
  20.  
  21. CJoinSet::CJoinSet(CDaoDatabase* pdb)
  22.     : CDaoRecordset(pdb)
  23. {
  24.     //{{AFX_FIELD_INIT(CJoinSet)
  25.     m_Employee_Number = 0;
  26.     m_Last_Name = _T("");
  27.     m_First_Name = _T("");
  28.     m_Department__ = 0;
  29.     m_Employee_Pay_Type = 0;
  30.     m_Hours = 0.0;
  31.     m_Hourly_Rate = 0.0;
  32.     m_Weekly_Salary = 0.0;
  33.     m_Sales_Bonus_Rate = 0.0;
  34.     m_Weekly_Sales = 0.0;
  35.     m_Employee_Number2 = 0;
  36.     m_Sex___Marital_Status = 0;
  37.     m_Height = 0.0;
  38.     m_Weight = 0.0;
  39.     m_nFields = 15;
  40.     //}}AFX_FIELD_INIT
  41.     m_nDefaultType = dbOpenDynaset;
  42.  
  43.     m_strFilter = "[Employee Pay Table].[Employee Number] = "
  44.                   "[Employee Personal Info Table].[Employee Number]";
  45.  
  46.     m_strSort   = "[Employee Pay Table].[Last Name], "
  47.                   "[Employee Pay Table].[First Name]";
  48. }
  49.  
  50. CString CJoinSet::GetDefaultDBName()
  51. {
  52.     // Search for the database 2 levels up...
  53.     struct _finddata_t c_file;
  54.     long hFile;
  55.     CString fname = "..\\..\\personnel.mdb";
  56.  
  57.     hFile = _findfirst(fname, &c_file);
  58.  
  59.     if( -1 != hFile )
  60.         return _T(fname);
  61.  
  62.     // and then one level up.
  63.     fname = "..\\personnel.mdb";
  64.  
  65.     hFile = _findfirst(fname, &c_file);
  66.  
  67.     if( -1 != hFile )
  68.         return _T(fname);
  69.  
  70.     return _T("");
  71. }
  72.  
  73.  
  74. CString CJoinSet::GetDefaultSQL()
  75. {
  76.     return _T("[Employee Pay Table],[Employee Personal Info Table]");
  77. }
  78.  
  79. void CJoinSet::DoFieldExchange(CDaoFieldExchange* pFX)
  80. {
  81.     //{{AFX_FIELD_MAP(CJoinSet)
  82.     pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  83.     DFX_Long(pFX, _T("[Employee Pay Table].[Employee Number]"), m_Employee_Number);
  84.     DFX_Text(pFX, _T("[Last Name]"), m_Last_Name);
  85.     DFX_Text(pFX, _T("[First Name]"), m_First_Name);
  86.     DFX_Short(pFX, _T("[Department #]"), m_Department__);
  87.     DFX_Short(pFX, _T("[Employee Pay Type]"), m_Employee_Pay_Type);
  88.     DFX_Double(pFX, _T("[Hours]"), m_Hours);
  89.     DFX_Double(pFX, _T("[Hourly Rate]"), m_Hourly_Rate);
  90.     DFX_Double(pFX, _T("[Weekly Salary]"), m_Weekly_Salary);
  91.     DFX_Double(pFX, _T("[Sales Bonus Rate]"), m_Sales_Bonus_Rate);
  92.     DFX_Double(pFX, _T("[Weekly Sales]"), m_Weekly_Sales);
  93.     DFX_Long(pFX, _T("[Employee Personal Info Table].[Employee Number]"), m_Employee_Number2);
  94.     DFX_DateTime(pFX, _T("[Birthdate]"), m_Birthdate);
  95.     DFX_Byte(pFX, _T("[Sex & Marital Status]"), m_Sex___Marital_Status);
  96.     DFX_Double(pFX, _T("[Height]"), m_Height);
  97.     DFX_Double(pFX, _T("[Weight]"), m_Weight);
  98.     //}}AFX_FIELD_MAP
  99. }
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CJoinSet diagnostics
  103.  
  104. #ifdef _DEBUG
  105. void CJoinSet::AssertValid() const
  106. {
  107.     CDaoRecordset::AssertValid();
  108. }
  109.  
  110. void CJoinSet::Dump(CDumpContext& dc) const
  111. {
  112.     CDaoRecordset::Dump(dc);
  113. }
  114. #endif //_DEBUG
  115.