关于TDBCombox(50分)

  • 主题发起人 主题发起人 carnation
  • 开始时间 开始时间
C

carnation

Unregistered / Unconfirmed
GUEST, unregistred user!
是否有一个控件,可以完成如下功能:
当数据库中某一字段的值为1时,显示a
2时, b
(做成下拉菜单的形式)
就像TDBCombox一样,但TDBCombox好象不能不能完成转换
我记得在Power Builder中很容易实现


 
ombobox1.Items.AddObject('a', TObject(1));
 
我的意思是在数据库中存1,显示成a;在数据库中存2,显示成b
 
我用了上面这局话,结果在数据库中存入了a,而不是1
 
with Combobox1 do
begin
ShowMessage(IntToStr(Integer(Items.Objects[Items.IndexOf(Text)])));
end;

这下看懂了吧
 
你还是没有搞清我的意思 or 我说的还是不太清楚:
我的意思是:是否有这样一个控件,(最好是下拉式的)它与数据库中的某一字段相联系,
(这一字段经常是数值),并根据字段的值显示不同的内容。(通常是字符串)
同样,当在控件中显示了字符串时,会将相应的数值存入数据库。
在功能上很像DBCombox,但是DBCombox显示什么就存什么。
我说清楚了吗?
 
你还是找一个第三方的控件吧,也省得花力气自己写啦
祝你好运气.

[我从不用数据感知控件(除了偶尔显示数据用),
也从不用什么POST,APPLYUPDATE之类的东东]
 
不知道你是如何显示和输入数据的?自己写?
如果是自己写,有什么好处?
 
直接操纵SQL
 
不知道你是如何显示和输入数据的?自己写?
---贴一段正在写的代码看看.
{
*****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;
.................................
.................................

如果是自己写,有什么好处?
----自己体会体会吧.
 
我不知道直接控制SQL有什么好处?有更大的自由度?
不过我现在的工作不需要直接控制SQL,我只要对数据进行简单的控制就可以了。
所以我需要一个控件!
不知有人有现成的吗?
 
唉,笑傲江湖的长篇是不是把大家都吓跑了,其实我的要求不算高吧
 
carnation:如果你还要继续讨论请定期提前你的帖子,如果不想继续讨论请结束帖子。
请认真阅读大富翁论坛规则说明 http://www.delphibbs.com/delphibbs/rules.htm
 
老猫我帮你结束吧。
 
咦,怎么变成只能删除了,COW!
 
后退
顶部