This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES2/Source/Modulos/Articulos/Views/uEditorElegirArticulos.pas
roberto acca485d58 Version 1.4.7
Tareas #611: Todos los informes estadisticos tendrán ano1 y ano2 como variables
Tareas #612: Repaso de todos los informes estadisticos para que los campos descripcion sean tipo texto
Tareas #709: Presupuesto descuentos de articulos para cada cliente

git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@136 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
2011-08-24 11:04:13 +00:00

223 lines
6.6 KiB
ObjectPascal
Raw Blame History

unit uEditorElegirArticulos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, uDADataTable, Menus, JvAppStorage, JvAppRegistryStorage,
JvComponentBase, JvFormPlacement, ImgList, PngImageList, StdActns,
ActnList, uCustomView, uViewBase, uViewGridBase, uViewGrid,
uViewArticulos, ComCtrls, TB2ExtItems, TBXExtItems, TBX,
TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls, JvExControls, JvComponent,
JvNavigationPane, uViewBarraSeleccion, StdCtrls,
uEditorArticulos, uBizArticulos, uIEditorElegirArticulos,
JvExComCtrls, JvStatusBar, uDAInterfaces, uEditorGridBase, uArticulosController;
type
TfEditorElegirArticulos = class(TfEditorGridBase, IEditorElegirArticulos)
frViewBarraSeleccion1: TfrViewBarraSeleccion;
lblTitle: TLabel;
lblComments: TLabel;
EditorSeleccionActionList: TActionList;
actBuscar2: TAction;
actQuitarFiltro2: TAction;
actAnchoAuto2: TAction;
pnlHeader: TPanel;
procedure frViewBarraSeleccion1actSeleccionarUpdate(Sender: TObject);
procedure frViewBarraSeleccion1actCancelarExecute(Sender: TObject);
procedure frViewBarraSeleccion1actSeleccionarExecute(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure actAnchoAuto2Execute(Sender: TObject);
procedure actQuitarFiltro2Execute(Sender: TObject);
private
FArticulos: IBizArticulo;
FController : IArticulosController;
protected
function GetArticulos: IBizArticulo;
procedure SetArticulos(const Value: IBizArticulo);
function GetController : IArticulosController; virtual;
procedure SetController (const Value : IArticulosController); virtual;
procedure SetMultiSelect (AValue : Boolean);
function GetMultiSelect : Boolean;
function GetArticulosSeleccionados: IBizArticulo;
procedure SetViewGrid(const Value: IViewGridBase); override;
procedure SetMensaje (const AValue: String);
function GetMensaje: String;
procedure NuevoInterno; override;
procedure ModificarInterno; override;
public
property Mensaje : String read GetMensaje write SetMensaje;
property ArticulosSeleccionados: IBizArticulo read GetArticulosSeleccionados;
property MultiSelect : Boolean read GetMultiSelect write SetMultiSelect;
property Articulos: IBizArticulo read GetArticulos write SetArticulos;
property Controller : IArticulosController read GetController write SetController;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
uses
cxGridCustomTableView, uIntegerListUtils, uDBSelectionListUtils,
uGridStatusUtils, uEditorBase;
{$R *.dfm}
{ TfEditorElegirArticulos }
procedure TfEditorElegirArticulos.actAnchoAuto2Execute(Sender: TObject);
begin
inherited;
actAnchoAuto.Execute;
end;
procedure TfEditorElegirArticulos.actQuitarFiltro2Execute(Sender: TObject);
begin
inherited;
actQuitarFiltro.Execute;
end;
constructor TfEditorElegirArticulos.Create(AOwner: TComponent);
begin
inherited;
end;
destructor TfEditorElegirArticulos.Destroy;
begin
FArticulos := NIL;
FController := NIl;
inherited;
end;
procedure TfEditorElegirArticulos.FormShow(Sender: TObject);
begin
inherited;
if not Assigned(ViewGrid) then
raise Exception.Create('No hay ninguna vista asignada');
if not Assigned(Articulos) then
raise Exception.Create('No hay ning<6E>n articulo asignado');
Articulos.DataTable.Active := True;
// EditorActionList.State := asSuspended;
end;
procedure TfEditorElegirArticulos.frViewBarraSeleccion1actCancelarExecute(
Sender: TObject);
begin
inherited;
Close;
end;
procedure TfEditorElegirArticulos.frViewBarraSeleccion1actSeleccionarExecute(
Sender: TObject);
begin
inherited;
ModalResult := mrOk;
end;
procedure TfEditorElegirArticulos.frViewBarraSeleccion1actSeleccionarUpdate(
Sender: TObject);
begin
inherited;
(Sender as TAction).Enabled := (ViewGrid._FocusedView.Controller.SelectedRowCount > 0)
end;
function TfEditorElegirArticulos.GetArticulos: IBizArticulo;
begin
Result := FArticulos;
end;
function TfEditorElegirArticulos.GetArticulosSeleccionados: IBizArticulo;
begin
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Articulos as ISeleccionable).SelectedRecords);
// En SelectedRecords tengo los ID de las filas seleccionadas del grid
Result := (Controller as IArticulosController).ExtraerSeleccionados(Articulos) as IBizArticulo;
end;
function TfEditorElegirArticulos.GetController: IArticulosController;
begin
Result := FController;
end;
function TfEditorElegirArticulos.GetMensaje: String;
begin
Result := lblComments.Caption;
end;
function TfEditorElegirArticulos.GetMultiSelect: Boolean;
begin
Result := ViewGrid.MultiSelect;
end;
procedure TfEditorElegirArticulos.ModificarInterno;
var
AArticulo: IBizArticulo;
begin
inherited;
AArticulo := FController.Buscar(Articulos.ID);
FController.Ver(AArticulo);
RefrescarInterno;
end;
procedure TfEditorElegirArticulos.NuevoInterno;
var
AArticulo: IBizArticulo;
begin
inherited;
AArticulo := FController.Nuevo;
if not AArticulo.DataTable.Active then
AArticulo.DataTable.Active := True;
FController.Ver(AArticulo);
RefrescarInterno;
end;
procedure TfEditorElegirArticulos.SetArticulos(const Value: IBizArticulo);
begin
FArticulos := Value;
dsDataTable.DataTable := FArticulos.DataTable;
//En el caso de no tener vista asignada le asignamos la de articulos para que en clientes se pueda usar este editor
if not Assigned(ViewGrid) then
ViewGrid := CreateView(TfrViewArticulos) as IViewArticulos;
(ViewGrid as IViewArticulos).Articulos := FArticulos;
end;
procedure TfEditorElegirArticulos.SetController(const Value: IArticulosController);
begin
FController := Value;
//En el caso de no tener vista asignada le asignamos la de articulos para que en clientes se pueda usar este editor
if not Assigned(ViewGrid) then
ViewGrid := CreateView(TfrViewArticulos) as IViewArticulos;
(ViewGrid as IViewArticulos).Controller := FController;
end;
procedure TfEditorElegirArticulos.SetMensaje(const AValue: String);
begin
lblComments.Caption := AValue;
end;
procedure TfEditorElegirArticulos.SetMultiSelect(AValue: Boolean);
begin
if Assigned(ViewGrid) then
ViewGrid.MultiSelect := AValue;
end;
procedure TfEditorElegirArticulos.SetViewGrid(const Value: IViewGridBase);
begin
inherited;
ViewGrid.OnDblClick := frViewBarraSeleccion1.actSeleccionar.OnExecute;
end;
end.