// Borland C++ Builder
// Copyright (c) 1995, 2005 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'Pfibdataset.pas' rev: 10.00

#ifndef PfibdatasetHPP
#define PfibdatasetHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <Sysinit.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Stdfuncs.hpp>	// Pascal unit
#include <Db.hpp>	// Pascal unit
#include <Ibase.hpp>	// Pascal unit
#include <Ib_intf.hpp>	// Pascal unit
#include <Ib_externals.hpp>	// Pascal unit
#include <Fib.hpp>	// Pascal unit
#include <Fibmiscellaneous.hpp>	// Pascal unit
#include <Pfibdatabase.hpp>	// Pascal unit
#include <Fibdatabase.hpp>	// Pascal unit
#include <Fibdataset.hpp>	// Pascal unit
#include <Fibquery.hpp>	// Pascal unit
#include <Pfiblists.hpp>	// Pascal unit
#include <Pfibquery.hpp>	// Pascal unit
#include <Dscontainer.hpp>	// Pascal unit
#include <Pfibprops.hpp>	// Pascal unit
#include <Ib_errorcodes.hpp>	// Pascal unit
#include <Pfibinterfaces.hpp>	// Pascal unit
#include <Pfibdatainfo.hpp>	// Pascal unit
#include <Fmtbcd.hpp>	// Pascal unit
#include <Variants.hpp>	// Pascal unit
#include <Windows.hpp>	// Pascal unit
#include <Messages.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Pfibdataset
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TLockStatus { lsSuccess, lsDeadLock, lsNotExist, lsMultiply, lsUnknownError };
#pragma option pop

typedef void __fastcall (__closure *TLockErrorEvent)(Db::TDataSet* DataSet, TLockStatus LockError, AnsiString &ErrorMessage, Db::TDataAction &Action);

#pragma option push -b-
enum TCachRefreshKind { frkEdit, frkInsert };
#pragma option pop

typedef void __fastcall (__closure *TOnGetSQLTextProc)(Fibdataset::TFIBDataSet* DataSet, AnsiString &SQLText);

#pragma option push -b-
enum TIncludeFieldsToSQL { ifsAllFields, ifsNoBlob, ifsOnlyBlob };
#pragma option pop

typedef DynamicArray<Fibquery::TFIBXSQLVAR* >  pFIBDataSet__2;

class DELPHICLASS TpFIBDataSet;
class PASCALIMPLEMENTATION TpFIBDataSet : public Fibdataset::TFIBDataSet 
{
	typedef Fibdataset::TFIBDataSet inherited;
	
private:
	Fibquery::TFIBQuery* vQryRecordCount;
	Fibquery::TFIBQuery* vLockQry;
	int FDataSet_ID;
	int FLoadedDataSet_ID;
	Pfibprops::TFormatFields* FDefaultFormats;
	TLockErrorEvent FOnLockError;
	Db::TDataSetErrorEvent vUserOnPostError;
	Db::TDataSetErrorEvent vUserOnDeleteError;
	Classes::TList* vUpdates;
	Classes::TList* vDeletes;
	Classes::TList* vInserts;
	Classes::TStrings* FReceiveEvents;
	bool FHaveUncommitedChanges;
	bool FHaveRollbackedChanges;
	AnsiString FDescription;
	TOnGetSQLTextProc FOnAskRecordCount;
	Dscontainer::TOnApplyDefaultValue FOnApplyDefaultValue;
	int FSQLTextChanges;
	Pfibquery::TpFIBUpdateObject* FBlobsUpdate;
	Dscontainer::TOnApplyFieldRepository FOnApplyFieldRepository;
	Dscontainer::TDataSetsContainer* FContainer;
	bool FDefaultsInited;
	DynamicArray<Fibquery::TFIBXSQLVAR* >  FParamsForFields;
	bool FGeneratorBeUsed;
	void __fastcall SetContainer(Dscontainer::TDataSetsContainer* Value);
	HIDESBASE Classes::TStrings* __fastcall GetSelectSQL(void);
	HIDESBASE void __fastcall SetSelectSQL(Classes::TStrings* Value);
	Classes::TList* __fastcall ListForUO(Db::TUpdateKind KindUpdate);
	void __fastcall SynchroOrdersUO(Classes::TList* List);
	void __fastcall SetDataSet_ID(int Value);
	Db::TField* __fastcall GetFieldForTable(const AnsiString Relation);
	bool __fastcall WillGenerateSQLs(void);
	AnsiString __fastcall GetFIBVersion();
	void __fastcall SetFIBVersion(const AnsiString vs);
	
protected:
	virtual void __fastcall Notification(Classes::TComponent* AComponent, Classes::TOperation Operation);
	int __fastcall GetVisibleRecno(void);
	void __fastcall SetVisibleRecno(int Value);
	virtual int __fastcall GetRecNo(void);
	virtual void __fastcall SetRecNo(int Value);
	virtual void __fastcall InternalPost(void);
	virtual void __fastcall InternalOpen(void);
	virtual void __fastcall SetPrepareOptions(Pfibprops::TpPrepareOptions Value);
	virtual void __fastcall DoOnPostError(Db::TDataSet* DataSet, Db::EDatabaseError* E, Db::TDataAction &Action);
	void __fastcall DoOnDeleteError(Db::TDataSet* DataSet, Db::EDatabaseError* E, Db::TDataAction &Action);
	virtual int __fastcall CompareFieldValues(Db::TField* Field, const Variant &S1, const Variant &S2);
	virtual void __fastcall PSSetCommandText(const WideString CommandText)/* overload */;
	virtual WideString __fastcall PSGetTableNameW();
	virtual WideString __fastcall PSGetKeyFieldsW();
	virtual WideString __fastcall PSGetQuoteCharW();
	virtual WideString __fastcall PSGetCommandTextW();
	virtual Db::EUpdateError* __fastcall PSGetUpdateException(Sysutils::Exception* E, Db::EUpdateError* Prev);
	virtual bool __fastcall PSInTransaction(void);
	virtual bool __fastcall PSIsSQLBased(void);
	virtual bool __fastcall PSIsSQLSupported(void);
	virtual void __fastcall PSStartTransaction(void);
	virtual void __fastcall PSEndTransaction(bool Commit);
	virtual void __fastcall PSReset(void);
	virtual bool __fastcall PSUpdateRecord(Db::TUpdateKind UpdateKind, Db::TDataSet* Delta);
	virtual int __fastcall PSExecuteStatement(const WideString ASQL, Db::TParams* AParams, void * ResultSet = (void *)(0x0))/* overload */;
	virtual void __fastcall PSExecute(void);
	virtual Db::TParams* __fastcall PSGetParams(void);
	virtual void __fastcall PSSetParams(Db::TParams* AParams);
	virtual bool __fastcall IsVisible(char * Buffer);
	virtual void __fastcall InternalPostRecord(Fibquery::TFIBQuery* Qry, void * Buff);
	virtual void __fastcall InternalDeleteRecord(Fibquery::TFIBQuery* Qry, void * Buff);
	virtual void __fastcall AddedFilterRecord(Db::TDataSet* DataSet, bool &Accept);
	virtual void __fastcall InternalDoBeforeOpen(void);
	virtual void __fastcall DoBeforeOpen(void);
	virtual void __fastcall DoAfterOpen(void);
	virtual void __fastcall DoAfterClose(void);
	virtual void __fastcall DoBeforeInsert(void);
	virtual void __fastcall DoAfterInsert(void);
	virtual void __fastcall DoBeforeEdit(void);
	virtual void __fastcall DoBeforePost(void);
	virtual void __fastcall DoAfterPost(void);
	virtual void __fastcall DoBeforeCancel(void);
	virtual void __fastcall DoAfterCancel(void);
	virtual void __fastcall DoBeforeDelete(void);
	virtual void __fastcall DoOnNewRecord(void);
	virtual void __fastcall DoAfterDelete(void);
	virtual void __fastcall DoAfterEdit(void);
	virtual void __fastcall DoAfterScroll(void);
	virtual void __fastcall DoBeforeClose(void);
	virtual void __fastcall DoBeforeScroll(void);
	virtual void __fastcall DoOnCalcFields(void);
	virtual void __fastcall DoBeforeRefresh(void);
	virtual void __fastcall DoAfterRefresh(void);
	DYNAMIC void __fastcall DoOnApplyDefaultValue(Db::TField* Field, bool &Applied);
	virtual int __fastcall GetRecordCount(void);
	virtual void __fastcall UpdateFieldsProps(void);
	virtual void __fastcall DoAfterEndUpdateTransaction(Fibdatabase::TFIBTransaction* EndingTR, Fibdatabase::TTransactionAction Action, bool Force);
	void __fastcall ClearModifFlags(Byte Kind, bool NeedRefreshFields = true);
	void __fastcall CloseProtect(void);
	Db::TDataAction __fastcall RaiseLockError(TLockStatus LockError, AnsiString ExceptMessage);
	
public:
	__fastcall virtual TpFIBDataSet(Classes::TComponent* AOwner);
	__fastcall virtual ~TpFIBDataSet(void);
	DYNAMIC int __fastcall RecordCountFromSrv(void);
	int __fastcall VisibleRecordCount(void);
	int __fastcall VisibleRecnoToRecno(int VisRN);
	void __fastcall ParseParamToFieldsLinks(Classes::TStrings* Dest);
	virtual void __fastcall Prepare(void);
	virtual bool __fastcall CanEdit(void);
	virtual bool __fastcall CanInsert(void);
	virtual bool __fastcall CanDelete(void);
	virtual bool __fastcall IsSequenced(void);
	bool __fastcall ExistActiveUO(Db::TUpdateKind KindUpdate);
	int __fastcall AddUpdateObject(Pfibquery::TpFIBUpdateObject* Value);
	void __fastcall RemoveUpdateObject(Pfibquery::TpFIBUpdateObject* Value);
	Fibquery::TFIBXSQLVAR* __fastcall ParamByName(const AnsiString ParamName);
	Fibquery::TFIBXSQLVAR* __fastcall FindParam(const AnsiString ParamName);
	Db::TUpdateStatus __fastcall RecordStatus(int RecNumber);
	void __fastcall CloneRecord(int SrcRecord, System::TVarRec * IgnoreFields, const int IgnoreFields_Size);
	void __fastcall CloneCurRecord(System::TVarRec * IgnoreFields, const int IgnoreFields_Size);
	void __fastcall CommitUpdToCach(void);
	void __fastcall ApplyUpdToBase(void);
	void __fastcall ApplyUpdates(void);
	void __fastcall SaveToStream(Classes::TStream* Stream, bool SeekBegin);
	void __fastcall LoadFromStream(Classes::TStream* Stream, bool SeekBegin);
	void __fastcall SaveToFile(const AnsiString FileName);
	void __fastcall LoadFromFile(const AnsiString FileName);
	TLockStatus __fastcall LockRecord(bool RaiseErr = true);
	Db::TField* __fastcall FieldByFieldNo(int FieldNo);
	int __fastcall ParamNameCount(const AnsiString aParamName);
	HIDESBASE int __fastcall ParamCount(void);
	void __fastcall ExecUpdateObjects(Db::TUpdateKind KindUpdate, void * Buff, Pfibquery::TFIBOrderExecUO aExecuteOrder);
	void __fastcall OpenWP(Variant const * ParamValues, const int ParamValues_Size)/* overload */;
	void __fastcall OpenWP(const AnsiString ParamNames, Variant const * ParamValues, const int ParamValues_Size)/* overload */;
	void __fastcall OpenWPS(Pfibinterfaces::_di_ISQLObject const * ParamSources, const int ParamSources_Size);
	void __fastcall ReOpenWP(Variant const * ParamValues, const int ParamValues_Size)/* overload */;
	void __fastcall ReOpenWP(const AnsiString ParamNames, Variant const * ParamValues, const int ParamValues_Size)/* overload */;
	void __fastcall ReOpenWPS(Pfibinterfaces::_di_ISQLObject const * ParamSources, const int ParamSources_Size);
	void __fastcall BatchRecordToQuery(Fibquery::TFIBQuery* ToQuery);
	void __fastcall BatchAllRecordsToQuery(Fibquery::TFIBQuery* ToQuery);
	void __fastcall AutoGenerateSQLText(Db::TDataSetState ForState);
	AnsiString __fastcall GenerateSQLText(const AnsiString TableName, const AnsiString KeyFieldNames, Fibdataset::TpSQLKind SK, TIncludeFieldsToSQL IncludeFields = (TIncludeFieldsToSQL)(0x0));
	AnsiString __fastcall GenerateSQLTextWA(const AnsiString TableName, Fibdataset::TpSQLKind SK, TIncludeFieldsToSQL IncludeFields = (TIncludeFieldsToSQL)(0x0));
	void __fastcall GenerateUpdateBlobsSQL(void);
	void __fastcall GenerateSQLs(void);
	bool __fastcall CanGenerateSQLs(void);
	Db::TField* __fastcall KeyField(void);
	AnsiString __fastcall SqlTextGenID();
	virtual void __fastcall IncGenerator(void);
	AnsiString __fastcall AllKeyFields(const AnsiString TableName);
	void __fastcall CacheModify(int * aFields, const int aFields_Size, Variant * Values, const int Values_Size, Byte KindModify);
	void __fastcall CacheEdit(int * aFields, const int aFields_Size, Variant * Values, const int Values_Size);
	void __fastcall CacheAppend(int * aFields, const int aFields_Size, Variant * Values, const int Values_Size)/* overload */;
	void __fastcall CacheAppend(const Variant &Value, bool DoRefresh = false)/* overload */;
	void __fastcall CacheInsert(int * aFields, const int aFields_Size, Variant * Values, const int Values_Size)/* overload */;
	void __fastcall CacheInsert(const Variant &Value, bool DoRefresh = false)/* overload */;
	void __fastcall CacheRefresh(Db::TDataSet* FromDataSet, TCachRefreshKind Kind, Classes::TStrings* FieldMap);
	void __fastcall CacheRefreshByArrMap(Db::TDataSet* FromDataSet, TCachRefreshKind Kind, AnsiString const * SourceFields, const int SourceFields_Size, AnsiString const * DestFields, const int DestFields_Size);
	double __fastcall RecordFieldAsFloat(Db::TField* Field, int RecNumber, bool IsVisibleRecordNum = true);
	__property bool HasUncommitedChanges = {read=FHaveUncommitedChanges, nodefault};
	__property bool HaveRollbackedChanges = {read=FHaveRollbackedChanges, nodefault};
	__property int AllRecordCount = {read=FAllRecordCount, nodefault};
	__property int VisibleRecno = {read=GetVisibleRecno, write=SetVisibleRecno, nodefault};
	
__published:
	__property Filtered  = {default=0};
	__property OnFilterRecord ;
	__property Classes::TStrings* DeleteSQL = {read=GetDeleteSQL, write=SetDeleteSQL};
	__property Classes::TStrings* UpdateSQL = {read=GetUpdateSQL, write=SetUpdateSQL};
	__property Classes::TStrings* InsertSQL = {read=GetInsertSQL, write=SetInsertSQL};
	__property Classes::TStrings* RefreshSQL = {read=GetRefreshSQL, write=SetRefreshSQL};
	__property Classes::TStrings* SelectSQL = {read=GetSelectSQL, write=SetSelectSQL};
	__property Pfibprops::TFormatFields* DefaultFormats = {read=FDefaultFormats, write=FDefaultFormats};
	__property Db::TDataSetErrorEvent OnPostError = {read=vUserOnPostError, write=vUserOnPostError};
	__property Db::TDataSetErrorEvent OnDeleteError = {read=vUserOnDeleteError, write=vUserOnDeleteError};
	__property TLockErrorEvent OnLockError = {read=FOnLockError, write=FOnLockError};
	__property int DataSet_ID = {read=FDataSet_ID, write=SetDataSet_ID, default=0};
	__property AnsiString Description = {read=FDescription, write=FDescription};
	__property Dscontainer::TDataSetsContainer* Container = {read=FContainer, write=SetContainer};
	__property TOnGetSQLTextProc OnAskRecordCount = {read=FOnAskRecordCount, write=FOnAskRecordCount};
	__property AnsiString About = {read=GetFIBVersion, write=SetFIBVersion, stored=false};
	__property Dscontainer::TOnApplyDefaultValue OnApplyDefaultValue = {read=FOnApplyDefaultValue, write=FOnApplyDefaultValue};
	__property Dscontainer::TOnApplyFieldRepository OnApplyFieldRepository = {read=FOnApplyFieldRepository, write=FOnApplyFieldRepository};
	
/* Hoisted overloads: */
	
protected:
	inline void __fastcall  PSSetCommandText(const AnsiString CommandText){ TWideDataSet::PSSetCommandText(CommandText); }
	inline int __fastcall  PSExecuteStatement(const AnsiString ASQL, Db::TParams* AParams, void * ResultSet = (void *)(0x0)){ return TWideDataSet::PSExecuteStatement(ASQL, AParams, ResultSet); }
	
};


//-- var, const, procedure ---------------------------------------------------
extern PACKAGE bool __fastcall FieldInArray(Db::TField* Field, System::TVarRec * Arr, const int Arr_Size);

}	/* namespace Pfibdataset */
using namespace Pfibdataset;
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// Pfibdataset
