Advertisement
zoltanleo

Untitled

May 4th, 2023
1,472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.97 KB | None | 0 0
  1. type
  2.   TRoamingRecType = (rrtSelected, rrtAll);
  3.  
  4. procedure TForm1.MoveSelectedRows(GridSource, GridDestin: TDBGridEh; RoamingRec: TRoamingRecType);
  5. var
  6.   i, j: Integer;
  7. begin
  8.   if TDBGridEh(GridSource).DataSource.DataSet.IsEmpty then Exit;
  9.  
  10.   try
  11.     TDBGridEh(GridSource).DataSource.DataSet.DisableControls;
  12.     TDBGridEh(GridDestin).DataSource.DataSet.DisableControls;
  13.  
  14.     case RoamingRec of
  15.       rrtSelected:
  16.         begin
  17.           TDBGridEh(GridSource).SaveBookmark;
  18.           for i := 0 to TDBGridEh(GridSource).SelectedRows.Count - 1 do
  19.           begin
  20.             TDBGridEh(GridSource).DataSource.DataSet.Bookmark := TDBGridEh(GridSource).SelectedRows[i];
  21.             TDBGridEh(GridDestin).DataSource.DataSet.Append;
  22.             TDBGridEh(GridDestin).DataSource.DataSet.Edit;
  23.  
  24.             for j := 0 to Pred(TDBGridEh(GridDestin).DataSource.DataSet.FieldCount) do
  25.               TDBGridEh(GridDestin).DataSource.DataSet.Fields[j].Value := TDBGridEh(GridSource).DataSource.DataSet.Fields[j].Value;
  26.             TDBGridEh(GridDestin).DataSource.DataSet.Post;
  27.             TDBGridEh(GridSource).DataSource.DataSet.Delete;
  28.           end;
  29.  
  30.           TDBGridEh(GridSource).RestoreBookmark;
  31.         end;
  32.       rrtAll:
  33.         begin
  34.           for i := 0 to Pred(TDBGridEh(GridSource).DataSource.DataSet.RecordCount) do
  35.           begin
  36.             TDBGridEh(GridDestin).DataSource.DataSet.Append;
  37.             TDBGridEh(GridDestin).DataSource.DataSet.Edit;
  38.  
  39.             for j := 0 to TDBGridEh(GridDestin).DataSource.DataSet.FieldCount - 1 do
  40.               TDBGridEh(GridDestin).DataSource.DataSet.Fields[j].Value := TDBGridEh(GridSource).DataSource.DataSet.Fields[j].Value;
  41.             TDBGridEh(GridDestin).DataSource.DataSet.Post;
  42.             TDBGridEh(GridSource).DataSource.DataSet.Delete;
  43.           end;
  44.         end;
  45.     end;
  46.   finally
  47.     TDBGridEh(GridDestin).DataSource.DataSet.EnableControls;
  48.     TDBGridEh(GridSource).DataSource.DataSet.EnableControls;
  49.   end;
  50. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement