Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 06-03-2020
Avatar de movorack
[movorack] movorack is offline
Miguel A. Valero
 
Registrado: feb 2007
Ubicación: Bogotá - Colombia
Posts: 1.346
Poder: 22
movorack Va camino a la famamovorack Va camino a la fama
Este código es originario del compañero [gatosoft], depronto te sirva

Código Delphi [-]
  TDatasetHelper = class helper for TDataSet
  Private
  Public
    procedure CopyCurrentRecord(DataSet: TDataset; IgnoreFieldNames: array of string); overload;
    procedure CopyCurrentRecord(DataSet: TDataset); overload;
    procedure CopyData(DataSet: TDataset; IgnoreFieldNames: array of string); overload;
    procedure CopyData(DataSet: TDataset); overload;  
  end;

procedure TDatasetHelper.CopyCurrentRecord(DataSet: TDataset);
begin
  CopyCurrentRecord(DataSet, []);
end;

procedure TDatasetHelper.CopyCurrentRecord(DataSet: TDataset;
  IgnoreFieldNames: array of string);
  function IgnoreField(FieldName: string): Boolean;
    var
      lFieldName : String;
  begin
    Result := False;
    for lFieldName in IgnoreFieldNames do
    begin
      Result := SameText(FieldName.Trim, lFieldName.trim);
      if Result then
        Break;
    end;
  end;
  var
    lField: TField;
begin
  if (not Dataset.Active) or Dataset.IsEmpty then
    Exit;

  if not (Self.State in [dsEdit, dsInsert]) then
    if Self.IsEmpty then
      Self.Append
    else
      Self.Edit;

  for lField in Self.Fields do
  begin
    if IgnoreField(lField.FieldName) then
      Continue;

    if not Assigned(DataSet.FindField(lField.FieldName)) then
      Continue;

    if lField.IsBlob then
    begin
      try
        //Se intenta realizar la copia
        lField.AsBytes := DataSet.FieldByName(lField.FieldName).AsBytes
      except
      end;
    end
    else
    if (lField.Value <> DataSet.FieldByName(lField.FieldName).Value) then
      lField.Value := DataSet.FieldByName(lField.FieldName).Value;
  end;
end;

procedure TDatasetHelper.CopyData(DataSet: TDataset);
begin
  CopyData(DataSet, []);
end;

procedure TDatasetHelper.CopyData(DataSet: TDataset; IgnoreFieldNames: array of string);
  var
    BookMark: TBookmark;
begin
  if (not DataSet.Active) or DataSet.IsEmpty then
    Exit;

  if Self.State in [dsEdit, dsInsert] then
    Self.Cancel;

  BookMark := nil;
  try
    DataSet.DisableControls;
    Self.DisableControls;
    BookMark := DataSet.GetBookmark;

    DataSet.First;
    while not DataSet.Eof do
    begin
      Self.Append;
      CopyCurrentRecord(Dataset, IgnoreFieldNames);
      Self.Post;
      Dataset.Next;
    end;

    Self.First;
  finally
    if Assigned(BookMark) and Dataset.BookmarkValid(BookMark) then
      DataSet.GotoBookmark(BookMark);

    DataSet.EnableControls;
    Self.EnableControls;
  end;
end;
__________________
Buena caza y buen remar... http://mivaler.blogspot.com
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Copiar y pegar en FireMonkey TiammatMX FireMonkey 4 02-09-2019 18:37:02
copiar y pegar elguille Varios 0 30-04-2007 19:10:08
Copiar y pegar archivo Osorio Varios 2 22-03-2007 14:09:28
Más potente que copiar y pegar marcoszorrilla Trucos 0 29-06-2006 22:34:39
Copiar & Pegar no funciona paufra Varios 1 22-07-2005 23:24:10


La franja horaria es GMT +2. Ahora son las 04:11:21.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi