//---------------------------------------------------------------------------

#ifndef DMDbFH
#define DMDbFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
//---------------------------------------------------------------------------
#define ERRMSG(v,w,x,y) ITSLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,true)
#define ERRLOG(v,w,x,y) ITSLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,false)
//---------------------------------------------------------------------------
class TDMDb : public TDataModule
{
__published:	// IDE-managed Components
    void __fastcall DataModuleCreate(TObject *Sender);
    void __fastcall DataModuleDestroy(TObject *Sender);
private:	// User declarations
    TADOConnection *FDbConn;
    String          FErrorString;
    String          FConnString;
    bool            FException;

public:		// User declarations
    __fastcall TDMDb(TComponent* Owner);

    void __fastcall SetException(bool AException=true) { FException = AException; }

    TADOConnection *GetConnection() { return FDbConn; }
    void __fastcall SetConnectString(String AProvider, String AServerName, String AUserName, String APassword, String ACatalog="");
    void __fastcall SetConnectString(String AConnStr);

    bool __fastcall Connect(String AConnStr="");
    bool __fastcall Close();

    bool __fastcall SQLClose(TADOQuery *adoQry);
    bool __fastcall SQLClear(TADOQuery *adoQry);
    int  __fastcall SQLText(TADOQuery *adoQry, String sQry);
    bool __fastcall SQLBind(TADOQuery *adoQry, String param, String var);
    bool __fastcall SQLBindStream(TADOQuery *adoQry, String param, TStream * pStream);
    int  __fastcall SQLOpen(TADOQuery *adoQry);
    int  __fastcall SQLExec(TADOQuery *adoQry);
    bool __fastcall LocateItem(TADOQuery *adoQry, String sFldNm, String sFldVal);

    void __fastcall SetErrorString(String AErrorString);
	__property String  ErrorString = {read=FErrorString, write=SetErrorString};
	__property String  ConnString  = {read=FConnString,  write=FConnString};
};
//---------------------------------------------------------------------------
extern PACKAGE TDMDb *DMDb;
//---------------------------------------------------------------------------
#endif
