115 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			115 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #ifndef __SQLFILE_H__
 | |
| #define __SQLFILE_H__
 | |
| 
 | |
| class TSqlRecord : public CObject
 | |
| {
 | |
| 	CMap<SHORT,SHORT,CString,CString&> m_Fields;
 | |
| 
 | |
| public:
 | |
| 	CString Get(SHORT index) const;
 | |
| 
 | |
|     void Clear();
 | |
| 	int Set(SHORT nIndex, const char* val, DWORD dwSize = 0);
 | |
| 	void SetRecord(CdbRecordset& dbRecordset);
 | |
| 
 | |
| 	BOOL IsEmpty() const { return m_Fields.GetCount() == 0; }
 | |
| 
 | |
| 	TSqlRecord();
 | |
| 	virtual ~TSqlRecord();
 | |
| };
 | |
| 
 | |
| class TSqlFile : public CObject
 | |
| {
 | |
| 	int             m_nFirm;
 | |
| 	int				m_nLogicNumber;
 | |
| 	CString			m_strWhere;
 | |
| 	DWORD			m_dwConnection;
 | |
| 	int				m_nKey; 
 | |
| 	
 | |
| 	COleVariant		m_oleVariant;
 | |
| 	
 | |
| 	BOOL			m_bExists;
 | |
| 	DWORD			m_dwSnapHandle;
 | |
| 	int             m_nItems;
 | |
| 	int				m_nStatus;
 | |
| 
 | |
| 	TSqlRecord		m_sqlRecord;
 | |
| 	
 | |
| 	CMapStringToPtr m_Locks; 
 | |
| 	BOOL            m_bExclusiveLock;
 | |
| 
 | |
| protected:
 | |
| 	int TestOpen() const;
 | |
| 	BOOL Requery();
 | |
| 
 | |
| 	CdbTableDef GetTableDef() const;
 | |
| 	CdbRecordset& GetDynaset() const;
 | |
| 	CdbRecordset& GetSnapshot();
 | |
| 	void CloseSnapshot();
 | |
| 
 | |
| 	const char* VariantToString(const COleVariant& oleVariant) const;
 | |
| 	const char* GetField(CdbRecordset& dbRecordset, const char* strName);
 | |
| 
 | |
|     
 | |
| 	CString BuildKey(CdbRecordset& dbRecordset, int nKey);
 | |
| 	CString BuildKey(const TSqlRecord& sqlRecord, int nKey);
 | |
| 
 | |
| 	int Read(CdbRecordset& dbSnapshot, const char* sKey, int flags);
 | |
| 	
 | |
| 	int Lock(CdbRecordset& dbSnapshot);
 | |
| 
 | |
| 	int Unlock(LPCSTR sKey);
 | |
| 	int Unlock(CdbRecordset& dbDynaset);
 | |
| 	void UnlockAll();
 | |
| 	int HandleLock(CdbRecordset& dbRecordset, int nLock);
 | |
| 
 | |
| public:
 | |
| 	int LogicNumber() const { return m_nLogicNumber; }
 | |
|     BOOL IsOpen() const;
 | |
| 	
 | |
| 	int Open();
 | |
| 	int Close();
 | |
| 
 | |
| 	int First(int nLock);
 | |
| 	int Prev(int nLock);
 | |
| 	int Next(int nLock);
 | |
| 	int Last(int nLock);
 | |
| 
 | |
| 	int Move(long pos, int nLock);
 | |
| 	int Skip(long pos, int nLock);
 | |
| 	long GetPosition();
 | |
| 
 | |
| 	int Read(const char* sKey, int flags);
 | |
| 	int Remove(const char* sKey);
 | |
| 	int Rewrite(const char* sKey);
 | |
| 	int Write();
 | |
| 
 | |
| 	int ExclusiveLock();
 | |
| 	int ExclusiveUnlock();
 | |
| 	
 | |
| 	const char* GetField(const char* strName);
 | |
| 	CString GetFieldInfo(int index) const;
 | |
| 	
 | |
| 	int GetRecordCount();
 | |
| 
 | |
| 	int SetKey(int key);
 | |
| 	int GetKey() const;
 | |
| 
 | |
| 	CString GetKeyExpr(int key) const;
 | |
| 
 | |
| 	int ClearFields();
 | |
| 	int SetField(int index, const char* value);
 | |
| 	int SetField(const char* name, const char* value);
 | |
| 
 | |
| 	BOOL Exists() const 
 | |
| 	{ return m_bExists; }
 | |
| 
 | |
| 	BOOL SetFirm(int nFirm);
 | |
| 
 | |
| 	TSqlFile(int nFirm, int nLogicNumber, 
 | |
| 		     LPCSTR sWhere, DWORD dwConnection);
 | |
| 	virtual ~TSqlFile();
 | |
| };
 | |
| 
 | |
| #endif
 |