unit uViewProveedoresArticulo; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, uViewDetallesGenerico, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ActnList, ImgList, PngImageList, uDADataTable, ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxDBLookupComboBox, cxSpinEdit, uBizContactos, uProveedoresController, uDAInterfaces, uBizArticulos, uArticulosController, cxTextEdit, cxCurrencyEdit; type IViewProveedoresArticulo = interface(IViewBase) ['{65206152-786D-47AE-A037-5EF480BC056C}'] function GetArticulo: IBizArticulo; procedure SetArticulo(const Value: IBizArticulo); property Articulo: IBizArticulo read GetArticulo write SetArticulo; function GetController : IArticulosController; procedure SetController (const Value : IArticulosController); property Controller : IArticulosController read GetController write SetController; end; TfrViewProveedoresArticulo = class(TfrViewDetallesGenerico, IViewProveedoresArticulo) dsProveedores: TDADataSource; cxGridViewPROVEEDOR: TcxGridDBColumn; cxGridViewDESCUENTO: TcxGridDBColumn; cxGridViewREFERENCIA_PROV: TcxGridDBColumn; cxGridViewPRECIO_COSTE: TcxGridDBColumn; cxGridViewPRECIO_NETO: TcxGridDBColumn; cxGridViewPRECIO_PORTE: TcxGridDBColumn; cxGridViewPRECIO_PVP_VENTA: TcxGridDBColumn; cxGridViewPRECIO_PVP_TOTAL: TcxGridDBColumn; cxGridViewID_PROVEEDOR: TcxGridDBColumn; cxGridViewID_ARTICULO: TcxGridDBColumn; cxGridViewFECHA_ACTUALIZACION: TcxGridDBColumn; procedure cxGridViewPROVEEDORPropertiesEditValueChanged(Sender: TObject); procedure CustomViewShow(Sender: TObject); protected FArticulo: IBizArticulo; FController: IArticulosController; FProvController : IProveedoresController; FProveedores : IBizProveedor; function GetArticulo: IBizArticulo; procedure SetArticulo(const Value: IBizArticulo); function GetController : IArticulosController; procedure SetController (const Value : IArticulosController); procedure AnadirInterno; override; public property Articulo: IBizArticulo read GetArticulo write SetArticulo; property Controller : IArticulosController read GetController write SetController; constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; implementation {$R *.dfm} procedure TfrViewProveedoresArticulo.AnadirInterno; begin dsDetalles.DataTable.Append; end; constructor TfrViewProveedoresArticulo.Create(AOwner: TComponent); begin inherited; FProvController := TProveedoresController.Create; FProveedores := (FProvController.BuscarTodos as IBizProveedor); dsProveedores.DataTable := FProveedores.DataTable; if not dsProveedores.DataTable.Active then dsProveedores.DataTable.Active := True; end; procedure TfrViewProveedoresArticulo.CustomViewShow(Sender: TObject); begin inherited; cxGridView.ApplyBestFit; end; procedure TfrViewProveedoresArticulo.cxGridViewPROVEEDORPropertiesEditValueChanged(Sender: TObject); begin inherited; //Signamos el descuento del proveedor seleccionado if not Articulo.Proveedores.DataTable.Editing then Articulo.Proveedores.DataTable.Edit; Articulo.Proveedores.DESCUENTO := FProveedores.DESCUENTO; end; destructor TfrViewProveedoresArticulo.Destroy; begin if dsProveedores.DataTable.Active then dsProveedores.DataTable.Active := False; FProveedores := NIL; FProvController := NIL; inherited; end; function TfrViewProveedoresArticulo.GetArticulo: IBizArticulo; begin Result := FArticulo; end; function TfrViewProveedoresArticulo.GetController: IArticulosController; begin Result := FController; end; procedure TfrViewProveedoresArticulo.SetArticulo(const Value: IBizArticulo); begin FArticulo := Value; dsDetalles.DataTable := FArticulo.Proveedores.DataTable; end; procedure TfrViewProveedoresArticulo.SetController(const Value: IArticulosController); begin FController := Value; end; end.