procedure Terp.th(component:string;form:string); var clpbrd:TClipBoard; begin clpbrd:=TClipBoard.Create; with application.FindComponent(form) as tform do begin with tdbgrideh(FindComponent(component)) do begin with DataSource.DataSet do begin Book:=Selection.rect.TopRow; while True do begin Edit; fieldbyname(SelectedField.FieldName).value:=clpbrd.AsText; Post; if CompareBooks(Pointer(Selection.Rect.BottomRow),Pointer(Book)) = 0 then Break; Next; if Eof then Break; end; end; end; end; end; erp.th(ActiveControl.Name,'sspbm');
var clpbrd:TClipBoard;
begin
clpbrd:=TClipBoard.Create;
with application.FindComponent(form) as tform do
begin
with tdbgrideh(FindComponent(component)) do
begin
with DataSource.DataSet do
begin
Book:=Selection.rect.TopRow;
while True do begin
Edit;
fieldbyname(SelectedField.FieldName).value:=clpbrd.AsText;
Post;
if CompareBooks(Pointer(Selection.Rect.BottomRow),Pointer(Book)) = 0 then Break;
Next;
if Eof then Break;
end;
end;
end;
end;
end;
erp.th(ActiveControl.Name,'sspbm');
将adoquery1的locktype 设为 :ltBatchOptimistic这样保存的时候这样写就可以避免直接保存的问题了。 try
adoquery1.State in [dsinsert,dsedit] then adoquery1.Post;
adoquery1.UpdateBatch();
except
raise;
end;
UpdateBatch把内存中修改的记录一并提交到数据库