D
dyxfkj
Unregistered / Unconfirmed
GUEST, unregistred user!
unit UntBasic;
interface
Uses
Classes, Controls, ComCtrls, StdCtrls,
SysUtils, ExtCtrls, DB, Dialogs;
type
TcyEdit = Class(TEdit)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyDateTimePicker = Class(TDateTimePicker)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyCombobox = Class(TCombobox)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyPanel = Class(TPanel)
private
fTableName: String;
fDataset: TDataSet;
FieldList: TStringList;
ValueList: TStringList;
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
Procedure GetFieldInfo;
Procedure SaveData;
Procedure UpdateData;
published
Property TableName: String Read fTableName Write fTableName;
Property DataSet: TDataSet Read fDataSet Write fDataSet;
end;
implementation
{ TcyPanel }
constructor TcyPanel.Create(AOwner: TComponent);
begin
inherited;
FieldList := TStringList.Create;
ValueList := TStringList.Create;
end;
destructor TcyPanel.Destroy;
begin
FieldList.free;
ValueList.Free;
inherited;
end;
procedure TcyPanel.GetFieldInfo;
var
i: Integer;
begin
if self.ComponentCount > 0 then
ShowMessage('aa'); ************问题: 为何我在cyPanel中的cyEdit , 用以下这种方式取不到呢?
for i := 0 to Self.ComponentCount - 1 do
begin
if (Self.Components is TcyEdit) then
begin
FieldList.Add(TcyEdit(Self.Components).fFieldName);
ValueList.Add(Trim(TcyEdit(Self.Components).Text));
end else
if (Self.Components is TcyDateTimePicker) then
begin
FieldList.Add(TcyEdit(Components).fFieldName);
ValueList.Add(FormatDateTime('yyyy-mm-dd', TcyDateTimePicker(Components).DateTime))
end else
if (Components is TcyDateTimePicker) then
begin
FieldList.Add(TcyCombobox(Components).fFieldName);
ValueList.Add(Trim(TcyCombobox(Components).Text));
end;
end;
end;
procedure TcyPanel.SaveData;
var
i: Integer;
SQLStr: String;
begin
GetFieldInfo;
for i := 0 to FieldList.Count - 1 do
begin
SQLStr := SQLStr + FieldList;
end;
end;
procedure TcyPanel.UpdateData;
begin
end;
end.
interface
Uses
Classes, Controls, ComCtrls, StdCtrls,
SysUtils, ExtCtrls, DB, Dialogs;
type
TcyEdit = Class(TEdit)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyDateTimePicker = Class(TDateTimePicker)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyCombobox = Class(TCombobox)
private
fFieldName: String;
protected
public
published
Property FieldName: String Read fFieldName Write fFieldName;
end;
TcyPanel = Class(TPanel)
private
fTableName: String;
fDataset: TDataSet;
FieldList: TStringList;
ValueList: TStringList;
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
Procedure GetFieldInfo;
Procedure SaveData;
Procedure UpdateData;
published
Property TableName: String Read fTableName Write fTableName;
Property DataSet: TDataSet Read fDataSet Write fDataSet;
end;
implementation
{ TcyPanel }
constructor TcyPanel.Create(AOwner: TComponent);
begin
inherited;
FieldList := TStringList.Create;
ValueList := TStringList.Create;
end;
destructor TcyPanel.Destroy;
begin
FieldList.free;
ValueList.Free;
inherited;
end;
procedure TcyPanel.GetFieldInfo;
var
i: Integer;
begin
if self.ComponentCount > 0 then
ShowMessage('aa'); ************问题: 为何我在cyPanel中的cyEdit , 用以下这种方式取不到呢?
for i := 0 to Self.ComponentCount - 1 do
begin
if (Self.Components is TcyEdit) then
begin
FieldList.Add(TcyEdit(Self.Components).fFieldName);
ValueList.Add(Trim(TcyEdit(Self.Components).Text));
end else
if (Self.Components is TcyDateTimePicker) then
begin
FieldList.Add(TcyEdit(Components).fFieldName);
ValueList.Add(FormatDateTime('yyyy-mm-dd', TcyDateTimePicker(Components).DateTime))
end else
if (Components is TcyDateTimePicker) then
begin
FieldList.Add(TcyCombobox(Components).fFieldName);
ValueList.Add(Trim(TcyCombobox(Components).Text));
end;
end;
end;
procedure TcyPanel.SaveData;
var
i: Integer;
SQLStr: String;
begin
GetFieldInfo;
for i := 0 to FieldList.Count - 1 do
begin
SQLStr := SQLStr + FieldList;
end;
end;
procedure TcyPanel.UpdateData;
begin
end;
end.