unit uViewDetallesFamilias; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewContenido, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxDropDownEdit, cxTextEdit, cxSpinEdit, cxCurrencyEdit, ImgList, PngImageList, uDADataTable, ExtActns, StdActns, ActnList, ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxImageComboBox, uBizImportesCabeceraBase, cxCheckBox, TB2Item, TBX, TB2Dock, TB2Toolbar, JvExComCtrls, JvToolBar, cxMaskEdit; type IViewDetallesFamilias = interface(IViewContenido) ['{FFE0D3C1-F05C-4F28-9393-03F344CA6EBA}'] end; TfrViewDetallesFamilias = class(TfrViewContenido, IViewDetallesFamilias) cxStyleRepository1: TcxStyleRepository; cxStyle_IMPORTETOTAL: TcxStyle; cxStyle_SUBTOTAL: TcxStyle; TipoPngImageList: TPngImageList; cxGridViewDESCRIPCION: TcxGridDBColumn; cxGridViewCANTIDAD: TcxGridDBColumn; cxGridViewIMPORTEUNIDAD: TcxGridDBColumn; cxGridViewIMPORTETOTAL: TcxGridDBColumn; cxGridViewTIPO: TcxGridDBColumn; cxGridViewPOSICION: TcxGridDBColumn; cxGridViewVISIBLE: TcxGridDBColumn; actAnadirCap: TAction; ToolButton1: TToolButton; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; cxStyle_TITULO: TcxStyle; procedure cxGridViewEditing(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; var AAllow: Boolean); procedure cxGridViewTIPOStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); procedure actAnadirCapExecute(Sender: TObject); private protected public end; implementation uses uBizImportesDetalleBase, uDAInterfaces; {$R *.dfm} procedure TfrViewDetallesFamilias.cxGridViewEditing( Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; var AAllow: Boolean); var IndiceCol : Integer; begin IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_DESCRIPCION).Index; if AItem.Index <= IndiceCol then AAllow := True else begin IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_TIPODETALLE).Index; if (UpperCase(AItem.GridView.Items[IndiceCol].EditValue) = TIPODETALLE_SUBTOTAL) then AAllow := False else begin if (UpperCase(AItem.GridView.Items[IndiceCol].EditValue) = TIPODETALLE_TITULO) then begin IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_VISIBLE).Index; if AItem.Index = IndiceCol then AAllow := True else AAllow := False end; end; end; end; procedure TfrViewDetallesFamilias.cxGridViewTIPOStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); var IndiceCol : Integer; ATipo : String; begin if Assigned(ARecord) then begin IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_TIPODETALLE).Index; ATipo := VarToStr(ARecord.Values[IndiceCol]); if ATipo = TIPODETALLE_SUBTOTAL then AStyle := cxStyle_SUBTOTAL; if ATipo = TIPODETALLE_TITULO then AStyle := cxStyle_TITULO; end; end; procedure TfrViewDetallesFamilias.actAnadirCapExecute(Sender: TObject); var AFieldTIPO : TDAField; AFieldDES : TDAField; begin if Assigned(DADataSource.DataTable) then begin AFieldTIPO := DADataSource.DataTable.FindField(fld_TIPODETALLE); AFieldDES := DADataSource.DataTable.FindField(fld_DESCRIPCION); DADataSource.DataTable.Append; AFieldDES.AsString := 'Capítulo de...'; AFieldTIPO.Value := TIPODETALLE_TITULO; if DADataSource.DataTable.State in dsEditModes then DADataSource.DataTable.Post; DADataSource.DataTable.Next; DADataSource.DataTable.Insert; AFieldTIPO.Value := TIPODETALLE_CONCEPTO; if DADataSource.DataTable.State in dsEditModes then DADataSource.DataTable.Post; DADataSource.DataTable.Next; DADataSource.DataTable.Insert; AFieldDES.AsString := 'Total del capítulo'; AFieldTIPO.Value := TIPODETALLE_SUBTOTAL; if DADataSource.DataTable.State in dsEditModes then DADataSource.DataTable.Post; end; end; end.