- Quitar warnings - Limpieza de PNGImageList en las vistas de grids. git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@374 0c75b7a4-871f-7646-8a2f-f78d34cc349f
396 lines
12 KiB
ObjectPascal
396 lines
12 KiB
ObjectPascal
unit uEditorPresupuestosCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Menus, DB, uDADataTable, JvAppStorage,
|
||
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
||
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
||
JvNavigationPane, uViewGrid, pngimage, JvComponentBase,
|
||
uEditorGridBase,
|
||
uBizPresupuestosCliente, uIEditorPresupuestosCliente, uPresupuestosClienteController,
|
||
uCustomView, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
||
uViewPresupuestosCliente, JvExComCtrls, JvStatusBar, JSDialog, StdCtrls,
|
||
uDAInterfaces;
|
||
|
||
type
|
||
TfEditorPresupuestosCliente = class(TfEditorGridBase, IEditorPresupuestosCliente)
|
||
actGenerarAlbaranCli: TAction;
|
||
actGenerarFactura: TAction;
|
||
TBXSubmenuItem2: TTBXSubmenuItem;
|
||
TBXSeparatorItem17: TTBXSeparatorItem;
|
||
TBXItem38: TTBXItem;
|
||
TBXItem39: TTBXItem;
|
||
N4: TMenuItem;
|
||
actGenerar: TAction;
|
||
Generar2: TMenuItem;
|
||
JsGenerarDialog: TJSDialog;
|
||
JsPrevisualizarDialog: TJSDialog;
|
||
JsImprimirDialog: TJSDialog;
|
||
TBXItem40: TTBXItem;
|
||
JsListaPresupuestosNoEliminados: TJSDialog;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actGenerarAlbaranCliExecute(Sender: TObject);
|
||
procedure actEliminarUpdate(Sender: TObject);
|
||
procedure actGenerarFacturaUpdate(Sender: TObject);
|
||
procedure actGenerarFacturaExecute(Sender: TObject);
|
||
procedure actGenerarPresupuestoProvExecute(Sender: TObject);
|
||
procedure actGenerarExecute(Sender: TObject);
|
||
procedure actGenerarUpdate(Sender: TObject);
|
||
|
||
protected
|
||
FPresupuestos: IBizPresupuestoCliente;
|
||
FController : IPresupuestosClienteController;
|
||
|
||
function GetPresupuestos: IBizPresupuestoCliente;
|
||
procedure SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
|
||
function GetController : IPresupuestosClienteController; virtual;
|
||
procedure SetController (const Value : IPresupuestosClienteController); virtual;
|
||
|
||
procedure NuevoInterno; override;
|
||
procedure ModificarInterno; override;
|
||
procedure EliminarInterno; override;
|
||
procedure DuplicarInterno; override;
|
||
procedure ImprimirInterno; override;
|
||
procedure PrevisualizarInterno; override;
|
||
|
||
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
||
//sobreescribir este metodo
|
||
procedure AsignarVista; virtual;
|
||
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
|
||
property Controller : IPresupuestosClienteController read GetController write SetController;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
uDataModulePresupuestosCliente, uDataModuleUsuarios, uFactuGES_App,
|
||
// uBizAlbaranesCliente, uAlbaranesClienteController,
|
||
uEditorBase, uEditorDBBase, uDialogUtils,
|
||
// uFacturasClienteController, uBizFacturasCliente,
|
||
uGridUtils, uDBSelectionListUtils;
|
||
// uGenerarPresupuestosProvUtils, uGenerarAlbaranesCliUtils;
|
||
|
||
|
||
{$R *.dfm}
|
||
|
||
{
|
||
*************************** TfEditorPresupuestosCliente ***************************
|
||
}
|
||
procedure TfEditorPresupuestosCliente.actEliminarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := (FPresupuestos.SITUACION = SITUACION_PRESUPUESTO_PENDIENTE);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarAlbaranCliExecute(Sender: TObject);
|
||
{var
|
||
IDAlbaranAux : Integer;}
|
||
begin
|
||
inherited;
|
||
// GenerarAlbaranCli(FPresupuestos.ID, IDAlbaranAux);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarExecute(Sender: TObject);
|
||
{var
|
||
Respuesta : Integer;}
|
||
begin
|
||
AppFactuGES.ShowCapado;
|
||
{
|
||
inherited;
|
||
|
||
Respuesta := JsGenerarDialog.Execute;
|
||
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsGenerarDialog.CustomButtonResult of
|
||
200 : begin // Generar uno o m<>s Presupuestos a proveedor
|
||
// actGenerarPresupuestoProv.Execute;
|
||
end;
|
||
100 : begin // Albaran nuevo
|
||
actGenerarAlbaranCli.Execute;
|
||
end;
|
||
end;
|
||
actRefrescar.Execute;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarFacturaExecute(Sender: TObject);
|
||
{
|
||
var
|
||
AFacturasController : IFacturasClienteController;
|
||
AFactura : IBizFacturaCliente;
|
||
}
|
||
begin
|
||
{
|
||
inherited;
|
||
AFacturasController := TFacturasClienteController.Create;
|
||
try
|
||
AFactura := AFacturasController.Nuevo;
|
||
if AFacturasController.Anadir(AFactura, FPresupuestos.ID) then
|
||
AFacturasController.Ver(AFactura);
|
||
actRefrescar.Execute;
|
||
finally
|
||
AFacturasController := NIL;
|
||
AFactura := NIL;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarFacturaUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := HayDatos
|
||
and ViewGrid.esSeleccionCeldaDatos
|
||
and (FPresupuestos.SITUACION = SITUACION_PRESUPUESTO_PENDIENTE);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarPresupuestoProvExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// GenerarPresupuestosProv(FPresupuestos);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.actGenerarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
(Sender as TAction).Enabled := HayDatos and
|
||
not (ViewGrid.NumSeleccionados > 1) and
|
||
ViewGrid.esSeleccionCeldaDatos and
|
||
(FPresupuestos.SITUACION <> SITUACION_PRESUPUESTO_ANULADO);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.AsignarVista;
|
||
begin
|
||
ViewGrid := CreateView(TfrViewPresupuestosCliente) as IViewPresupuestosCliente;
|
||
end;
|
||
|
||
constructor TfEditorPresupuestosCliente.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
AsignarVista;
|
||
end;
|
||
|
||
destructor TfEditorPresupuestosCliente.Destroy;
|
||
begin
|
||
FPresupuestos := NIL;
|
||
FController := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.DuplicarInterno;
|
||
var
|
||
APresupuesto : IBizPresupuestoCliente;
|
||
begin
|
||
inherited;
|
||
APresupuesto := FController.Duplicar(Presupuestos);
|
||
try
|
||
FController.Ver(APresupuesto);
|
||
finally
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.EliminarInterno;
|
||
var
|
||
APresupuestos: IBizPresupuestoCliente;
|
||
AllItems: Boolean;
|
||
begin
|
||
APresupuestos := Nil;
|
||
AllItems := False;
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
if AllItems then
|
||
begin
|
||
if (Application.MessageBox('<27>Desea borrar los presupuestos seleccionados?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Presupuestos as ISeleccionable).SelectedRecords);
|
||
APresupuestos := (Controller as IPresupuestosClienteController).ExtraerSeleccionados(Presupuestos) as IBizPresupuestoCliente;
|
||
end
|
||
end
|
||
else begin
|
||
if (Application.MessageBox('<27>Desea borrar el presupuesto seleccionado?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
APresupuestos := Presupuestos;
|
||
end;
|
||
|
||
if Assigned(APresupuestos) then
|
||
begin
|
||
FController.Eliminar(APresupuestos, AllItems);
|
||
if AllItems then
|
||
begin
|
||
if (APresupuestos.DataTable.RecordCount > 0) then
|
||
begin
|
||
with APresupuestos.DataTable do
|
||
begin
|
||
First;
|
||
while not EOF do
|
||
begin
|
||
// JsListaPresupuestosNoEliminados.Content.Add('Ref. Presupuesto: ' + APresupuestos.REFERENCIA + ' ' + APresupuestos.NOMBRE);
|
||
Next;
|
||
end;
|
||
end;
|
||
JsListaPresupuestosNoEliminados.Execute;
|
||
end;
|
||
actRefrescar.Execute;
|
||
end;
|
||
end;
|
||
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(ViewGrid) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Presupuestos) then
|
||
raise Exception.Create('No hay ning<6E>n Presupuesto asignado');
|
||
|
||
Presupuestos.DataTable.Active := True;
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
|
||
function TfEditorPresupuestosCliente.GetController: IPresupuestosClienteController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorPresupuestosCliente.GetPresupuestos: IBizPresupuestoCliente;
|
||
begin
|
||
Result := FPresupuestos;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.ImprimirInterno;
|
||
var
|
||
Respuesta : Integer;
|
||
APresupuestos: IBizPresupuestoCliente;
|
||
AllItems: Boolean;
|
||
begin
|
||
APresupuestos := Nil;
|
||
AllItems := False;
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
//Si esta agrupado solo podr<64> imprimir la lista de elementos visibles
|
||
if not ViewGrid.esSeleccionCeldaDatos then
|
||
inherited
|
||
else
|
||
begin
|
||
Respuesta := JsImprimirDialog.Execute;
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsImprimirDialog.CustomButtonResult of
|
||
200 : begin // Lista de elementos visibles
|
||
inherited;
|
||
end;
|
||
100 : begin // Elemento Seleccionado
|
||
if AllItems then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Presupuestos as ISeleccionable).SelectedRecords);
|
||
APresupuestos := (Controller as IPresupuestosClienteController).ExtraerSeleccionados(Presupuestos) as IBizPresupuestoCliente;
|
||
end
|
||
else
|
||
APresupuestos := Presupuestos;
|
||
|
||
if Assigned(APresupuestos) then
|
||
FController.Print(APresupuestos, AllItems);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.ModificarInterno;
|
||
begin
|
||
inherited;
|
||
FController.Ver(Presupuestos);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.NuevoInterno;
|
||
begin
|
||
inherited;
|
||
if FController.Anadir(Presupuestos) then
|
||
FController.Ver(Presupuestos);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
FTitulo := 'Lista de presupuestos de cliente - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
||
inherited PonerTitulos(FTitulo);
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.PrevisualizarInterno;
|
||
var
|
||
Respuesta : Integer;
|
||
APresupuestos: IBizPresupuestoCliente;
|
||
AllItems: Boolean;
|
||
begin
|
||
APresupuestos := Nil;
|
||
AllItems := False;
|
||
|
||
if MultiSelect and Assigned(ViewGrid) then
|
||
AllItems := (ViewGrid.NumSeleccionados > 1);
|
||
|
||
//Si esta agrupado solo podr<64> imprimir la lista de elementos visibles
|
||
if not ViewGrid.esSeleccionCeldaDatos then
|
||
inherited
|
||
else
|
||
begin
|
||
Respuesta := JsPrevisualizarDialog.Execute;
|
||
if Respuesta <> IDCANCEL then
|
||
begin
|
||
case JsPrevisualizarDialog.CustomButtonResult of
|
||
200 : begin // Lista de elementos visibles
|
||
inherited;
|
||
end;
|
||
100 : begin // Elemento Seleccionado
|
||
if AllItems then
|
||
begin
|
||
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Presupuestos as ISeleccionable).SelectedRecords);
|
||
APresupuestos := (Controller as IPresupuestosClienteController).ExtraerSeleccionados(Presupuestos) as IBizPresupuestoCliente;
|
||
end
|
||
else
|
||
APresupuestos := Presupuestos;
|
||
|
||
if Assigned(APresupuestos) then
|
||
FController.Preview(APresupuestos, AllItems);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
APresupuestos := Nil;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.SetController(const Value: IPresupuestosClienteController);
|
||
begin
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfEditorPresupuestosCliente.SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
begin
|
||
FPresupuestos := Value;
|
||
dsDataTable.DataTable := FPresupuestos.DataTable;
|
||
if Assigned(ViewGrid) then
|
||
(ViewGrid as IViewPresupuestosCliente).Presupuestos := Presupuestos;
|
||
end;
|
||
|
||
end.
|