Subject ReadOnly fields, which the best method?
Author Paulo Henrique Albanez
Which is of the methods below better?

1)
procedure TFormSC01.SourceItensDataChange(Sender: TIB_StatementLink;
Statement: TIB_Statement; Field: TIB_Column);
begin
inherited;
if (DatMod.Itens.Prepared) and ((Field = Nil) or (Field = DatMod.ItensSMCodigo)) then begin

lEstCodReadOnly := (DatMod.ItensSMCodigo.AsInteger > 0);
if lEstCodReadOnly <> DatMod.ItensEstCodigo.PreventEditing then begin

try
DatMod.Itens.FieldsReadOnly.BeginUpdate;
DatMod.ItensEstCodigo.PreventEditing := lEstCodReadOnly;
DatMod.ItensEstCodigo.PreventInserting := lEstCodReadOnly;
DatMod.ItensEstComplem.PreventEditing := lEstCodReadOnly;
DatMod.ItensEstComplem.PreventInserting := lEstCodReadOnly;
finally
DatMod.Itens.FieldsReadOnly.EndUpdate;
end;

end;
end;
end;

2)
procedure TFormSC01.SourceItensDataChange(Sender: TIB_StatementLink;
Statement: TIB_Statement; Field: TIB_Column);
begin
inherited;
if (DatMod.Itens.Prepared) and ((Field = Nil) or (Field = DatMod.ItensSMCodigo)) then begin

lEstCodReadOnly := (DatMod.ItensSMCodigo.AsInteger > 0);
if lEstCodReadOnly <> DatMod.ItensEstCodigo.ForceControlsReadOnly then begin
DatMod.ItensEstCodigo.ForceControlsReadOnly := lEstCodReadOnly;
DatMod.ItensEstComplem.ForceControlsReadOnly := lEstCodReadOnly;
end;

end;
end;


PHA
Nova Odessa / SP - Brazil



[Non-text portions of this message have been removed]