📄 hmoledataset.pas
字号:
{-----------------------------------------------------------------------------
Unit: hmOleDataset
Author: aleyn.wu
Date: 2002-05-12
Arguments: None
-----------------------------------------------------------------------------}
unit hmOleDataset;
interface
uses
Classes, SysUtils, Variants, DB, hmIntf;
type
IHMOleDataSet = interface
['{BDE495F1-7DD2-45C7-ABF3-BFA35C4F14D6}']
{procedure}
procedure Open; safecall;
procedure Close; safecall;
procedure First; safecall;
procedure Prev; safecall;
procedure Next; safecall;
procedure Last; safecall;
procedure Append; safecall;
procedure Edit; safecall;
procedure Post; safecall;
{function}
function NotEmpty: Boolean; safecall;
function Bof: Boolean; safecall;
function Eof: Boolean; safecall;
function Locate(KeyField: WideString; KeyValue: OleVariant): Boolean; safecall;
function IsNull(FieldName: WideString): Boolean; safecall;
{property Mother}
function GetActive: Boolean; safecall;
procedure SetActive(const Value: Boolean); safecall;
function GetRecordCount: Integer; safecall;
function GetBV(index: WideString): Boolean; safecall;
procedure SetBV(index: WideString; const Value: Boolean); safecall;
function GetSV(index: WideString): WideString; safecall;
procedure SetSV(index: WideString; const Value: WideString); safecall;
function GetDV(index: WideString): TDatetime; safecall;
procedure SetDV(index: WideString; const Value: TDatetime); safecall;
function GetIV(index: WideString): Integer; safecall;
procedure SetIV(index: WideString; const Value: Integer); safecall;
function GetFV(index: WideString): Double; safecall;
procedure SetFV(index: WideString; const Value: Double); safecall;
function GetValue(index: WideString): OleVariant; safecall;
procedure SetValue(index: WideString; const Value: OleVariant); safecall;
function GetUpdateStatus: TUpdateStatus; safecall;
{property}
property Active: Boolean read GetActive write SetActive;
property RecordCount: integer read GetRecordCount;
property BV[index: WideString]: Boolean read GetBV write SetBV;
property SV[index: WideString]: WideString read GetSV write SetSV;
property DV[index: WideString]: TDatetime read GetDV write SetDV;
property IV[index: WideString]: Integer read GetIV write SetIV;
property FV[index: WideString]: Double read GetFV write SetFV;
property Value[index: WideString]: OleVariant read GetValue write SetValue; default;
property UpdateStatus: TUpdateStatus read GetUpdateStatus;
end;
THMOleDataSet = class(TSafeInterfacedObject, IHMOleDataSet)
private
FParent: TDataSet;
protected
function GetActive: Boolean; safecall;
procedure SetActive(const Value: Boolean); safecall;
function GetRecordCount: Integer; safecall;
function GetBV(index: WideString): Boolean; safecall;
procedure SetBV(index: WideString; const Value: Boolean); safecall;
function GetSV(index: WideString): WideString; safecall;
procedure SetSV(index: WideString; const Value: WideString); safecall;
function GetDV(index: WideString): TDatetime; safecall;
procedure SetDV(index: WideString; const Value: TDatetime); safecall;
function GetIV(index: WideString): Integer; safecall;
procedure SetIV(index: WideString; const Value: Integer); safecall;
function GetFV(index: WideString): Double; safecall;
procedure SetFV(index: WideString; const Value: Double); safecall;
function GetValue(index: WideString): OleVariant; safecall;
procedure SetValue(index: WideString; const Value: OleVariant); safecall;
function GetUpdateStatus: TUpdateStatus; safecall;
public
constructor Create(AOwner: TComponent); virtual;
procedure Open; safecall;
procedure Close; safecall;
procedure First; safecall;
procedure Prev; safecall;
procedure Next; safecall;
procedure Last; safecall;
procedure Append; safecall;
procedure Edit; safecall;
procedure Post; safecall;
function NotEmpty: Boolean; safecall;
function Bof: Boolean; safecall;
function Eof: Boolean; safecall;
function Locate(KeyField: WideString; KeyValue: OleVariant): Boolean; safecall;
function IsNull(FieldName: WideString): Boolean; safecall;
property Parent: TDataSet read FParent;
end;
IHMOleADOQuery = interface(IHMOleDataSet)
['{8E96658D-C912-4684-931D-30ED8E5F67FC}']
procedure LoadSql(Sql: WideString); safecall;
procedure LoadSqlAndOpen(Sql: WideString); safecall;
end;
THMCustomOleADOQuery = class(THMOleDataSet, IHMOleADOQuery)
public
procedure LoadSql(Sql: WideString); virtual; safecall;
procedure LoadSqlAndOpen(Sql: WideString); virtual; safecall;
end;
IHMOleClientDataSet = interface(IHMOleDataSet)
['{FEB67005-4631-4746-A2A3-F2C20C8664C9}']
procedure LoadData; safecall;
procedure LoadDataEx(var Data: OleVariant); safecall;
procedure LoadOleData(Name: Widestring); safecall;
function GetData: OleVariant; safecall;
procedure SetData(Value: OleVariant); safecall;
property Data: OleVariant read GetData write SetData;
end;
THMCustomOleClientDataSet = class(THMOleDataSet, IHMOleClientDataSet)
protected
function GetData: OleVariant; virtual; safecall;
procedure SetData(Value: OleVariant); virtual; safecall;
public
procedure LoadData; virtual; safecall;
procedure LoadDataEx(var Data: OleVariant); virtual; safecall;
procedure LoadOleData(Name: Widestring); virtual; safecall;
end;
implementation
{ THMOleDataSet }
constructor THMOleDataSet.Create(AOwner: TComponent);
begin
inherited Create;
FParent := AOwner as TDataSet;
end;
function THMOleDataSet.GetBV(index: WideString): Boolean;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsBoolean
else
raise Exception.Create('GetBV(' + index + ') Error, Query is not actived.');
end; // with
end;
procedure THMOleDataSet.SetBV(index: WideString; const Value: Boolean);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsBoolean := Value
else
raise Exception.Create('SetBV(' + index + ') Error, Query is not actived.');
end; // with
end;
function THMOleDataSet.GetDV(index: WideString): TDatetime;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsDateTime
else
raise Exception.Create('GetDV(' + index + ') Error, Query is not actived.');
end; // with
end;
function THMOleDataSet.GetFV(index: WideString): Double;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsFloat
else
raise Exception.Create('GetFV(' + index + ') Error, Query is not actived.');
end; // with
end;
function THMOleDataSet.GetIV(index: WideString): Integer;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsInteger
else
raise Exception.Create('GetIV(' + index + ') Error, Query is not actived.');
end; // with
end;
function THMOleDataSet.GetSV(index: WideString): WideString;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsString
else
raise Exception.Create('GetSV(' + index + ') Error, Query is not actived.');
end; // with
end;
function THMOleDataSet.GetValue(index: WideString): OleVariant;
begin
with (FParent as TDataSet) do
begin
if Active then
Result := FieldByName(index).AsVariant
else
raise Exception.Create('GetValue(' + index + ') Error, Query is not actived.');
end; // with
end;
procedure THMOleDataSet.SetDV(index: WideString; const Value: TDatetime);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsDateTime := Value
else
raise Exception.Create('SetDV(' + index + ') Error, Query is not actived.');
end; // with
end;
procedure THMOleDataSet.SetFV(index: WideString; const Value: Double);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsFloat := Value
else
raise Exception.Create('SetFV(' + index + ') Error, Query is not actived.');
end; // with
end;
procedure THMOleDataSet.SetIV(index: WideString; const Value: Integer);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsInteger := Value
else
raise Exception.Create('SetIV(' + index + ') Error, Query is not actived.');
end; // with
end;
procedure THMOleDataSet.SetSV(index: WideString; const Value: WideString);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsString := Value
else
raise Exception.Create('SetSV(' + index + ') Error, ' + Name + ' is not actived.');
end; // with
end;
procedure THMOleDataSet.SetValue(index: WideString; const Value: OleVariant);
begin
with (FParent as TDataSet) do
begin
if Active then
FieldByName(index).AsVariant := Value
else
raise Exception.Create('SetValue(' + index + ') Error, ' + Name + ' is not actived.');
end; // with
end;
function THMOleDataSet.NotEmpty: Boolean;
begin
with (FParent as TDataSet) do
begin
if Active then
begin
if RecordCount > 0 then
Result := True
else
Result := False;
end
else
Result := False;
end; // with
end;
procedure THMOleDataSet.Close;
begin
with (FParent as TDataSet) do
begin
Close;
end; // with
end;
function THMOleDataSet.GetActive: Boolean;
begin
with (FParent as TDataSet) do
begin
Result := Active;
end; // with
end;
procedure THMOleDataSet.Open;
begin
(FParent as TDataSet).Open;
end;
procedure THMOleDataSet.SetActive(const Value: Boolean);
begin
(FParent as TDataSet).Active := Value;
end;
function THMOleDataSet.GetRecordCount: Integer;
begin
with (FParent as TDataSet) do
begin
if Active then
begin
Result := RecordCount;
end
else
raise Exception.Create('GetRecordCount Error,' + Name + ' is not actived.');
end; // with
end;
function THMOleDataSet.Locate(KeyField: WideString; KeyValue: OleVariant): Boolean;
begin
with (FParent as TDataSet) do
begin
if Active then
begin
Result := Locate(KeyField, KeyValue, []);
end
else
raise Exception.Create('Locate Error, ' + Name + ' is not actived.');
end; // with
end;
procedure THMOleDataSet.First;
begin
(FParent as TDataSet).First;
end;
procedure THMOleDataSet.Last;
begin
(FParent as TDataSet).Last;
end;
procedure THMOleDataSet.Next;
begin
(FParent as TDataSet).Next;
end;
procedure THMOleDataSet.Prev;
begin
(FParent as TDataSet).Prior;
end;
function THMOleDataSet.IsNull(FieldName: WideString): Boolean;
begin
Result := (FParent as TDataSet).FieldByName(FieldName).IsNull;
end;
procedure THMOleDataSet.Append;
begin
(FParent as TDataSet).Append;
end;
procedure THMOleDataSet.Edit;
begin
(FParent as TDataSet).Edit;
end;
procedure THMOleDataSet.Post;
begin
(FParent as TDataSet).Post;
end;
function THMOleDataSet.GetUpdateStatus: TUpdateStatus;
begin
Result := (FParent as TDataSet).UpdateStatus;
end;
function THMOleDataSet.Bof: Boolean;
begin
Result := (FParent as TDataSet).Bof;
end;
function THMOleDataSet.Eof: Boolean;
begin
Result := (FParent as TDataSet).Eof;
end;
{ THMCustomOleADOQuery }
procedure THMCustomOleADOQuery.LoadSql(Sql: WideString);
begin
end;
procedure THMCustomOleADOQuery.LoadSqlAndOpen(Sql: WideString);
begin
end;
{ THMCustomOleClientDataSet }
(*----------------------------------------------------------------------------
Procedure : THMCustomOleClientDataSet.LoadData
Designed By: Aleyn.wu
Create Date: 2002 - 11 - 07
Update Date: 2002 - 11 - 07
Arguments : None
Result : None
Comment : Load Data with Default Action
----------------------------------------------------------------------------*)
procedure THMCustomOleClientDataSet.LoadData;
begin
end;
(*----------------------------------------------------------------------------
Procedure : THMCustomOleClientDataSet.LoadDataEx
Designed By: Aleyn.wu
Create Date: 2002 - 11 - 07
Update Date: 2002 - 11 - 07
Arguments : var Data: OleVariant
Result : None
Comment : Load Data From Custom Data
----------------------------------------------------------------------------*)
procedure THMCustomOleClientDataSet.LoadDataEx(var Data: OleVariant);
begin
end;
(*----------------------------------------------------------------------------
Procedure : THMCustomOleClientDataSet.LoadOleData
Designed By: Aleyn.wu
Create Date: 2002 - 11 - 07
Update Date: 2002 - 11 - 07
Arguments : Name: Widestring
Result : None
Comment : Load Data From THMOleVariant(OLE) Value
----------------------------------------------------------------------------*)
procedure THMCustomOleClientDataSet.LoadOleData(Name: Widestring);
begin
end;
(*----------------------------------------------------------------------------
Procedure : THMCustomOleClientDataSet.GetData,SetData
Designed By: Aleyn.wu
Create Date: 2002 - 11 - 08
Update Date: 2002 - 11 - 08
Arguments : None
Result : OleVariant
Comment :
----------------------------------------------------------------------------*)
function THMCustomOleClientDataSet.GetData: OleVariant;
begin
end;
procedure THMCustomOleClientDataSet.SetData(Value: OleVariant);
begin
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -