309 lines
8.7 KiB
ObjectPascal
309 lines
8.7 KiB
ObjectPascal
|
|
unit uEditorPedidosCliente;
|
|||
|
|
|
|||
|
|
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,
|
|||
|
|
uBizPedidosCliente, uIEditorPedidosCliente, uPedidosClienteController,
|
|||
|
|
uCustomView, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
|||
|
|
uViewPedidosCliente, JvExComCtrls, JvStatusBar, JSDialog, StdCtrls;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorPedidosCliente = class(TfEditorGridBase, IEditorPedidosCliente)
|
|||
|
|
actGenerarAlbaranCli: TAction;
|
|||
|
|
actGenerarFactura: TAction;
|
|||
|
|
actGenerarPedidoProv: TAction;
|
|||
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|||
|
|
TBXSeparatorItem17: TTBXSeparatorItem;
|
|||
|
|
TBXItem38: TTBXItem;
|
|||
|
|
TBXItem39: TTBXItem;
|
|||
|
|
N4: TMenuItem;
|
|||
|
|
TBXSeparatorItem18: TTBXSeparatorItem;
|
|||
|
|
actGenerar: TAction;
|
|||
|
|
TBXItem43: TTBXItem;
|
|||
|
|
Generar2: TMenuItem;
|
|||
|
|
JsGenerarDialog: TJSDialog;
|
|||
|
|
JsPrevisualizarDialog: TJSDialog;
|
|||
|
|
JsImprimirDialog: TJSDialog;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure actGenerarAlbaranCliExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|||
|
|
procedure actGenerarFacturaUpdate(Sender: TObject);
|
|||
|
|
procedure actGenerarFacturaExecute(Sender: TObject);
|
|||
|
|
procedure actGenerarPedidoProvExecute(Sender: TObject);
|
|||
|
|
procedure actGenerarExecute(Sender: TObject);
|
|||
|
|
procedure actGenerarUpdate(Sender: TObject);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
FPedidos: IBizPedidoCliente;
|
|||
|
|
FController : IPedidosClienteController;
|
|||
|
|
|
|||
|
|
function GetPedidos: IBizPedidoCliente;
|
|||
|
|
procedure SetPedidos(const Value: IBizPedidoCliente);
|
|||
|
|
|
|||
|
|
function GetController : IPedidosClienteController; virtual;
|
|||
|
|
procedure SetController (const Value : IPedidosClienteController); 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 Pedidos: IBizPedidoCliente read GetPedidos write SetPedidos;
|
|||
|
|
property Controller : IPedidosClienteController read GetController write SetController;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModulePedidosCliente, uDataModuleUsuarios, uBizAlbaranesCliente,
|
|||
|
|
uAlbaranesClienteController, uEditorBase, uEditorDBBase, uDialogUtils,
|
|||
|
|
uFacturasClienteController, uBizFacturasCliente,
|
|||
|
|
uGenerarPedidosProvUtils, uGenerarAlbaranesCliUtils;
|
|||
|
|
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
*************************** TfEditorPedidosCliente ***************************
|
|||
|
|
}
|
|||
|
|
procedure TfEditorPedidosCliente.actEliminarUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if (Sender as TAction).Enabled then
|
|||
|
|
(Sender as TAction).Enabled := HayDatos
|
|||
|
|
and (FPedidos.SITUACION = SITUACION_PEDIDO_PENDIENTE);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarAlbaranCliExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
GenerarAlbaranCli(FPedidos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
Respuesta : Integer;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
Respuesta := JsGenerarDialog.Execute;
|
|||
|
|
|
|||
|
|
if Respuesta <> IDCANCEL then
|
|||
|
|
begin
|
|||
|
|
case JsGenerarDialog.CustomButtonResult of
|
|||
|
|
200 : begin // Generar uno o m<>s pedidos a proveedor
|
|||
|
|
actGenerarPedidoProv.Execute;
|
|||
|
|
end;
|
|||
|
|
100 : begin // Albaran nuevo
|
|||
|
|
actGenerarAlbaranCli.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarFacturaExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AFacturasController : IFacturasClienteController;
|
|||
|
|
AFactura : IBizFacturaCliente;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AFacturasController := TFacturasClienteController.Create;
|
|||
|
|
try
|
|||
|
|
AFactura := AFacturasController.Nuevo;
|
|||
|
|
if AFacturasController.Anadir(AFactura, FPedidos.ID) then
|
|||
|
|
AFacturasController.Ver(AFactura);
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
finally
|
|||
|
|
AFacturasController := NIL;
|
|||
|
|
AFactura := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarFacturaUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := HayDatos
|
|||
|
|
and ViewGrid.esSeleccionCeldaDatos
|
|||
|
|
and (FPedidos.SITUACION = SITUACION_PEDIDO_PENDIENTE);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarPedidoProvExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
GenerarPedidosProv(FPedidos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.actGenerarUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := HayDatos and
|
|||
|
|
ViewGrid.esSeleccionCeldaDatos and
|
|||
|
|
(FPedidos.SITUACION <> SITUACION_PEDIDO_SERVIDO);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.AsignarVista;
|
|||
|
|
begin
|
|||
|
|
ViewGrid := CreateView(TfrViewPedidosCliente) as IViewPedidosCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorPedidosCliente.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AsignarVista;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorPedidosCliente.Destroy;
|
|||
|
|
begin
|
|||
|
|
FPedidos := NIL;
|
|||
|
|
FController := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.DuplicarInterno;
|
|||
|
|
var
|
|||
|
|
APedido : IBizPedidoCliente;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
APedido := FController.Duplicar(Pedidos);
|
|||
|
|
try
|
|||
|
|
FController.Ver(APedido);
|
|||
|
|
finally
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.EliminarInterno;
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('<27>Desea borrar este pedido de cliente?', '') = IDYES) then
|
|||
|
|
begin
|
|||
|
|
FController.Eliminar(Pedidos);
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(ViewGrid) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(Pedidos) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n pedido asignado');
|
|||
|
|
|
|||
|
|
Pedidos.DataTable.Active := True;
|
|||
|
|
ViewGrid.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorPedidosCliente.GetController: IPedidosClienteController;
|
|||
|
|
begin
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorPedidosCliente.GetPedidos: IBizPedidoCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FPedidos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.ImprimirInterno;
|
|||
|
|
var
|
|||
|
|
Respuesta : Integer;
|
|||
|
|
begin
|
|||
|
|
//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
|
|||
|
|
FController.Print(FPedidos);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.ModificarInterno;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FController.Ver(Pedidos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.NuevoInterno;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if FController.Anadir(Pedidos) then
|
|||
|
|
FController.Ver(Pedidos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
FTitulo := 'Lista de pedidos de cliente - ' + dmUsuarios.EmpresaActual.NOMBRE;
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.PrevisualizarInterno;
|
|||
|
|
var
|
|||
|
|
Respuesta : Integer;
|
|||
|
|
begin
|
|||
|
|
//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
|
|||
|
|
FController.Preview(FPedidos);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.SetController(const Value: IPedidosClienteController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorPedidosCliente.SetPedidos(const Value: IBizPedidoCliente);
|
|||
|
|
begin
|
|||
|
|
FPedidos := Value;
|
|||
|
|
dsDataTable.DataTable := FPedidos.DataTable;
|
|||
|
|
if Assigned(ViewGrid) then
|
|||
|
|
(ViewGrid as IViewPedidosCliente).Pedidos := Pedidos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|