unit uEditorHistorialCargasEDI;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uEditorGridBase, Menus, DB, uDADataTable, JvAppStorage,
  JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList,
  PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
  TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls, JvComponent,
  JvNavigationPane, uBizEDILog, uCustomView, uViewBase, 
  uViewHistorialCargasEDI, uViewGrid, uViewGridBase;

type
  IEditorHistorialCargasEDI = interface(IEditorGridBase)
  ['{6C84E101-C4FB-48F9-A9A9-93F8606DF4FF}']
    function GetEDILog: IBizEDILog;
    procedure SetEDILog(const Value: IBizEDILog);
    property EDILog: IBizEDILog read GetEDILog write SetEDILog;
  end;
  
  TfEditorHistorialCargasEDI = class(TfEditorGridBase, IEditorHistorialCargasEDI)
    frViewHistorialCargasEDI1: TfrViewHistorialCargasEDI;
    procedure CustomEditorCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  protected
    FEDILog : IBizEDILog;
    function GetEDILog: IBizEDILog;
    procedure SetEDILog(const Value: IBizEDILog);
  public
    property EDILog: IBizEDILog read GetEDILog write SetEDILog;
  end;

var
  fEditorHistorialCargasEDI: TfEditorHistorialCargasEDI;

implementation

{$R *.dfm}

{ TfEditorHistorialCargasEDI }

function TfEditorHistorialCargasEDI.GetEDILog: IBizEDILog;
begin
  Result := FEDILog;
end;

procedure TfEditorHistorialCargasEDI.SetEDILog(const Value: IBizEDILog);
begin
  FEDILog := Value;
  dsDataTable.DataTable := FEDILog.DataTable;
  if Assigned(ViewGrid) then
    (ViewGrid as IViewHistorialCargasEDI).EDILog := FEDILog;
end;

procedure TfEditorHistorialCargasEDI.CustomEditorCreate(Sender: TObject);
begin
  inherited;
  ViewGrid := frViewHistorialCargasEDI1;
end;

procedure TfEditorHistorialCargasEDI.FormShow(Sender: TObject);
begin
  inherited;

  if not Assigned(ViewGrid) then
    raise Exception.Create('No hay ninguna vista asignada');

  if not Assigned(FEDILog) then
    raise Exception.Create('No hay ningún control asignado');

  FEDILog.DataTable.Active := True;
  ViewGrid.GotoFirst;
end;

end.
