2007-11-16 20:58:56 +00:00
|
|
|
|
unit uEditorAlbaranesProveedor;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, 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,
|
|
|
|
|
|
uBizAlbaranesProveedor, uIEditorAlbaranesProveedor, uAlbaranesProveedorController,
|
|
|
|
|
|
uCustomView, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
2007-11-17 13:14:53 +00:00
|
|
|
|
uViewAlbaranesProveedor, JvExComCtrls, JvStatusBar, JSDialog, uDAInterfaces;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorAlbaranesProveedor = class(TfEditorGridBase, IEditorAlbaranesProveedor)
|
|
|
|
|
|
actGenerarFactura: TAction;
|
|
|
|
|
|
JsNuevoAlbaranDialog: TJSDialog;
|
|
|
|
|
|
JsPrevisualizarDialog: TJSDialog;
|
|
|
|
|
|
JsImprimirDialog: TJSDialog;
|
|
|
|
|
|
TBXItem39: TTBXItem;
|
|
|
|
|
|
JsListaAlbaranesNoEliminados: TJSDialog;
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure actGenerarFacturaExecute(Sender: TObject);
|
|
|
|
|
|
procedure actGenerarFacturaUpdate(Sender: TObject);
|
|
|
|
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
FAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
FController : IAlbaranesProveedorController;
|
|
|
|
|
|
|
|
|
|
|
|
function GetAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
procedure SetAlbaranes(const Value: IBizAlbaranProveedor);
|
|
|
|
|
|
|
|
|
|
|
|
function GetController : IAlbaranesProveedorController; virtual;
|
|
|
|
|
|
procedure SetController (const Value : IAlbaranesProveedorController); virtual;
|
|
|
|
|
|
|
|
|
|
|
|
procedure NuevoInterno; override;
|
|
|
|
|
|
procedure ModificarInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
procedure DuplicarInterno; override;
|
|
|
|
|
|
procedure PrevisualizarInterno; override;
|
|
|
|
|
|
procedure ImprimirInterno; 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 Albaranes: IBizAlbaranProveedor read GetAlbaranes write SetAlbaranes;
|
|
|
|
|
|
property Controller : IAlbaranesProveedorController read GetController write SetController;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2007-11-18 15:10:09 +00:00
|
|
|
|
uDataModuleAlbaranesProveedor, uDataModuleUsuarios, uFactuGES_App,
|
2007-11-17 13:14:53 +00:00
|
|
|
|
// uGenerarFacturasProvAlbProvUtils, uGenerarAlbaranesProvUtils,
|
|
|
|
|
|
uEditorBase, schAlbaranesProveedorClient_Intf,
|
2007-11-16 20:58:56 +00:00
|
|
|
|
uGridUtils, uDBSelectionListUtils;
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
*************************** TfEditorAlbaranesProveedor ***************************
|
|
|
|
|
|
}
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.actEliminarUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if (Sender as TAction).Enabled then
|
|
|
|
|
|
(Sender as TAction).Enabled := not (FAlbaranes.ID_FACTURA > 0)
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.actGenerarFacturaExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
2007-11-19 19:13:37 +00:00
|
|
|
|
AppFactuGES.ShowCapado;
|
|
|
|
|
|
{
|
2007-11-16 20:58:56 +00:00
|
|
|
|
inherited;
|
2007-11-17 13:14:53 +00:00
|
|
|
|
// GenerarFacturaProv(Albaranes.ID);
|
2007-11-19 19:13:37 +00:00
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
}
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.actGenerarFacturaUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Enabled := HayDatos
|
|
|
|
|
|
and not (ViewGrid.NumSeleccionados > 1)
|
|
|
|
|
|
and (Albaranes.REF_FACTURA = '')
|
|
|
|
|
|
and ViewGrid.esSeleccionCeldaDatos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.AsignarVista;
|
|
|
|
|
|
begin
|
|
|
|
|
|
ViewGrid := CreateView(TfrViewAlbaranesProveedor) as IViewAlbaranesProveedor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TfEditorAlbaranesProveedor.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
AsignarVista;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorAlbaranesProveedor.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlbaranes := NIL;
|
|
|
|
|
|
FController := NIL;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.DuplicarInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
AAlbaran : IBizAlbaranProveedor;
|
|
|
|
|
|
begin
|
2007-11-19 19:13:37 +00:00
|
|
|
|
AppFactuGES.ShowCapado;
|
|
|
|
|
|
{
|
2007-11-16 20:58:56 +00:00
|
|
|
|
inherited;
|
|
|
|
|
|
AAlbaran := FController.Duplicar(Albaranes);
|
|
|
|
|
|
try
|
|
|
|
|
|
FController.Ver(AAlbaran);
|
|
|
|
|
|
finally
|
|
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
2007-11-19 19:13:37 +00:00
|
|
|
|
}
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.EliminarInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
AAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
AllItems: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AAlbaranes := Nil;
|
|
|
|
|
|
AllItems := False;
|
|
|
|
|
|
|
|
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
|
|
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
|
|
|
|
|
|
|
|
if AllItems then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar los albaranes de proveedor seleccionados?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Albaranes as ISeleccionable).SelectedRecords);
|
|
|
|
|
|
AAlbaranes := (Controller as IAlbaranesProveedorController).ExtraerSeleccionados(Albaranes) as IBizAlbaranProveedor;
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
else begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar el albar<61>n de proveedor seleccionado?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
AAlbaranes := Albaranes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(AAlbaranes) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController.Eliminar(AAlbaranes, AllItems);
|
|
|
|
|
|
if AllItems then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (AAlbaranes.DataTable.RecordCount > 0) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
with AAlbaranes.DataTable do
|
|
|
|
|
|
begin
|
|
|
|
|
|
First;
|
|
|
|
|
|
while not EOF do
|
|
|
|
|
|
begin
|
|
|
|
|
|
JsListaAlbaranesNoEliminados.Content.Add('Ref. albar<61>n: ' + AAlbaranes.REFERENCIA + ' ' + AAlbaranes.NOMBRE);
|
|
|
|
|
|
Next;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
JsListaAlbaranesNoEliminados.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
ViewGrid.GotoFirst;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(ViewGrid) then
|
|
|
|
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(Albaranes) then
|
|
|
|
|
|
raise Exception.Create('No hay ning<6E>n albar<61>n asignado');
|
|
|
|
|
|
|
|
|
|
|
|
Albaranes.DataTable.Active := True;
|
|
|
|
|
|
ViewGrid.GotoFirst;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorAlbaranesProveedor.GetController: IAlbaranesProveedorController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.ImprimirInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
Respuesta : Integer;
|
|
|
|
|
|
AAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
AllItems: Boolean;
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
2007-11-19 19:13:37 +00:00
|
|
|
|
AppFactuGES.ShowCapado;
|
|
|
|
|
|
{
|
2007-11-16 20:58:56 +00:00
|
|
|
|
AAlbaranes := 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, (Albaranes as ISeleccionable).SelectedRecords);
|
|
|
|
|
|
AAlbaranes := (Controller as IAlbaranesProveedorController).ExtraerSeleccionados(Albaranes) as IBizAlbaranProveedor;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
AAlbaranes := Albaranes;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(AAlbaranes) then
|
|
|
|
|
|
FController.Print(AAlbaranes, AllItems);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2007-11-19 19:13:37 +00:00
|
|
|
|
}
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorAlbaranesProveedor.GetAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAlbaranes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.ModificarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
FController.Ver(Albaranes);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.NuevoInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
Respuesta : Integer;
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
Respuesta := JsNuevoAlbaranDialog.Execute;
|
|
|
|
|
|
|
|
|
|
|
|
if Respuesta <> IDCANCEL then
|
|
|
|
|
|
begin
|
|
|
|
|
|
case JsNuevoAlbaranDialog.CustomButtonResult of
|
|
|
|
|
|
200 : begin // Utilizar un pedido
|
2007-11-17 13:14:53 +00:00
|
|
|
|
// GenerarAlbaranProv;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
100 : begin // Albaran nuevo vacio
|
|
|
|
|
|
if FController.Anadir(Albaranes) then
|
|
|
|
|
|
FController.Ver(Albaranes);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.PonerTitulos(const ATitulo: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
FTitulo : String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (ATitulo = '') then
|
2007-11-18 15:10:09 +00:00
|
|
|
|
FTitulo := 'Lista de albaranes de proveedor - ' + AppFactuGES.EmpresaActiva.NOMBRE
|
2007-11-16 20:58:56 +00:00
|
|
|
|
else
|
|
|
|
|
|
FTitulo := ATitulo;
|
|
|
|
|
|
|
|
|
|
|
|
inherited PonerTitulos(FTitulo);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.PrevisualizarInterno;
|
|
|
|
|
|
var
|
|
|
|
|
|
Respuesta : Integer;
|
|
|
|
|
|
AAlbaranes: IBizAlbaranProveedor;
|
|
|
|
|
|
AllItems: Boolean;
|
|
|
|
|
|
begin
|
2007-11-19 19:13:37 +00:00
|
|
|
|
AppFactuGES.ShowCapado;
|
|
|
|
|
|
{
|
2007-11-16 20:58:56 +00:00
|
|
|
|
AAlbaranes := 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, (Albaranes as ISeleccionable).SelectedRecords);
|
|
|
|
|
|
AAlbaranes := (Controller as IAlbaranesProveedorController).ExtraerSeleccionados(Albaranes) as IBizAlbaranProveedor;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
AAlbaranes := Albaranes;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(AAlbaranes) then
|
|
|
|
|
|
FController.Preview(AAlbaranes, AllItems);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2007-11-19 19:13:37 +00:00
|
|
|
|
}
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.SetController(const Value: IAlbaranesProveedorController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesProveedor.SetAlbaranes(const Value: IBizAlbaranProveedor);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlbaranes := Value;
|
|
|
|
|
|
dsDataTable.DataTable := FAlbaranes.DataTable;
|
|
|
|
|
|
if Assigned(ViewGrid) then
|
|
|
|
|
|
(ViewGrid as IViewAlbaranesProveedor).Albaranes := Albaranes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|