unit uBizInformesVentas;

interface

uses
  Classes, DB, SysUtils, uROClasses, schInformesVentasClient_Intf, uDADataTable;

const
  BIZ_INFORMESVENTAS = 'Client.InformesVentas';
  VALOR_CATEGORIA = 'VENTAS';

type
  IBizInformesVentas = interface(IListaInformesPorCategoria)
  ['{78F747A5-9A35-44D6-8C73-8682A41FE573}']
    procedure Show;
    procedure VerPropiedades;
  end;

  TBizInformesVentasDataTableRules = class(TListaInformesPorCategoriaDataTableRules, IBizInformesVentas)
  protected
    function GetVISTAValue: IROStrings; override;
    procedure BeforePost(Sender: TDADataTable); override;
  public
    procedure Show;
    procedure VerPropiedades;
  end;

implementation

uses
  Windows, Dialogs, uDACDSDataTable, uDataModuleBase,
  uEditorUtils, Variants, uFormPropiedadesInforme, Forms, Controls;

{ TBizInformesVentasDataTableRules }

procedure TBizInformesVentasDataTableRules.BeforePost(
  Sender: TDADataTable);
begin
  inherited;
  if Length(CATEGORIA) = 0 then
  begin
    Edit;
    CATEGORIA := VALOR_CATEGORIA;
  end;

  if Length(NOMBRE) = 0 then
    VerPropiedades;
end;

function TBizInformesVentasDataTableRules.GetVISTAValue: IROStrings;
begin
  result := NewROStrings();
  result.Add(DataTable.Fields[idx_ListaInformesPorCategoriaVISTA].AsString);
end;

procedure TBizInformesVentasDataTableRules.Show;
begin
  ShowEditor(IBizInformesVentas, Self, etItem);
end;

procedure TBizInformesVentasDataTableRules.VerPropiedades;
begin
  with TfrPropiedadesInforme.Create(NIL) do
  try
    Nombre := Self.NOMBRE;
    Descripcion := Self.DESCRIPCION;
    if (ShowModal = mrOK) then
    begin
      DataTable.Edit;
      Self.NOMBRE := Nombre;
      Self.DESCRIPCION := Descripcion;
      Self.ICONO := 2;
    end;
  finally
    Free;
  end;
end;

initialization
  RegisterDataTableRules(BIZ_INFORMESVENTAS, TBizInformesVentasDataTableRules);

end.
