unit uBizVentasProceso;

interface

uses
  Classes, DB, SysUtils, uROClasses, uDADataTable, uDAInterfaces,
  DataAbstract_Intf, uROTypes, schVentasEnProcesoClient_Intf;

const
  BIZ_VENTASPROCESO = 'Client.VentasProceso';

type
  IBizVentasProceso = interface(IVentasEnProcesoPendientes)
    ['{FA9EC0B7-D12E-4088-8406-D9A86441C3B3}']
    function GetVisibleColumns: String;
    procedure SetVisibleColumns(const Value: String);
    property VisibleColumns : String read GetVisibleColumns write SetVisibleColumns;
  end;

  TBizVentasProcesoDataTableRules = class(TVentasEnProcesoPendientesDataTableRules, IBizVentasProceso)
  private
    FVisibleColumns : String;
  protected
    function GetVisibleColumns: String;
    procedure SetVisibleColumns(const Value: String);
    procedure OnBeforeDataRequestCall(DataTable: TDADataTable;
      Request: TDARemoteRequest);
    procedure OnBeforeSchemaCall(DataTable: TDADataTable;
      Request: TDARemoteRequest);
  public
    constructor Create(aDataTable: TDADataTable); override;
    property VisibleColumns : String read GetVisibleColumns write SetVisibleColumns;
  end;


implementation

uses
  uDataModuleVentasProceso;

{ TBizVentasProcesoDataTableRules }

constructor TBizVentasProcesoDataTableRules.Create(
  aDataTable: TDADataTable);
begin
  inherited;
  if Assigned(DataTable) then
  begin
    DataTable.OnBeforeDataRequestCall := OnBeforeDataRequestCall;
    DataTable.OnBeforeSchemaCall := OnBeforeSchemaCall;
  end;
end;

function TBizVentasProcesoDataTableRules.GetVisibleColumns: String;
begin
  if Length(FVisibleColumns) = 0 then
    FVisibleColumns := dmVentasEnProceso.GetNameColumns;
  Result := FVisibleColumns
end;

procedure TBizVentasProcesoDataTableRules.OnBeforeDataRequestCall(
  DataTable: TDADataTable; Request: TDARemoteRequest);
begin
  Request.ParamByName('Columns').AsString := VisibleColumns;
end;

procedure TBizVentasProcesoDataTableRules.OnBeforeSchemaCall(
  DataTable: TDADataTable; Request: TDARemoteRequest);
begin
  Request.ParamByName('Columns').AsString := VisibleColumns;
end;

procedure TBizVentasProcesoDataTableRules.SetVisibleColumns(
  const Value: String);
begin
  if Length(Value) > 0 then
    FVisibleColumns := Value
  else
    FVisibleColumns := dmVentasEnProceso.GetNameColumns;
end;

initialization
  RegisterDataTableRules(BIZ_VENTASPROCESO, TBizVentasProcesoDataTableRules);

finalization
end.


