AbetoDesign_FactuGES2/Source/Modulos/Contactos/Views/uEditorClientes.pas

286 lines
8.6 KiB
ObjectPascal

unit uEditorClientes;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
uEditorContactos, Menus, ImgList, PngImageList, StdActns,
ActnList, TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar,
JvExControls, JvComponent, JvNavigationPane, DB, uDADataTable,
JvFormAutoSize, ComCtrls, uDAScriptingProvider, uDACDSDataTable, StdCtrls,
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, uCustomView,
uViewBase, uViewBarraSeleccion, ExtCtrls, pngimage, JvComponentBase,
uIEditorClientes, uViewGridBase, uViewGrid, uViewContactos, uViewClientes,
TBXStatusBars, JvExComCtrls, JvStatusBar, JSDialog, uDAInterfaces;
type
TfEditorClientes = class(TfEditorContactos, IEditorClientes)
JsPrevisualizarDialog: TJSDialog;
JsImprimirDialog: TJSDialog;
actGruposCliente: TAction;
JsListaContactosNoEliminados: TJSDialog;
frViewClientes1: TfrViewClientes;
actInformes: TAction;
TBXItem38: TTBXItem;
JSInformesDialog: TJSDialog;
actCambiarPrecioPunto: TAction;
TBXSeparatorItem17: TTBXSeparatorItem;
TBXItem39: TTBXItem;
procedure actGruposClienteExecute(Sender: TObject);
procedure actInformesExecute(Sender: TObject);
procedure actCambiarPrecioPuntoExecute(Sender: TObject);
procedure actCambiarPrecioPuntoUpdate(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
uGridUtils, uDataModuleContactos, uDMBase, uEditorGridBase, uBizContactos,
uDBSelectionListUtils, uDataModuleUsuarios, uDialogUtils, uFactuGES_App,
uGruposClienteController, uBizGruposCliente, uClientesController, uGestorInformesController,
uEditorAsignarPrecioPunto, Dialogs;
{$R *.dfm}
{
******************************* TfEditorClientes *******************************
}
procedure TfEditorClientes.actCambiarPrecioPuntoExecute(Sender: TObject);
var
AClientes: IBizCliente;
AllItems: Boolean;
APrecioPunto: Variant;
begin
AClientes := Nil;
AllItems := False;
if MultiSelect and Assigned(ViewGrid) then
AllItems := (ViewGrid.NumSeleccionados > 1);
if AsignarPrecioPunto(APrecioPunto) then
begin
if AllItems then
begin
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
AClientes := (Controller as IClientesController).ExtraerSeleccionados(Contactos) as IBizCliente;
end
else
AClientes := (Contactos as IBizCliente);
(Controller as IClientesController).AsignarPrecioPunto(AClientes, APrecioPunto, AllItems);
// ShowMessage(APrecioPunto);
actRefrescar.Execute;
end;
end;
procedure TfEditorClientes.actCambiarPrecioPuntoUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Enabled := HayDatos
and ViewGrid.esSeleccionCeldaDatos;
end;
procedure TfEditorClientes.actGruposClienteExecute(Sender: TObject);
var
AGruposController : IGruposClienteController;
AGrupos : IBizGrupoCliente;
begin
AGruposController := TGruposClienteController.Create;
try
AGrupos := (AGruposController.BuscarTodos as IBizGrupoCliente);
AGruposController.VerTodos(AGrupos);
finally
AGrupos := NIL;
AGruposController := NIL;
end;
end;
procedure TfEditorClientes.actInformesExecute(Sender: TObject);
var
Respuesta : Integer;
AGestorInformesController : IGestorInformesController;
begin
AGestorInformesController := TGestorInformesController.Create;
try
Respuesta := JsInformesDialog.Execute;
if Respuesta <> IDCANCEL then
begin
case JsInformesDialog.CustomButtonResult of
400 : begin // Listado de facturas de cliente
AGestorInformesController.VerInformeListadoFacturasRecibosCli(Contactos.ID);
end;
end;
end;
finally
AGestorInformesController := NIL;
end;
end;
constructor TfEditorClientes.Create(AOwner: TComponent);
begin
inherited;
ViewGrid := frViewClientes1;
end;
procedure TfEditorClientes.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('¿Desea borrar los clientes seleccionados?', 'Atención', MB_YESNO) = IDYES) then
begin
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
AContactos := (Controller as IClientesController).ExtraerSeleccionados(Contactos) as IBizContacto;
end
end
else begin
if (Application.MessageBox('¿Desea borrar el cliente seleccionado?', 'Atención', MB_YESNO) = IDYES) then
AContactos := Contactos;
end;
if Assigned(AContactos) then
begin
(FController as IClientesController).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 TfEditorClientes.ImprimirInterno;
var
Respuesta : Integer;
AClientes: IBizCliente;
AllItems: Boolean;
begin
inherited;
//Desactivamos la impresion de etiquetas
{
AClientes := Nil;
AllItems := False;
if MultiSelect and Assigned(ViewGrid) then
AllItems := (ViewGrid.NumSeleccionados > 1);
//Si esta agrupado solo podré 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);
AClientes := (Controller as IClientesController).ExtraerSeleccionados(Contactos) as IBizCliente;
end
else
AClientes := (Contactos as IBizCliente);
if Assigned(AClientes) then
(FController as IClientesController).Print(AClientes, AllItems);
end;
end;
end;
end;
}
end;
procedure TfEditorClientes.PonerTitulos(const ATitulo: string);
var
FTitulo : String;
begin
FTitulo := 'Lista de clientes - ' + AppFactuGES.EmpresaActiva.NOMBRE;
inherited PonerTitulos(FTitulo);
end;
procedure TfEditorClientes.PrevisualizarInterno;
var
Respuesta : Integer;
AClientes: IBizCliente;
AllItems: Boolean;
begin
inherited;
//Desactivamos la impresion de etiquetas
{
AClientes := Nil;
AllItems := False;
if MultiSelect and Assigned(ViewGrid) then
AllItems := (ViewGrid.NumSeleccionados > 1);
//Si esta agrupado solo podré 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);
AClientes := (Controller as IClientesController).ExtraerSeleccionados(Contactos) as IBizCliente;
end
else
AClientes := (Contactos as IBizCliente);
if Assigned(AClientes) then
(FController as IClientesController).Preview(AClientes, AllItems);
end;
end;
end;
end;
}
end;
end.