dByName(''Telephone'').AsString;
Result:=FTelephone;
end;
{显示编码}
procedure TPerson.ShowId;
var
IdCaption,Id:string;
begin
Id:=FTable.FieldByName(''Id'').AsString;
if FTable.TableName=C_tblStudent then
IdCaption:=''Student Id:''
else if FTable.TableName=C_tblTeacher then
IdCaption:=''Teacher Id:'';
ShowMessage(IdCaption+Id);
end;
{ TStudent }
{设置字段值}
procedure TStudent.BindFieldValues;
begin
inherited;
FTable.FieldByName(''TotalScore'').AsInteger:=FTotalScore;
end;
constructor TStudent.Create(AOwner: TComponent);
begin
inherited;
FTable.TableName:=C_tblStudent;
FTable.Active:=True;
end;
{定义字段属性}
function TStudent.GetTotalScore: integer;
begin
FTotalScore:=FTable.FieldByName(''TotalScore'').AsInteger;
Result := FTotalScore;
end;
{保存记录}
function TStudent.Post: boolean;
begin
FTable.Insert;
BindFieldValues;
Result:=Inherited Post;
end;
{ TTeacher }
{设置字段值}
procedure TTeacher.BindFieldValues;
begin
inherited;
FTable.FieldByName(''Subject'').AsString:=FSubject;
end;
constructor TTeacher.Create(AOwner: TComponent);
begin
inherited;
FTable.TableName:=C_tblTeacher;
FTable.Active:=True;
end;
{定义字段属性}
function TTeacher.GetSubject: string;
begin
FSubject:=FTable.FieldByName(''Subject'').AsString;
Result := FSubject;
end;
{保存记录}
function TTeacher.Post: boolean;
begin
FTable.Insert;
BindFieldValues;
Result:=Inherited Post;
end;
end.