unit uViewDatosYSeleccionPresupuesto; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, StdCtrls, cxControls, cxContainer, cxEdit, cxLabel, cxDBLabel, ExtCtrls, DB, uDADataTable, uBizPresupuestos, ComCtrls, ToolWin, ActnList, ImgList, PngImageList, cxTextEdit, cxDBEdit, pngimage, JvExControls, JvComponent, JvButton, JvTransparentButton, Mask, DBCtrls, uPresupuestosController, dxLayoutControl, Buttons, cxMaskEdit, cxDropDownEdit, cxCalendar; type IViewDatosYSeleccionPresupuesto = interface(IViewBase) ['{BCC2B36B-4A19-4981-B69A-56E258A898F0}'] function GetController: IPresupuestosController; procedure SetController(Value: IPresupuestosController); property Controller: IPresupuestosController read GetController write SetController; function GetPresupuesto: IBizPresupuesto; procedure SetPresupuesto(Value: IBizPresupuesto); property Presupuesto: IBizPresupuesto read GetPresupuesto write SetPresupuesto; function GetOnPresupuestoChanged : TNotifyEvent; procedure SetOnPresupuestoChanged (const Value : TNotifyEvent); property OnPresupuestoChanged : TNotifyEvent read GetOnPresupuestoChanged write SetOnPresupuestoChanged; end; TfrViewDatosYSeleccionPresupuesto = class(TfrViewBase, IViewDatosYSeleccionPresupuesto) DADataSource: TDADataSource; ActionList1: TActionList; actElegirPresupuesto: TAction; actAnadirPresupuesto: TAction; actVerPresupuesto: TAction; PngImageList: TPngImageList; dxLayoutControlPresupuestoGroup_Root: TdxLayoutGroup; dxLayoutControlPresupuesto: TdxLayoutControl; dxLayoutControlPresupuestoItem1: TdxLayoutItem; edtlReferencia: TcxDBTextEdit; Button1: TBitBtn; dxLayoutControlPresupuestoItem7: TdxLayoutItem; Button2: TBitBtn; dxLayoutControlPresupuestoItem8: TdxLayoutItem; Button3: TBitBtn; dxLayoutControlPresupuestoItem9: TdxLayoutItem; dxLayoutControlPresupuestoGroup1: TdxLayoutGroup; dxLayoutControlPresupuestoItem2: TdxLayoutItem; edtFecha: TcxDBTextEdit; procedure actElegirPresupuestoExecute(Sender: TObject); procedure actAnadirPresupuestoExecute(Sender: TObject); procedure actVerPresupuestoExecute(Sender: TObject); procedure actVerPresupuestoUpdate(Sender: TObject); private FController : IPresupuestosController; FPresupuesto : IBizPresupuesto; FOnPresupuestoChanged : TNotifyEvent; protected function GetController: IPresupuestosController; procedure SetController(Value: IPresupuestosController); function GetPresupuesto: IBizPresupuesto; procedure SetPresupuesto(Value: IBizPresupuesto); function GetOnPresupuestoChanged : TNotifyEvent; procedure SetOnPresupuestoChanged (const Value : TNotifyEvent); public property Controller: IPresupuestosController read GetController write SetController; property Presupuesto: IBizPresupuesto read GetPresupuesto write SetPresupuesto; property OnPresupuestoChanged : TNotifyEvent read GetOnPresupuestoChanged write SetOnPresupuestoChanged; end; implementation {$R *.dfm} uses uDataModulePresupuestos, Math; procedure TfrViewDatosYSeleccionPresupuesto.actElegirPresupuestoExecute(Sender: TObject); var APresupuesto : IBizPresupuesto; begin inherited; APresupuesto := (Controller.ElegirPresupuesto(Controller.BuscarSinMontaje, '', False) as IBizPresupuesto); if Assigned(APresupuesto) then Presupuesto := APresupuesto; end; procedure TfrViewDatosYSeleccionPresupuesto.actAnadirPresupuestoExecute( Sender: TObject); var APresupuesto : IBizPresupuesto; begin inherited; APresupuesto := (FController.Nuevo as IBizPresupuesto); FController.Ver(APresupuesto); Presupuesto := APresupuesto; end; procedure TfrViewDatosYSeleccionPresupuesto.actVerPresupuestoExecute(Sender: TObject); begin inherited; FController.Ver(Presupuesto); end; procedure TfrViewDatosYSeleccionPresupuesto.actVerPresupuestoUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := Length(edtlReferencia.Text) > 0; end; function TfrViewDatosYSeleccionPresupuesto.GetPresupuesto: IBizPresupuesto; begin Result := FPresupuesto; end; function TfrViewDatosYSeleccionPresupuesto.GetController: IPresupuestosController; begin Result := FController; end; procedure TfrViewDatosYSeleccionPresupuesto.SetPresupuesto(Value: IBizPresupuesto); begin FPresupuesto := Value; if Assigned(FPresupuesto) then begin DADataSource.DataTable := FPresupuesto.DataTable; if not FPresupuesto.DataTable.Active then FPresupuesto.DataTable.Active := True; end else DADataSource.DataTable := NIL; if Assigned(FOnPresupuestoChanged) then FOnPresupuestoChanged(Self); end; procedure TfrViewDatosYSeleccionPresupuesto.SetController(Value: IPresupuestosController); begin FController := Value; end; function TfrViewDatosYSeleccionPresupuesto.GetOnPresupuestoChanged: TNotifyEvent; begin Result := FOnPresupuestoChanged; end; procedure TfrViewDatosYSeleccionPresupuesto.SetOnPresupuestoChanged(const Value: TNotifyEvent); begin FOnPresupuestoChanged := Value; end; end.