unit uEditorCalendarioMediciones;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dxLayoutLookAndFeels, JvAppStorage, JvAppRegistryStorage,
  JvComponentBase, JvFormPlacement, ImgList, PngImageList, StdActns, ActnList,
  ComCtrls, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls, JvExControls,
  JvComponent, JvNavigationPane, uCustomView, uViewBase, uViewCalendarioBase,
  cxSchedulerStorage, cxSchedulerDBStorage, DB,
  uDADataTable, dxPSGlbl, dxPSUtl, dxPSEngn, dxPrnPg, dxBkgnd, dxWrap,
  dxPrnDev, dxPSCompsProvider, dxPSFillPatterns, dxPSEdgePatterns,
  dxPrnDlg, dxPSCore, dxPScxCommon, dxPScxScheduler2Lnk, Grids, DBGrids,

  uBizCitas, uEditorCalendarioConFiltro, uViewCalendarioConFiltro,
  uEditorCalendarioBase, uViewCalendarioMediciones;

type
  IEditorCalendarioMediciones = interface(IEditorCalendarioConFiltro)
  ['{CA83B596-1408-455F-AD78-0BC121A452C3}']
    function GetVendedores: IBizVendedores;
    procedure SetVendedores(const Value: IBizVendedores);
    property Vendedores : IBizVendedores read GetVendedores write SetVendedores;
  end;

  TfEditorCalendarioMediciones = class(TfEditorCalendarioConFiltro, IEditorCalendarioMediciones)
    DADataSource2: TDADataSource;
    frViewCalendarioMediciones: TfrViewCalendarioConFiltro;

  private
    FVendedores: IBizVendedores;
    procedure CargarLista; override;
    function GetVendedores: IBizVendedores;
    procedure SetVendedores(const Value: IBizVendedores);

  protected
    procedure InicializarEvento (var aEvent : TcxSchedulerControlEvent); override;

  public
    property Vendedores : IBizVendedores read GetVendedores write SetVendedores;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

var
  fEditorCalendarioMediciones: TfEditorCalendarioMediciones;

implementation
{$R *.dfm}

{ TfEditorCalendarioMediciones }

uses schCitasClient_Intf;


constructor TfEditorCalendarioMediciones.Create(AOwner: TComponent);
begin
  inherited;
  ViewCitas := frViewCalendarioMediciones;
end;

procedure TfEditorCalendarioMediciones.CargarLista;
begin
  NombreLista := 'Mediciones';
  inherited;
end;

function TfEditorCalendarioMediciones.GetVendedores: IBizVendedores;
begin
  Result := FVendedores;
end;

procedure TfEditorCalendarioMediciones.SetVendedores(const Value: IBizVendedores);
begin
  FVendedores := Value;

  if Assigned(FVendedores) then
  begin
    DADataSource2.DataTable := FVendedores.DataTable;

    if not FVendedores.DataTable.Active then
       FVendedores.DataTable.Active := True;
  end
  else
    DADataSource2.DataTable := Nil;
end;

procedure TfEditorCalendarioMediciones.InicializarEvento(var aEvent: TcxSchedulerControlEvent);
begin
  inherited;
  with AEvent do
  begin
    SetCustomFieldValueByName(fld_CITASTIPOTAREA, TextoTipoCita[Ord(tcMedicion)]);
  end;
end;

destructor TfEditorCalendarioMediciones.Destroy;
begin
  FVendedores := Nil;
  inherited;
end;

end.
