254 lines
8.1 KiB
ObjectPascal
254 lines
8.1 KiB
ObjectPascal
|
|
unit uEditorProveedores;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
uEditorContactos, Menus, DB, uDADataTable, JvAppStorage,
|
|||
|
|
JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList, PngImageList,
|
|||
|
|
StdActns, ActnList, uCustomView, uViewBase, uViewBarraSeleccion, ComCtrls,
|
|||
|
|
TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls,
|
|||
|
|
JvExControls, JvComponent, JvNavigationPane,
|
|||
|
|
|
|||
|
|
uIEditorProveedores, uViewGridBase, uViewGrid, uViewContactos, uViewProveedores,
|
|||
|
|
pngimage, TBXStatusBars, JvExComCtrls, JvStatusBar, JSDialog, uDAInterfaces;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorProveedores = class(TfEditorContactos, IEditorProveedores)
|
|||
|
|
frViewProveedores1: TfrViewProveedores;
|
|||
|
|
JsPrevisualizarDialog: TJSDialog;
|
|||
|
|
JsImprimirDialog: TJSDialog;
|
|||
|
|
JsListaContactosNoEliminados: TJSDialog;
|
|||
|
|
actDocumentosPedidos: TAction;
|
|||
|
|
actDocumentosAlbaranes: TAction;
|
|||
|
|
actDocumentosDevoluciones: TAction;
|
|||
|
|
actDocumentosFacturas: TAction;
|
|||
|
|
actDocumentosRecibos: TAction;
|
|||
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|||
|
|
TBXItem38: TTBXItem;
|
|||
|
|
TBXItem39: TTBXItem;
|
|||
|
|
TBXItem40: TTBXItem;
|
|||
|
|
TBXItem41: TTBXItem;
|
|||
|
|
TBXItem42: TTBXItem;
|
|||
|
|
TBXSubmenuItem3: TTBXSubmenuItem;
|
|||
|
|
TBXItem43: TTBXItem;
|
|||
|
|
TBXItem44: TTBXItem;
|
|||
|
|
TBXItem45: TTBXItem;
|
|||
|
|
TBXItem46: TTBXItem;
|
|||
|
|
TBXItem47: TTBXItem;
|
|||
|
|
Documentosrelacionados1: TMenuItem;
|
|||
|
|
Pedidos1: TMenuItem;
|
|||
|
|
Albaranes1: TMenuItem;
|
|||
|
|
Devoluciones1: TMenuItem;
|
|||
|
|
Facturas1: TMenuItem;
|
|||
|
|
Recibos1: TMenuItem;
|
|||
|
|
procedure actDocumentosPedidosUpdate(Sender: TObject);
|
|||
|
|
procedure actDocumentosPedidosExecute(Sender: TObject);
|
|||
|
|
procedure actDocumentosAlbaranesExecute(Sender: TObject);
|
|||
|
|
procedure actDocumentosDevolucionesExecute(Sender: TObject);
|
|||
|
|
procedure actDocumentosFacturasExecute(Sender: TObject);
|
|||
|
|
procedure actDocumentosRecibosExecute(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
procedure ImprimirInterno; override;
|
|||
|
|
procedure PrevisualizarInterno; override;
|
|||
|
|
procedure EliminarInterno; override;
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uGridStatusUtils, uEditorGridBase, uDataModuleUsuarios, uDialogUtils, uBizContactos,
|
|||
|
|
uDBSelectionListUtils, uProveedoresController, uFactuGES_App;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{ TfEditorProveedores }
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosAlbaranesExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(FController as IProveedoresController).VerAlbaranesDeProveedor(IBizProveedor(FContactos));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosDevolucionesExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(FController as IProveedoresController).VerDevolucionesDeProveedor(IBizProveedor(FContactos));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosFacturasExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(FController as IProveedoresController).VerFacturasDeProveedor(IBizProveedor(FContactos));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosPedidosExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(FController as IProveedoresController).VerPedidosDeProveedor(IBizProveedor(FContactos));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosPedidosUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := HayDatos
|
|||
|
|
and not ViewGrid.IsEmpty
|
|||
|
|
and ViewGrid.EsSeleccionCeldaDatos
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.actDocumentosRecibosExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(FController as IProveedoresController).VerRecibosDeProveedor(IBizProveedor(FContactos));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorProveedores.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewGrid := frViewProveedores1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.EliminarInterno;
|
|||
|
|
var
|
|||
|
|
AContactos: IBizContacto;
|
|||
|
|
AllItems: Boolean;
|
|||
|
|
begin
|
|||
|
|
AContactos := Nil;
|
|||
|
|
AllItems := False;
|
|||
|
|
|
|||
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|||
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|||
|
|
|
|||
|
|
if AllItems then
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar los proveedores seleccionados?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
begin
|
|||
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
|
|||
|
|
AContactos := (Controller as IProveedoresController).ExtraerSeleccionados(Contactos) as IBizContacto;
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar el proveedor seleccionado?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
AContactos := Contactos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Assigned(AContactos) then
|
|||
|
|
begin
|
|||
|
|
(FController as IProveedoresController).Eliminar(AContactos, AllItems);
|
|||
|
|
if AllItems then
|
|||
|
|
begin
|
|||
|
|
if (AContactos.DataTable.RecordCount > 0) then
|
|||
|
|
begin
|
|||
|
|
with AContactos.DataTable do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
JsListaContactosNoEliminados.Content.Add('Cliente: ' + AContactos.NOMBRE);
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
JsListaContactosNoEliminados.Execute;
|
|||
|
|
end;
|
|||
|
|
actRefrescar.Execute;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
ViewGrid.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.ImprimirInterno;
|
|||
|
|
var
|
|||
|
|
Respuesta : Integer;
|
|||
|
|
AProveedores: IBizProveedor;
|
|||
|
|
AllItems: Boolean;
|
|||
|
|
begin
|
|||
|
|
AProveedores := 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, (Contactos as ISeleccionable).SelectedRecords);
|
|||
|
|
AProveedores := (Controller as IProveedoresController).ExtraerSeleccionados(Contactos) as IBizProveedor;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
AProveedores := (Contactos as IBizProveedor);
|
|||
|
|
|
|||
|
|
if Assigned(AProveedores) then
|
|||
|
|
(FController as IProveedoresController).Print(AProveedores, AllItems);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
FTitulo := 'Lista de proveedores - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedores.PrevisualizarInterno;
|
|||
|
|
var
|
|||
|
|
Respuesta : Integer;
|
|||
|
|
AProveedores: IBizProveedor;
|
|||
|
|
AllItems: Boolean;
|
|||
|
|
begin
|
|||
|
|
AProveedores := 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, (Contactos as ISeleccionable).SelectedRecords);
|
|||
|
|
AProveedores := (Controller as IProveedoresController).ExtraerSeleccionados(Contactos) as IBizProveedor;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
AProveedores := (Contactos as IBizProveedor);
|
|||
|
|
|
|||
|
|
if Assigned(AProveedores) then
|
|||
|
|
(FController as IProveedoresController).Preview(AProveedores, AllItems);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|