1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| #ifndef __REPERESPHYSIQUES_H_
#define __REPERESPHYSIQUES_H_
class CReperesPhysiquesAccessor
{
public:
TCHAR m_Description[51];
TCHAR m_EUUnits[51];
LONG m_ID;
VARIANT_BOOL m_EnAcqPermanente;
VARIANT_BOOL m_Monitor;
TCHAR m_Name[51];
LONG m_ParentID;
LONG m_Sequence;
LONG m_Type;
LONG m_Nature;
LONG m_TypePhysique;
LONG m_RangBit;
LONG m_Adresse;
LONG m_UPC;
BEGIN_COLUMN_MAP(CReperesPhysiquesAccessor)
COLUMN_ENTRY(1, m_ID)
COLUMN_ENTRY(2, m_ParentID)
COLUMN_ENTRY(3, m_Name)
COLUMN_ENTRY(4, m_Sequence)
COLUMN_ENTRY_TYPE(5, DBTYPE_BOOL, m_Monitor)
COLUMN_ENTRY_TYPE(6, DBTYPE_BOOL, m_EnAcqPermanente)
COLUMN_ENTRY(7, m_EUUnits)
COLUMN_ENTRY(8, m_Description)
COLUMN_ENTRY(9, m_Type)
COLUMN_ENTRY(10, m_Nature)
COLUMN_ENTRY(11, m_TypePhysique)
COLUMN_ENTRY(12, m_RangBit)
COLUMN_ENTRY(13, m_Adresse)
COLUMN_ENTRY(14, m_UPC)
END_COLUMN_MAP()
// You may wish to call this function if you are inserting a record and wish to
// initialize all the fields, if you are not going to explicitly set all of them.
void ClearRecord()
{
memset(this, 0, sizeof(*this));
}
};
class CReperesPhysiques : public CCommand<CAccessor<CReperesPhysiquesAccessor> >
{
public:
HRESULT Open()
{
HRESULT hr;
hr = OpenDataSource();
if (FAILED(hr))
return hr;
return OpenRowset();
}
HRESULT OpenDataSource()
{
HRESULT hr;
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);
dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);
dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin"));
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("D:\\MonRepertoireDeTravail\\CommonFiles\\Database.mdb"));
dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(""));
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
hr = db.Open(_T("Microsoft.Jet.OLEDB.4.0"), &dbinit);
if (FAILED(hr))
return hr;
return m_session.Open(db);
}
HRESULT OpenRowset()
{
return CCommand<CAccessor<CReperesPhysiquesAccessor> >::Open(m_session);
}
CSession m_session;
};
#endif // __REPERESPHYSIQUES_H_ |