unit uViewContenido; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, cxStyles, ComCtrls, ToolWin, ActnList, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, ImgList, PngImageList, uDataModulePresupuestos, cxImageComboBox, cxCalc, cxCurrencyEdit, cxSpinEdit, cxTextEdit, cxMemo, ExtActns, StdActns, cxRichEdit, TB2Item, TBX, TBXExtItems, TB2Dock, TB2Toolbar, TB2ExtItems, uBizPresupuestosCliente, Grids, DBGrids, cxDropDownEdit; type IViewContenido = interface(IViewBase) ['{6D98117E-EFAE-4D05-ACB7-63D0AC95AB12}'] function GetContenido : IBizDetallesPresupuesto; procedure SetContenido (const Value : IBizDetallesPresupuesto); property Contenido : IBizDetallesPresupuesto read GetContenido write SetContenido; end; TfrViewContenido = class(TfrViewBase) ActionListContenido: TActionList; cxGrid: TcxGrid; cxGridView: TcxGridDBTableView; cxGridLevel: TcxGridLevel; DADataSource: TDADataSource; ToolBar1: TToolBar; actAnadir: TAction; actEliminar: TAction; ToolButton1: TToolButton; ToolButton2: TToolButton; ContenidoImageList: TPngImageList; cxGridViewRecID: TcxGridDBColumn; cxGridViewCODIGOPRESUPUESTO: TcxGridDBColumn; cxGridViewNUMCONCEPTO: TcxGridDBColumn; cxGridViewDESCRIPCION: TcxGridDBColumn; cxGridViewCANTIDAD: TcxGridDBColumn; cxGridViewIMPORTEUNIDAD: TcxGridDBColumn; cxGridViewIMPORTETOTAL: TcxGridDBColumn; ToolButton3: TToolButton; ToolButton4: TToolButton; RichEditBold1: TRichEditBold; RichEditItalic1: TRichEditItalic; RichEditUnderline1: TRichEditUnderline; RichEditStrikeOut1: TRichEditStrikeOut; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; cxGridViewPOSICION: TcxGridDBColumn; ToolButton9: TToolButton; cxGridViewTIPO: TcxGridDBColumn; cxStyleRepository1: TcxStyleRepository; cxStyle_IMPORTETOTAL: TcxStyle; cxStyle_SUBTOTAL: TcxStyle; procedure actAnadirExecute(Sender: TObject); procedure actEliminarExecute(Sender: TObject); procedure ToolButton9Click(Sender: TObject); procedure cxGridViewStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); procedure cxGridViewCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); private FContenido : IBizDetallesPresupuesto; protected function GetContenido : IBizDetallesPresupuesto; procedure SetContenido (const Value : IBizDetallesPresupuesto); public property Contenido : IBizDetallesPresupuesto read GetContenido write SetContenido; constructor Create(AOwner: TComponent); override; end; implementation uses schPresupuestosClient_Intf; {$R *.dfm} procedure TfrViewContenido.actAnadirExecute(Sender: TObject); begin inherited; DADataSource.DataTable.Insert; end; procedure TfrViewContenido.actEliminarExecute(Sender: TObject); begin inherited; DADataSource.DataTable.Delete; end; function TfrViewContenido.GetContenido: IBizDetallesPresupuesto; begin Result := FContenido; end; procedure TfrViewContenido.SetContenido( const Value: IBizDetallesPresupuesto); begin FContenido := Value; if Assigned(FContenido) then begin DADataSource.DataTable := FContenido.DataTable; end; end; procedure TfrViewContenido.ToolButton9Click(Sender: TObject); begin inherited; DADataSource.DataTable.Append; end; procedure TfrViewContenido.cxGridViewStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); var IndiceCol : Integer; ATipo : String; begin inherited; if Assigned(ARecord) then begin IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_DetallesPresupuestosTIPO).Index; ATipo := VarToStr(ARecord.DisplayTexts[IndiceCol]); if ATipo = TIPODETALLE_SUBTOTAL then AStyle := cxStyle_SUBTOTAL end; end; constructor TfrViewContenido.Create(AOwner: TComponent); begin inherited; cxGridView.Styles.OnGetContentStyle := cxGridViewStylesGetContentStyle; end; procedure TfrViewContenido.cxGridViewCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); var x, y, IndiceCol : Integer; ATipo : String; R : TRect; AParams: TcxViewParams; begin inherited; {IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_DetallesPresupuestosTIPO).Index; ATipo := VarToStr(AViewInfo.GridRecord.DisplayTexts[IndiceCol]); if ATipo = TIPODETALLE_SUBTOTAL then begin with AParams do begin Bitmap := cxStyle_SUBTOTAL.Bitmap; Color := cxStyle_SUBTOTAL.Color; Font := cxStyle_SUBTOTAL.Font; TextColor := cxStyle_SUBTOTAL.TextColor; end; R := AViewInfo.ContentBounds; ACanvas.FillRect(R, AParams, [bTop], clGreen, 1); ACanvas.Pen.Color := clGreen; ACanvas.MoveTo(R.Left, R.Top); ACanvas.LineTo(R.Right, R.Top); ADone := True; end} end; end.