150 lines
5.2 KiB
ObjectPascal
150 lines
5.2 KiB
ObjectPascal
|
|
unit uEditorCliente;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
uEditorContacto, ImgList, PngImageList, StdActns, ActnList, TBX,
|
|||
|
|
TB2Item, TB2Dock, TB2Toolbar, ComCtrls, JvExControls, JvComponent,
|
|||
|
|
JvNavigationPane, uViewCliente, uBizContactos, DB, uDADataTable,
|
|||
|
|
JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable, uCustomView,
|
|||
|
|
uViewBase, JvAppStorage, JvAppRegistryStorage,
|
|||
|
|
JvFormPlacement, ExtCtrls, pngimage, JvComponentBase, uViewContacto, StdCtrls,
|
|||
|
|
|
|||
|
|
uIEditorCliente, TBXStatusBars, JvExComCtrls, JvStatusBar,
|
|||
|
|
uViewDireccionesEntrega, uViewDetallesGenerico, uViewClienteDescuentos,
|
|||
|
|
uViewContactoDatosBancarios, dxLayoutLookAndFeels,
|
|||
|
|
uViewClienteDatosComerciales, uDAInterfaces, uViewSubCuentaContacto,
|
|||
|
|
uViewPersonalContacto, Grids, DBGrids;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorCliente = class(TfEditorContacto, IEditorCliente)
|
|||
|
|
frViewCliente1: TfrViewCliente;
|
|||
|
|
pagDirecciones: TTabSheet;
|
|||
|
|
frViewDireccionesEntrega1: TfrViewDireccionesEntrega;
|
|||
|
|
actGruposCliente: TAction;
|
|||
|
|
TBXItem7: TTBXItem;
|
|||
|
|
pagDescuentos: TTabSheet;
|
|||
|
|
frViewClienteDescuentos1: TfrViewClienteDescuentos;
|
|||
|
|
pagDatosComerciales: TTabSheet;
|
|||
|
|
frViewClienteDatosComerciales1: TfrViewClienteDatosComerciales;
|
|||
|
|
pagContabilidad: TTabSheet;
|
|||
|
|
frViewSubCuentaContacto1: TfrViewSubCuentaContacto;
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure actGruposClienteExecute(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
procedure GuardarInterno; override;
|
|||
|
|
procedure EliminarInterno; override;
|
|||
|
|
procedure SetContacto(const Value: IBizContacto); override;
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
{$R *.dfm}
|
|||
|
|
{$INCLUDE ..\..\..\FactuGES.inc}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uEditorItem, uEditorBase, uDataModuleUsuarios, uEditorDBItem, cxDBEdit,
|
|||
|
|
uGruposClienteController, uBizGruposCliente, uEditorDBBase, uDialogUtils,
|
|||
|
|
uClientesController;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.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;
|
|||
|
|
|
|||
|
|
constructor TfEditorCliente.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewContacto := frViewCliente1;
|
|||
|
|
|
|||
|
|
{$IFDEF CONTABILIDAD}
|
|||
|
|
pagContabilidad.TabVisible := true;
|
|||
|
|
{$ELSE}
|
|||
|
|
pagContabilidad.TabVisible := false;
|
|||
|
|
{$ENDIF}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.EliminarInterno;
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('<27>Desea borrar este cliente?', '') = IDYES) then
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
pgPaginas.ActivePageIndex := 0;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.GuardarInterno;
|
|||
|
|
begin
|
|||
|
|
//Si tiene al menos una subcuenta asociada se pone el flag el cliente a 1, asi podremos poner un icono en la lista de clientes
|
|||
|
|
//que tengan subcuenta asociada, y comprobar si al modificar no tene ya seleccionada una subcuenta en tal caso la crearemos si el
|
|||
|
|
//usuario lo desea.
|
|||
|
|
if ((Contacto as IBizCliente).SubCuentas.RecordCount <> 0) then
|
|||
|
|
(Controller as IClientesController).SetTieneSubCuenta(Contacto as IBizCliente, True)
|
|||
|
|
else
|
|||
|
|
(Controller as IClientesController).SetTieneSubCuenta(Contacto as IBizCliente, False);
|
|||
|
|
|
|||
|
|
//Evitamos que cada vez que se a<>ada un cliente te pregunta por defecto se crea y punto.
|
|||
|
|
//Otro caso es al modificar que si que hay que preguntar por si acaso desea asignar el manualmente una subcuenta existente
|
|||
|
|
if not Contacto.EsNuevo
|
|||
|
|
and (frViewSubCuentaContacto1.cbIgnorarContabilidad.EditValue = 0)
|
|||
|
|
and ((Contacto as IBizCliente).TIENE_SUBCUENTA = 0) then
|
|||
|
|
if (ShowConfirmMessage('Confirmaci<63>n de subcuenta', 'El cliente no tiene asignada ninguna subcuenta contable.' + #10#13 + '<27>Desea crear una nueva subcuenta para el cliente?') = IDNO) then
|
|||
|
|
(Controller as IClientesController).SetIgnorarContabilidad(Contacto as IBizCliente, True);
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
if Assigned(Contacto) then
|
|||
|
|
begin
|
|||
|
|
if Contacto.EsNuevo then
|
|||
|
|
FTitulo := 'Nuevo cliente'
|
|||
|
|
else
|
|||
|
|
FTitulo := 'Cliente';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
|
|||
|
|
if (Contacto as IBizCliente).BLOQUEADO = 1 then
|
|||
|
|
JvNavPanelHeader.Caption := JvNavPanelHeader.Caption + ' (Bloqueado)';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorCliente.SetContacto(const Value: IBizContacto);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(Contacto) then
|
|||
|
|
begin
|
|||
|
|
frViewDireccionesEntrega1.dsDetalles.DataTable := Contacto.Direcciones.DataTable;
|
|||
|
|
frViewClienteDescuentos1.dsDetalles.DataTable := (Contacto as IBizCliente).Descuentos.DataTable;
|
|||
|
|
frViewClienteDatosComerciales1.Contacto := Contacto;
|
|||
|
|
frViewSubCuentaContacto1.Contacto := Contacto;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
frViewDireccionesEntrega1.dsDetalles.DataTable := NIL;
|
|||
|
|
frViewClienteDescuentos1.dsDetalles.DataTable := NIL;
|
|||
|
|
frViewClienteDatosComerciales1.Contacto := NIL;
|
|||
|
|
frViewSubCuentaContacto1.Contacto := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|