git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@5 9a1d36f3-7752-2d40-8ccb-50eb49674c68
135 lines
3.9 KiB
ObjectPascal
135 lines
3.9 KiB
ObjectPascal
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, ImgList,
|
||
PngImageList, cxGrid;
|
||
|
||
type
|
||
IViewContenido = interface(IViewBase)
|
||
['{AF7F3CD1-3CD1-4F87-A4B4-FCB1320104F7}']
|
||
end;
|
||
|
||
TfrViewContenido = class(TfrViewBase, IViewContenido)
|
||
ActionListContenido: TActionList;
|
||
cxGrid: TcxGrid;
|
||
cxGridView: TcxGridDBTableView;
|
||
cxGridLevel: TcxGridLevel;
|
||
DADataSource: TDADataSource;
|
||
actAnadir: TAction;
|
||
actEliminar: TAction;
|
||
actSubir: TAction;
|
||
actBajar: TAction;
|
||
ContenidoImageList: TPngImageList;
|
||
ToolBar1: TToolBar;
|
||
cxStyleRepository: TcxStyleRepository;
|
||
cxStyleEven: TcxStyle;
|
||
cxStyleOdd: TcxStyle;
|
||
cxStyleSelection: TcxStyle;
|
||
procedure actAnadirExecute(Sender: TObject);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure actEliminarUpdate(Sender: TObject);
|
||
procedure actSubirUpdate(Sender: TObject);
|
||
procedure actBajarExecute(Sender: TObject);
|
||
procedure actBajarUpdate(Sender: TObject);
|
||
procedure actSubirExecute(Sender: TObject);
|
||
private
|
||
protected
|
||
public
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses uBizImportesDetalleBase, uDAInterfaces;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrViewContenido.actAnadirExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if Assigned(DADataSource.DataTable) then
|
||
DADataSource.DataTable.Insert
|
||
end;
|
||
|
||
procedure TfrViewContenido.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
{ Este cambio nos permite poder eliminar varios conceptos de una sola vez
|
||
y no de uno en uno como antes. }
|
||
with cxGrid.ActiveView.DataController do
|
||
begin
|
||
DeleteSelection;
|
||
SelectRows(FocusedRowIndex, FocusedRowIndex);
|
||
end;
|
||
|
||
{ if Assigned(DADataSource.DataTable) then
|
||
DADataSource.DataTable.Delete;}
|
||
end;
|
||
|
||
procedure TfrViewContenido.actEliminarUpdate(Sender: TObject);
|
||
begin
|
||
if Assigned(DADataSource.DataTable) then
|
||
(Sender as TAction).Enabled := (not DADataSource.DataTable.IsEmpty)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
end;
|
||
|
||
procedure TfrViewContenido.actSubirUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if Assigned(cxGridView.Controller.FocusedRow) then
|
||
(Sender as TAction).Enabled := not (cxGridView.Controller.FocusedRow.IsFirst)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
end;
|
||
|
||
procedure TfrViewContenido.actBajarExecute(Sender: TObject);
|
||
var
|
||
AField : TDAField;
|
||
begin
|
||
inherited;
|
||
if Assigned(DADataSource.DataTable) then
|
||
begin
|
||
AField := DADataSource.DataTable.FindField(fld_POSICION);
|
||
// Por si el registro est<73> reci<63>n insertado y la posici<63>n todav<61>a
|
||
// no ha sido asignada.
|
||
if (AField.AsInteger < 0) then
|
||
DADataSource.DataTable.Post;
|
||
|
||
IntercambiarPosiciones(DADataSource.DataTable, AField.AsInteger, AField.AsInteger + 1);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewContenido.actBajarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if Assigned(cxGridView.Controller.FocusedRow) then
|
||
(Sender as TAction).Enabled := not (cxGridView.Controller.FocusedRow.IsLast)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
end;
|
||
|
||
procedure TfrViewContenido.actSubirExecute(Sender: TObject);
|
||
var
|
||
AField : TDAField;
|
||
begin
|
||
inherited;
|
||
if Assigned(DADataSource.DataTable) then
|
||
begin
|
||
AField := DADataSource.DataTable.FindField(fld_POSICION);
|
||
// Por si el registro est<73> reci<63>n insertado y la posici<63>n todav<61>a
|
||
// no ha sido asignada.
|
||
if (AField.AsInteger < 0) then
|
||
DADataSource.DataTable.Post;
|
||
|
||
IntercambiarPosiciones(DADataSource.DataTable, AField.AsInteger, AField.AsInteger - 1);
|
||
end;
|
||
end;
|
||
|
||
end.
|