unit uViewFiltroComerciales; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, StdCtrls, Buttons, TBXDkPanels, uViewParametrosInforme, uBizContactos, uComercialesController, uIViewFiltroComerciales; type TfrViewFiltroComerciales = class(TfrViewParametrosInforme, IViewFiltroComerciales) TBXLabel2: TTBXLabel; rbTodosComerciales: TRadioButton; rbUnComercial: TRadioButton; cbxDesglosado: TCheckBox; bElegirComercial: TBitBtn; edtComercial: TcxTextEdit; procedure rbTodosComercialesClick(Sender: TObject); procedure rbUnComercialClick(Sender: TObject); procedure CustomViewCreate(Sender: TObject); procedure bElegirComercialClick(Sender: TObject); procedure CustomViewDestroy(Sender: TObject); private FComercial : IBizComercial; FComercialesController : IComercialesController; function getIdComercial: Integer; procedure setIdComercial(const IdComercial:Integer); public property IdComercial : Integer read getIdComercial write setIdComercial; property Comercial : IBizComercial read FComercial; end; implementation {$R *.dfm} procedure TfrViewFiltroComerciales.bElegirComercialClick(Sender: TObject); var AComerciales : IBizComercial; begin inherited; AComerciales := IBizComercial(FComercialesController.BuscarTodos); try FComercial := IBizComercial(FComercialesController.ElegirContacto(AComerciales, '', False)); if Assigned(FComercial) then begin FComercial.Open; edtComercial.Text := FComercial.NOMBRE; end; finally AComerciales := NIL; end; end; procedure TfrViewFiltroComerciales.CustomViewCreate(Sender: TObject); begin inherited; FComercial := NIL; FComercialesController := NIL; end; procedure TfrViewFiltroComerciales.CustomViewDestroy(Sender: TObject); begin inherited; FComercial := NIL; FComercialesController := NIL; end; function TfrViewFiltroComerciales.getIdComercial: Integer; begin Result := FComercial.ID; end; procedure TfrViewFiltroComerciales.rbTodosComercialesClick(Sender: TObject); begin if rbTodosComerciales.Checked then begin cbxDesglosado.Enabled := True; FComercial := NIL; bElegirComercial.Enabled := False; edtComercial.Clear; edtComercial.Enabled := False; end; end; procedure TfrViewFiltroComerciales.rbUnComercialClick(Sender: TObject); begin if rbUnComercial.Checked then begin cbxDesglosado.Enabled := False; bElegirComercial.Enabled := True; edtComercial.Enabled := True; if not Assigned(FComercialesController) then FComercialesController := TComercialesController.Create; end; end; procedure TfrViewFiltroComerciales.setIdComercial(const IdComercial: Integer); begin if not Assigned(FComercialesController) then FComercialesController := TComercialesController.Create; FComercial := IBizComercial(FComercialesController.Buscar(IdComercial)); if Assigned(FComercial) then begin FComercial.Open; edtComercial.Text := FComercial.NOMBRE; end; end; end.