unit uViewFacturasComision; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewDetallesGenerico, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ActnList, ImgList, PngImageList, uDADataTable, ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxImageComboBox, cxCurrencyEdit, uDataModuleComisiones, uBizComisiones, uComisionesController, Grids, DBGrids, cxSpinEdit, dxLayoutControl, uDAInterfaces; type IViewFacturasComision = interface ['{9B698A4C-B38E-4279-918D-2AF64556B1FB}'] function GetComision: IBizComisiones; procedure SetComision(const Value: IBizComisiones); property Comision: IBizComisiones read GetComision write SetComision; function GetController : IComisionesController; procedure SetController (const Value : IComisionesController); property Controller : IComisionesController read GetController write SetController; end; TfrViewFacturasComision = class(TfrViewDetallesGenerico, IViewFacturasComision) cxGridViewRecID: TcxGridDBColumn; cxGridViewID_EMPRESA: TcxGridDBColumn; cxGridViewID_COMISION_LIQUIDADA: TcxGridDBColumn; cxGridViewFECHA: TcxGridDBColumn; cxGridViewREFERENCIA: TcxGridDBColumn; cxGridViewID_CLIENTE: TcxGridDBColumn; cxGridViewCLIENTE: TcxGridDBColumn; cxGridViewBASE_IMPONIBLE: TcxGridDBColumn; actExpandir: TAction; actContraer: TAction; ToolButton3: TToolButton; ToolButton8: TToolButton; cxGridViewCOMISION: TcxGridDBColumn; cxGridViewIMPORTE_COMISION: TcxGridDBColumn; procedure actExpandirExecute(Sender: TObject); procedure actContraerExecute(Sender: TObject); procedure CustomViewShow(Sender: TObject); procedure actEliminarUpdate(Sender: TObject); procedure actExpandirUpdate(Sender: TObject); procedure actContraerUpdate(Sender: TObject); protected FHayCambios : Boolean; FComision : IBizComisiones; FController : IComisionesController; procedure AnadirInterno; override; procedure EliminarInterno; override; function GetComision: IBizComisiones; procedure SetComision(const Value: IBizComisiones); function GetModified: Boolean; override; procedure SetModified(const Value: Boolean); override; function GetController : IComisionesController; procedure SetController (const Value : IComisionesController); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Comision: IBizComisiones read GetComision write SetComision; property Controller : IComisionesController read GetController write SetController; end; implementation {$R *.dfm} uses uCustomView; { TfrViewFacturasComision } procedure TfrViewFacturasComision.actContraerExecute(Sender: TObject); begin inherited; cxGridView.ViewData.Collapse(True); end; procedure TfrViewFacturasComision.actContraerUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := HayDatos; end; procedure TfrViewFacturasComision.actEliminarUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := ((cxGridView.Controller.SelectedRowCount > 0) and (cxGridView.Controller.SelectedRows[0].HasCells)); end; procedure TfrViewFacturasComision.actExpandirExecute(Sender: TObject); begin inherited; cxGridView.ViewData.Expand(True); end; procedure TfrViewFacturasComision.actExpandirUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := HayDatos; end; procedure TfrViewFacturasComision.AnadirInterno; begin //inherited; // No hacer el comportamiento normal if FController.ElegirFacturasComision(Comision) then Modified := True; end; constructor TfrViewFacturasComision.Create(AOwner: TComponent); begin inherited; FHayCambios := False; end; procedure TfrViewFacturasComision.CustomViewShow(Sender: TObject); begin inherited; cxGridView.OptionsSelection.MultiSelect := True; end; destructor TfrViewFacturasComision.Destroy; begin inherited; end; procedure TfrViewFacturasComision.EliminarInterno; begin inherited; end; function TfrViewFacturasComision.GetController: IComisionesController; begin Result := FController; end; function TfrViewFacturasComision.GetModified: Boolean; begin Result := FHayCambios or inherited GetModified; end; function TfrViewFacturasComision.GetComision: IBizComisiones; begin Result := FComision; end; procedure TfrViewFacturasComision.SetController( const Value: IComisionesController); begin FController := Value; end; procedure TfrViewFacturasComision.SetModified(const Value: Boolean); begin FHayCambios := Value; inherited; end; procedure TfrViewFacturasComision.SetComision(const Value: IBizComisiones); begin FComision := Value; FHayCambios := False; if Assigned(FComision) then dsDetalles.DataTable := FComision.Facturas.DataTable else dsDetalles.DataTable := NIL; actAnchoAutomatico.Execute; end; end.