不知道你是如何显示和输入数据的?自己写?
---贴一段正在写的代码看看.
{
*****ComQyery platform class library*****
TObj
--TCQObj
--TCQCustomObj
--TCQIDObj
--TCQDispIndexableObj
--TCQLinkObj
--TCQDataSetLink
--TCQIndependentObj
--TCQHasParentIDObj
--TCQDSGroup
--TCQQryApp
--TCQDataSet
--TCQField
--TCQParam
--TCQDispPattern
--TCQDispMode
--TCQDisplayableObj
--TCQQryPage
--TCQQryUnit
--TCQQryCell
--TCQFields
--TCQParams
--TCQDetailDataSets
--TCQFieldLinks
--TCQVirtualNode
}
unit CQPersistents;
interface
uses
Sysutils, Classes, ComCtrls, Db, CQCallDBs, CQDBUtils;
type
{ComQuery platform root class}
TCQObjClass = class of TCQObj;
TCQObj = class;
{Add access database data member, derived from TCQObj}
TCQCustomObj = class;
{Add CQID data member, derived from TCQCustomObj}
TCQIDObj = class;
{Add CQDispIndex data member, derived from TCQIDObj}
TCQDispIndexableObj = class;
{Derived from TCQDispIndexableObj}
TCQLinkObj = class;
{Add CQName, CQCode, CQNote data members, derived from TCQDispIndexableObj}
TCQIndependentObj = class;
{Add CQParID, Derived from TCQIndependentObj}
TCQHasParentIDObj = class;
{Add CQX, CQY, CQWidth, CQHeight, CQFontName, CQFontSize, CQFontSize,
CQVisible, CQColor data members, derived from TCQIndependentObj}
TCQDisplayableObj = class;
{Derived from TCQHasParentIDObj}
TCQDSGroup = class;
{Add CQSql data member, derived from TCQIndependentObj}
TCQDataSet = class;
{Add CQType, CQLength, CQScale, CQDataSetID data members,
derived from TCQIndependentObj}
TCQField = class;
{Add CQTitle, CQFieldType, CQDefaValue, CQIgnorable, CQDispModeID,
CQDataSetID data members, derived from TCQIndependentObj}
TCQParam = class;
{Derived from TCQHasParentIDObj}
TCQQryApp = class;
{Add CQQryAppID, derived from TCQDisplayableObj}
TCQQryPage = class;
{Add CQQryPageID, CQDataSetID, CQDispPatternID data members, derived form TCQDisplayableObj}
TCQQryUnit = class;
{Add CQQryUnitID, CQDispModeID, derived from TCQDisplayableObj}
TCQQryCell = class;
{Add CQDisplay data member, derived from TCQIndependentObj}
TCQDispPattern = class;
{Add CQDisplay, CQDisplayDef data members, derived from TCQIndependentObj}
TCQDispMode = class;
{Add CQDSGroupID, CQDataSetID, data members, derived from TCQLinkObj}
//TCQDsgDsLink = class;
{Add CQQryAppID, CQDataSetID data members, derived from TCQLinkObj}
//TCQQryAppDsLink = class;
{Add CQMasterDataSetID, CQDetailDataSetID, CQMasterFieldID, CQDetailFieldID
data members, derived from TCQLinkObj}
TCQDataSetLink = class;
//TCQFieldLink = class;
{Used to organize fiels which are contained by dataset Object, It's just a group Object}
TCQFields = class(TObject) end;
{Used to organize params which are contained by dataset Object, It's just a group Object}
TCQParams = class(TObject) end;
{Used to organize detail datasets which are contained by dataset Object, It's just a group Object}
TCQDetailDataSets = class(TObject) end;
{Used to organize datasets which are referred by QryApp Object, It's just a group Object}
//TCQFieldLinks = class(TObject) end;
{Virtual Node Linked Object}
TCQVirtualNode = class(TObject) end;
TCQObj = class(TObject)
public
constructor Create; overload; virtual;
destructor Destroy; override;
procedure Assign(Source: TCQObj); virtual;
procedure LoadFromDataSet; virtual;
procedure SelectByID(AID: Integer); virtual;
procedure DbInsert; virtual;
procedure DbUpdate; virtual;
procedure DbDelete; virtual;
procedure UpdateListItem(AItem: TListItem); virtual;
procedure UpdateTreeNode(ANode: TTreeNode); virtual;
function Clone: TCQObj; virtual;
function Duplicate: TCQObj; virtual;
function Equals(AObj: TCQObj): Boolean; virtual;
end;
TCQCustomObj = class(TCQObj)
protected
FCQCallDB: TCQCallDB;
public
constructor Create; override;
destructor Destroy; override;
property CQCallDB: TCQCallDB read FCQCallDB write FCQCallDB;
end;
TCQIDObj = class(TCQCustomObj)
protected
FCQID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQID: Integer read FCQID write FCQID;
end;
TCQDispIndexableObj = class(TCQIDObj)
protected
FCQDispIndex: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQDispIndex: Integer read FCQDispIndex write FCQDispIndex;
end;
TCQLinkObj = class(TCQDispIndexableObj);
TCQIndependentObj = class(TCQDispIndexableObj)
protected
FCQName: string;
FCQCode: string;
FCQNote: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
property CQName: string read FCQName write FCQName;
property CQCode: string read FCQCode write FCQCode;
property CQNote: string read FCQNote write FCQNote;
end;
TCQHasParentIDObj = class(TCQIndependentObj)
protected
FCQParID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQParID: Integer read FCQParID write FCQParID;
end;
TCQDisplayableObj = class(TCQIndependentObj)
protected
FCQX: Integer;
FCQY: Integer;
FCQWidth: Integer;
FCQHeight: Integer;
FCQFontName: string;
FCQFontSize: Integer;
FCQFontStyle: string;
FCQColor: string;
FCQVisible: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
property CQX: Integer read FCQX write FCQX;
property CQY: Integer read FCQY write FCQY;
property CQWidth: Integer read FCQWidth write FCQWidth;
property CQHeight: Integer read FCQHeight write FCQHeight;
property CQFontName: string read FCQFontName write FCQFontName;
property CQFontSize: Integer read FCQFontSize write FCQFontSize;
property CQFontStyle: string read FCQFontStyle write FCQFontStyle;
property CQColor: string read FCQColor write FCQColor;
property CQVisible: string read FCQVisible write FCQVisible;
end;
TCQDsGroup = class(TCQHasParentIDObj)
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
end;
TCQDataSet = class(TCQIndependentObj)
private
FCQSql: string;
FCQDsGroupID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQSql: string read FCQSql write FCQSql;
property CQDsGroupID: Integer read FCQDsGroupID write FCQDsGroupID;
end;
TCQField = class(TCQIndependentObj)
private
FCQType: string;
FCQLength: Integer;
FCQScale: Integer;
FCQDataSetID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQType: string read FCQType write FCQType;
property CQLength: Integer read FCQLength write FCQLength;
property CQScale: Integer read FCQScale write FCQScale;
property CQDataSetID: Integer read FCQDataSetID write FCQDataSetID;
end;
TCQParam = class(TCQIndependentObj)
private
FCQTitle: string;
FCQFieldType: string;
FCQDefaValue: string;
FCQIgnorable: string;
FCQDataSource: string;
FCQDispModeID: Integer;
FCQDataSetID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQTitle: string read FCQTitle write FCQTitle;
property CQFieldType: string read FCQFieldType write FCQFieldType;
property CQDefaValue: string read FCQDefaValue write FCQDefaValue;
property CQIgnorable: string read FCQIgnorable write FCQIgnorable;
property CQDataSource: string read FCQDataSource write FCQDataSource;
property CQDispModeID: Integer read FCQDispModeID write FCQDispModeID;
property CQDataSetID: Integer read FCQDataSetID write FCQDataSetID;
end;
TCQQryApp = class(TCQHasParentIDObj)
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
end;
TCQQryPage = class(TCQDisplayableObj)
private
FCQQryAppID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQQryAppID: Integer read FCQQryAppID write FCQQryAppID;
end;
TCQQryUnit = class(TCQDisplayableObj)
private
FCQQryPageID: Integer;
FCQDataSetID: Integer;
FCQDispPatternID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQQryPageID: Integer read FCQQryPageID write FCQQryPageID;
property CQDataSetID: Integer read FCQDataSetID write FCQDataSetID;
property CQDispPatternID: Integer read FCQDispPatternID write FCQDispPatternID;
end;
TCQQryCell = class(TCQDisplayableObj)
private
FCQFieldName: string;
FCQFieldType: string;
FCQIsX: string;
FCQQryUnitID: Integer;
FCQDispModeID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQFieldName: string read FCQFieldName write FCQFieldName;
property CQFieldType: string read FCQFieldType write FCQFieldType;
property CQIsX: string read FCQIsX write FCQIsX;
property CQQryUnitID: Integer read FCQQryUnitID write FCQQryUnitID;
property CQDispModeID: Integer read FCQDispModeID write FCQDispModeID;
end;
TCQDispPattern = class(TCQIndependentObj)
private
FCQDisplay: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQDisplay: string read FCQDisplay write FCQDisplay;
end;
TCQDispMode = class(TCQIndependentObj)
private
FCQDisplay: string;
FCQDisplayDef: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
function GetDataStrings(AStrings: TStrings): Integer;//only it has
property CQDisplay: string read FCQDisplay write FCQDisplay;
property CQDisplayDef: string read FCQDisplayDef write FCQDisplayDef;
end;
{TCQDsgDsLink = class(TCQLinkObj)
private
FCQDsGroupID: Integer;
FCQDataSetID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(Item: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQDsGroupID: Integer read FCQDsGroupID write FCQDsGroupID;
property CQDataSetID: Integer read FCQDataSetID write FCQDataSetID;
end; }
{TCQQryAppDsLink = class(TCQLinkObj)
private
FCQQryAppID: Integer;
FCQDataSetID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(Item: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQQryAppID: Integer read FCQQryAppID write FCQQryAppID;
property CQDataSetID: Integer read FCQDataSetID write FCQDataSetID;
end; }
TCQDataSetLink = class(TCQLinkObj)
private
FCQMasterDataSetID: Integer;
FCQDetailDataSetID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQMasterDataSetID: Integer read FCQMasterDataSetID write FCQMasterDataSetID;
property CQDetailDataSetID: Integer read FCQDetailDataSetID write FCQDetailDataSetID;
end;
{TCQFieldLink = class(TCQLinkObj)
private
FCQMasterFieldID: Integer;
FCQDetailFieldID: Integer;
FCQDataSetLinkID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(AItem: TListItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
property CQMasterFieldID: Integer read FCQMasterFieldID write FCQMasterFieldID;
property CQDetailFieldID: Integer read FCQDetailFieldID write FCQDetailFieldID;
property CQDataSetLinkID: Integer read FCQDataSetLinkID write FCQDataSetLinkID;
end;}
{参数录入方式需要REF/INST选择}
TCQRefInst = class(TCQDispIndexableObj)
private
FCQInstID: Integer;
FCQClsID: Integer;
FCQInstName: string;
FCQParRefID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
property CQInstID: Integer read FCQInstID write FCQInstID;
property CQClsID: Integer read FCQClsID write FCQClsID;
property CQInstName: string read FCQInstName write FCQInstName;
property CQParRefID: Integer read FCQParRefID write FCQParRefID;
end;
{------------------------------------------------------------------------------}
implementation
{------------------------------------------------------------------------------}
uses
CQUtils;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ TCQObj }
{------------------------------------------------------------------------------}
{forward declaration is...
TCQObj = class(TObject)
public
constructor Create; overload; virtual;
destructor Destroy; override;
procedure Assign(Source: TCQObj); virtual;
procedure LoadFromDataSet; virtual;
procedure SelectByID(AID: Integer); virtual;
procedure DbInsert; virtual;
procedure DbUpdate; virtual;
procedure DbDelete; virtual;
procedure UpdateListItem(Item: TListItem); virtual;
procedure UpdateTreeNode(ANode: TTreeNode); virtual;
function Clone: TCQObj; virtual;
function Duplicate: TCQObj; virtual;
function Equals(AObj: TCQObj): Boolean; virtual;
end;
}
constructor TCQObj.Create;
begin
inherited Create;
end;
destructor TCQObj.Destroy;
begin
inherited;
end;
procedure TCQObj.Assign(Source: TCQObj);
begin
end;
procedure TCQObj.LoadFromDataSet;
begin
end;
function TCQObj.Equals(AObj: TCQObj): Boolean;
begin
Result := False;
end;
procedure TCQObj.SelectByID(AID: Integer);
begin
end;
procedure TCQObj.DbInsert;
begin
end;
procedure TCQObj.DbUpdate;
begin
end;
procedure TCQObj.DbDelete;
begin
end;
procedure TCQObj.UpdateListItem(AItem: TListItem);
begin
end;
procedure TCQObj.UpdateTreeNode(ANode: TTreeNode);
begin
end;
function TCQObj.Clone: TCQObj;
begin
Result := nil;
end;
function TCQObj.Duplicate: TCQObj;
begin
Result := nil;
end;
{------------------------------------------------------------------------------}
{ TCQCustomObj }
{------------------------------------------------------------------------------}
{forward declaration is ...
TCQCustomObj = class(TCQObj)
protected
FCQCallDB: TCQCallDB;
public
constructor Create; override;
destructor Destroy; override;
property CQCallDB: TCQCallDB read FCQCallDB write FCQCallDB;
end;
}
constructor TCQCustomObj.Create;
begin
inherited Create;
FCQCallDB := TCQDOACallDB.Create;
end;
destructor TCQCustomObj.Destroy;
begin
FCQCallDB.Free;
inherited;
end;
{------------------------------------------------------------------------------}
{ TCQIDObj }
{------------------------------------------------------------------------------}
{forward declaration is ...
TCQIDObj = class(TCQCustomObj)
protected
FCQID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQID: Integer read FCQID write FCQID;
end;
}
constructor TCQIDObj.Create;
begin
inherited Create;
FCQID := -1;
end;
destructor TCQIDObj.Destroy;
begin
inherited;
end;
procedure TCQIDObj.Assign(Source: TCQObj);
begin
Assert(Source is TCQIDObj);
inherited;
FCQID := TCQIDObj(Source).CQID;
end;
{------------------------------------------------------------------------------}
{ TCQDispIndexableObj }
{------------------------------------------------------------------------------}
{forward declation is ...
TCQDispIndexableObj = class(TCQIDObj)
protected
FCQDispIndex: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQDispIndex: Integer read FCQDispIndex write FCQDispIndex;
end;
}
constructor TCQDispIndexableObj.Create;
begin
inherited Create;
FCQDispIndex:= -1;
end;
destructor TCQDispIndexableObj.Destroy;
begin
inherited;
end;
procedure TCQDispIndexableObj.Assign(Source: TCQObj);
begin
Assert(Source is TCQDispIndexableObj);
inherited;
FCQDispIndex := TCQDispIndexableObj(Source).CQDispIndex;
end;
{------------------------------------------------------------------------------}
{ TCQLinkObj }
{------------------------------------------------------------------------------}
{TCQLinkObj = class(TCQDispIndexableObj) end; }
{------------------------------------------------------------------------------}
{ TCQIndependentObj }
{------------------------------------------------------------------------------}
{forward declaration is ...
TCQIndependentObj = class(TCQDispIndexableObj)
protected
FCQName: string;
FCQCode: string;
FCQNote: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(Item: TTreeItem); override;
procedure UpdateTreeNode(ANode: TTreeNode); override;
property CQName: string read FCQName write FCQName;
property CQCode: string read FCQCode write FCQCode;
property CQNote: string read FCQNote write FCQNote;
end;
}
constructor TCQIndependentObj.Create;
begin
inherited Create;
FCQName := '';
FCQCode := '';
FCQNote := '';
end;
destructor TCQIndependentObj.Destroy;
begin
inherited;
end;
procedure TCQIndependentObj.Assign(Source: TCQObj);
begin
Assert(Source is TCQIndependentObj);
inherited;
FCQName := TCQIndependentObj(Source).CQName;
FCQCode := TCQIndependentObj(Source).CQCode;
FCQNote := TCQIndependentObj(Source).CQNote;
end;
procedure TCQIndependentObj.UpdateListItem(AItem: TListItem);
begin
with AItem do
begin
Caption := FCQName;
Data := Self;
with SubItems do
begin
Clear;
//Add(FCQCode);
end;
end;
end;
procedure TCQIndependentObj.UpdateTreeNode(ANode: TTreeNode);
begin
with ANode do
begin
Data := Self;
Text := FCQName;
end;
end;
{------------------------------------------------------------------------------}
{ TCQHasParentIDObj }
{------------------------------------------------------------------------------}
{forward declaration is ...
TCQHasParentIDObj = class(TCQIndependentObj)
protected
FCQParID: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
property CQParID: Integer read FCQParID write FCQParID;
end;
}
constructor TCQHasParentIDObj.Create;
begin
inherited;
FCQParID := -1;
end;
destructor TCQHasParentIDObj.Destroy;
begin
inherited;
end;
procedure TCQHasParentIDObj.Assign(Source: TCQObj);
begin
Assert(Source is TCQHasParentIDObj);
inherited;
FCQParID := TCQHasParentIDObj(Source).CQParID;
end;
{------------------------------------------------------------------------------}
{ TCQDisplayableObj }
{------------------------------------------------------------------------------}
{forward declaration is ...
TCQDisplayableObj = class(TCQIndependentObj)
protected
FCQX: Integer;
FCQY: Integer;
FCQWidth: Integer;
FCQHeight: Integer;
FCQFontName: string;
FCQFontSize: Integer;
FCQFontStyle: Integer;
FCQColor: Integer;
FCQVisible: string;
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(Item: TTreeItem); override;
property CQX: Integer read FCQX write FCQX;
property CQY: Integer read FCQY write FCQY;
property CQWidth: Integer read FCQWidth write FCQWidth;
property CQHeight: Integer read FCQHeight write FCQHeight;
property CQFontName: string read FCQFontName write FCQFontName;
property CQFontSize: Integer read FCQFontSize write FCQFontSize;
property CQFontStyle: Integer read FCQFontStyle write FCQFontStyle;
property CQColor: Integer read FCQColor write FCQColor;
property CQVisible: string read FCQVisible write FCQVisible;
end;
}
constructor TCQDisplayableObj.Create;
begin
inherited Create;
FCQX := 0;
FCQY := 0;
FCQWidth := 0;
FCQHeight := 0;
FCQFontName := '宋体';
FCQFontSize := 9;
FCQFontStyle := '';
FCQColor := '';
FCQVisible := 'T';
end;
destructor TCQDisplayableObj.Destroy;
begin
inherited;
end;
procedure TCQDisplayableObj.Assign(Source: TCQObj);
begin
Assert(Source is TCQDisplayableObj);
inherited;
FCQX := TCQDisplayableObj(Source).CQX;
FCQY := TCQDisplayableObj(Source).CQY;
FCQWidth := TCQDisplayableObj(Source).CQWidth;
FCQHeight := TCQDisplayableObj(Source).CQHeight;
FCQFontName := TCQDisplayableObj(Source).CQFontName;
FCQFontSize := TCQDisplayableObj(Source).CQFontSize;
FCQFontStyle := TCQDisplayableObj(Source).CQFontStyle;
FCQColor := TCQDisplayableObj(Source).CQColor;
FCQVisible := TCQDisplayableObj(Source).CQVisible;
end;
procedure TCQDisplayableObj.UpdateListItem(AItem: TListItem);
begin
inherited;
with AItem.SubItems do
begin
Add(IntToStr(FCQX));
Add(IntToStr(FCQY));
Add(IntToStr(FCQWidth));
Add(IntToStr(FCQHeight));
Add(FCQFontName);
Add(IntToStr(FCQFontSize));
Add(FCQFontStyle);
Add(FCQColor);
Add(FCQVisible);
end;
end;
procedure TCQDisplayableObj.UpdateTreeNode(ANode: TTreeNode);
begin
inherited;
if FCQVisible = 'F' then
begin
ANode.ImageIndex := 20;
ANode.SelectedIndex := 20;
end;
end;
{------------------------------------------------------------------------------}
{ TCQDsGroup }
{------------------------------------------------------------------------------}
{forward declaration is...
TCQDsGroup = class(TCQHasParentIDObj)
public
constructor Create; override;
destructor Destroy; override;
procedure Assign(Source: TCQObj); override;
procedure UpdateListItem(Item: TTreeItem); override;
procedure LoadFromDataSet; override;
procedure SelectByID(AID: Integer); override;
procedure DbInsert; override;
procedure DbUpdate; override;
procedure DbDelete; override;
function Clone: TCQObj; override;
function Duplicate: TCQObj; override;
function Equals(AObj: TCQObj): Boolean; override;
end;
}
constructor TCQDsGroup.Create;
begin
inherited;
end;
destructor TCQDsGroup.Destroy;
begin
inherited;
end;
procedure TCQDsGroup.Assign(Source: TCQObj);
begin
inherited;
end;
procedure TCQDsGroup.UpdateListItem(AItem: TListItem);
begin
inherited;
end;
procedure TCQDsGroup.LoadFromDataSet;
begin
Assert(FCQCallDB.DataSet.Active);
Assert(not ((FCQCallDB.DataSet.Eof) and (FCQCallDB.DataSet.Bof)));
with FCQCallDB.DataSet do
begin
FCQID := FieldByName('DSGROUP_ID').AsInteger;
FCQName := FieldByName('DSGROUP_NAME').AsString;
FCQNote := FieldByName('DSGROUP_NOTE').AsString;
FCQCode := FieldByName('DSGROUP_CODE').AsString;
FCQDispIndex := FieldByName('DSGROUP_DISPINDEX').AsInteger;
FCQParID := FieldByName('PARENT_DSGROUP_ID').AsInteger;
end;
end;
procedure TCQDsGroup.SelectByID(AID: Integer);
const
strSql = 'SELECT * FROM PMIS.COM_CQ_DSGROUP WHERE DSGROUP_ID = %D';
begin
Assert(not FCQCallDB.DataSet.Active);
with FCQCallDB do
begin
SqlOpen(Format(strSql, [AID]));
LoadFromDataSet;
SqlOpenEnd;
end;
end;
procedure TCQDsGroup.DbInsert;
const
strSql = 'INSERT INTO PMIS.COM_CQ_DSGROUP '
+ '(DSGROUP_ID,'
+ 'DSGROUP_NAME,'
+ 'DSGROUP_NOTE,'
+ 'DSGROUP_CODE,'
+ 'DSGROUP_DISPINDEX,'
+ 'PARENT_DSGROUP_ID)'
+ 'VALUES (%D, ''%S'', ''%S'', ''%S'', %D, %D)';
begin
Assert(not FCQCallDB.DataSet.Active);
with FCQCallDB do
begin
SqlExec(Format(strSql, [FCQID, FCQName, FCQNote, FCQCode, FCQDispIndex, FCQParID]));
SqlExecEnd;
end;
end;
procedure TCQDsGroup.DbUpdate;
const
strSql = 'UPDATE PMIS.COM_CQ_DSGROUP '
+ 'SET '
+ 'DSGROUP_NAME = ''%S'','
+ 'DSGROUP_NOTE = ''%S'','
+ 'DSGROUP_CODE = ''%S'','
+ 'DSGROUP_DISPINDEX = %D,'
+ 'PARENT_DSGROUP_ID = %D '
+ 'WHERE DSGROUP_ID = %D';
begin
Assert(not FCQCallDB.DataSet.Active);
with FCQCallDB do
begin
SqlExec(Format(strSql, [FCQName, FCQNote, FCQCode, FCQDispIndex, FCQParID, FCQID]));
SqlExecEnd;
end;
end;
procedure TCQDsGroup.DbDelete;
const
strSql = 'DELETE FROM PMIS.COM_CQ_DSGROUP WHERE DSGROUP_ID = %D';
begin
Assert(not FCQCallDB.DataSet.Active);
with FCQCallDB do
begin
SqlExec(Format(strSql, [FCQID]));
SqlExecEnd;
end;
end;
function TCQDsGroup.Clone: TCQObj;
begin
Result := TCQDsGroup.Create;
Result.Assign(Self);
end;
function TCQDsGroup.Duplicate: TCQObj;
begin
Result := TCQDsGroup.Create;
Result.Assign(Self);
TCQDsGroup(Result).CQID := CQGetNextDsGroupRecID;
end;
function TCQDsGroup.Equals(AObj: TCQObj): Boolean;
begin
Assert(AObj is TCQDsGroup);
Result := (FCQID = TCQDsGroup(AObj).CQID);
end;
.................................
.................................
如果是自己写,有什么好处?
----自己体会体会吧.