git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@21 40301925-124e-1c4e-b97d-170ad7a8785b
260 lines
8.1 KiB
ObjectPascal
260 lines
8.1 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;
|
|
actLOPD: TAction;
|
|
TBXItem38: TTBXItem;
|
|
procedure actGruposClienteExecute(Sender: TObject);
|
|
procedure actLOPDExecute(Sender: TObject);
|
|
procedure actLOPDUpdate(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;
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
{
|
|
******************************* TfEditorClientes *******************************
|
|
}
|
|
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.actLOPDExecute(Sender: TObject);
|
|
var
|
|
AClientes: IBizCliente;
|
|
AListaClientesNoModificados: TStringList;
|
|
i: integer;
|
|
|
|
begin
|
|
inherited;
|
|
|
|
ViewGrid.SaveGridStatus;
|
|
try
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
|
|
AClientes := (Controller as IClientesController).ExtraerSeleccionados(Contactos) as IBizCliente;
|
|
finally
|
|
ViewGrid.RestoreGridStatus;
|
|
end;
|
|
|
|
if (Controller as IClientesController).AsignarLOPD(AClientes) then
|
|
RefrescarInterno;
|
|
end;
|
|
|
|
procedure TfEditorClientes.actLOPDUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
|
|
if HayDatos and Assigned(ViewGrid) then
|
|
(Sender as TAction).Enabled := not (dsDataTable.DataTable.State in dsEditModes)
|
|
and ViewGrid.esSeleccionCeldaDatos
|
|
and (ViewGrid.NumSeleccionados > 0)
|
|
else
|
|
(Sender as TAction).Enabled := False;
|
|
|
|
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
|
|
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).PrintInformeEtiquetas(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
|
|
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).PreviewInformeEtiquetas(AClientes, AllItems);
|
|
end;
|
|
{
|
|
300 : 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).PreviewInformeListaDatosContacto(AClientes, AllItems);
|
|
end;
|
|
}
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|