unit uViewContactosObra;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn,
  dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
  dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGridLnk, ActnList,
  uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
  uViewBase, uBizObra, ComCtrls, ToolWin, ImgList, PngImageList;

type
  IViewContactosObra = interface(IViewBase)
  ['{68560F9F-2BB9-4787-A97C-0FF61C60DD25}']
    function GetContactosObra: IBizContactosObra;
    procedure SetContactosObra(const Value: IBizContactosObra);
    property ContactosObra: IBizContactosObra read GetContactosObra write SetContactosObra;
  end;

  TfrViewContactosObra = class(TfrViewGrid, IViewContactosObra)
    cxGridViewRecID: TcxGridDBColumn;
    cxGridViewCODIGOOBRA: TcxGridDBColumn;
    cxGridViewCODIGOCONTACTO: TcxGridDBColumn;
    cxGridViewNOMBRE: TcxGridDBColumn;
    cxGridViewCATEGORIAS: TcxGridDBColumn;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton4: TToolButton;
    ToolButton3: TToolButton;
    ToolButton5: TToolButton;
    actAnadir: TAction;
    actEliminar: TAction;
    actEliminarTodo: TAction;
    actEditar: TAction;
    PngImageList: TPngImageList;
    procedure actEliminarUpdate(Sender: TObject);
    procedure actEliminarTodoUpdate(Sender: TObject);
    procedure actEditarUpdate(Sender: TObject);
  private
    FContactosObra: IBizContactosObra;
    function GetContactosObra: IBizContactosObra;
    procedure SetContactosObra(const Value: IBizContactosObra);
  public
    property ContactosObra: IBizContactosObra read GetContactosObra write SetContactosObra;
  end;

var
  frViewContactosObra: TfrViewContactosObra;

implementation

uses uDataModuleObras;

{$R *.dfm}

{ TfrViewContactosObra }

function TfrViewContactosObra.GetContactosObra: IBizContactosObra;
begin
  Result := FContactosObra;
end;

procedure TfrViewContactosObra.SetContactosObra(const Value: IBizContactosObra);
begin
  FContactosObra := Value;

  if Assigned(FContactosObra) then
    DADataSource.DataTable := FContactosObra.DataTable
  else
    DADataSource.DataTable := Nil;
end;

procedure TfrViewContactosObra.actEliminarUpdate(Sender: TObject);
begin
  if Assigned(ContactosObra) then
    (Sender as TAction).Enabled := not ContactosObra.DataTable.IsEmpty
  else
    (Sender as TAction).Enabled := False;
end;

procedure TfrViewContactosObra.actEliminarTodoUpdate(Sender: TObject);
begin
  if Assigned(ContactosObra) then
    (Sender as TAction).Enabled := not ContactosObra.DataTable.IsEmpty
  else
    (Sender as TAction).Enabled := False;
end;

procedure TfrViewContactosObra.actEditarUpdate(Sender: TObject);
begin
  if Assigned(ContactosObra) then
    (Sender as TAction).Enabled := not ContactosObra.DataTable.IsEmpty
  else
    (Sender as TAction).Enabled := False;
end;

end.
