348 lines
11 KiB
ObjectPascal
348 lines
11 KiB
ObjectPascal
|
|
unit uViewDireccionEntregaContratoCli;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, uBizContratosCliente, cxGraphics, dxLayoutControl, cxMemo,
|
|||
|
|
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit,
|
|||
|
|
cxDBLookupEdit, cxDBLookupComboBox, StdCtrls, cxControls, DB, uDADataTable,
|
|||
|
|
ActnList, uContratosClienteController, Buttons, uDAInterfaces, uClientesController,
|
|||
|
|
uDireccionesContactoController, uBizContactosDirecciones;
|
|||
|
|
// uBizAlmacenes, uAlmacenesController;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewDireccionEntregaContratoCli = interface(IViewBase)
|
|||
|
|
['{07B3EA98-62DA-4BAD-8F45-24FBEB2236EF}']
|
|||
|
|
function GetContratoCliente: IBizContratoCliente;
|
|||
|
|
procedure SetContratoCliente(const Value: IBizContratoCliente);
|
|||
|
|
property ContratoCliente: IBizContratoCliente read GetContratoCliente write SetContratoCliente;
|
|||
|
|
procedure RefrescarDireccion;
|
|||
|
|
procedure CambioDireccionAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewDireccionEntregaContratoCli = class(TfrViewBase, IViewDireccionEntregaContratoCli)
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
rdxDestino1: TRadioButton;
|
|||
|
|
rdxDestino2: TRadioButton;
|
|||
|
|
cbLista: TcxDBLookupComboBox;
|
|||
|
|
dxLayoutGroup1: TdxLayoutGroup;
|
|||
|
|
dxLayoutItem1: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|||
|
|
ActionList1: TActionList;
|
|||
|
|
actLista: TAction;
|
|||
|
|
actOtro: TAction;
|
|||
|
|
dsContrato: TDADataSource;
|
|||
|
|
dsAlmacenes: TDADataSource;
|
|||
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|||
|
|
bModificar: TBitBtn;
|
|||
|
|
txtDireccion: TStaticText;
|
|||
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|||
|
|
rdxDestinoCliente: TRadioButton;
|
|||
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|||
|
|
cbListaDireccionesCliente: TcxDBLookupComboBox;
|
|||
|
|
dsDireccionesCliente: TDADataSource;
|
|||
|
|
actListaCliente: TAction;
|
|||
|
|
procedure actListaExecute(Sender: TObject);
|
|||
|
|
procedure actOtroExecute(Sender: TObject);
|
|||
|
|
procedure cbListaPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure cbListaDireccionesClientePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure bModificarClick(Sender: TObject);
|
|||
|
|
procedure txtDireccionDblClick(Sender: TObject);
|
|||
|
|
procedure actListaClienteExecute(Sender: TObject);
|
|||
|
|
procedure actBotonElegirDirClienteUpdate(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
// FAlmacenesController : IAlmacenesController;
|
|||
|
|
// FAlmacenes: IBizAlmacen;
|
|||
|
|
FDireccionesCliente : IBizContactosDirecciones;
|
|||
|
|
FContrato : IBizContratoCliente;
|
|||
|
|
FController : IContratosClienteController;
|
|||
|
|
function GetContratoCliente: IBizContratoCliente;
|
|||
|
|
function HayClienteAsociado: Boolean;
|
|||
|
|
procedure SetContratoCliente(const Value: IBizContratoCliente);
|
|||
|
|
procedure CambioDireccionCliente;
|
|||
|
|
procedure RecuperarClienteAsociado;
|
|||
|
|
procedure SetReadOnly(Value: Boolean); override;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
property ContratoCliente: IBizContratoCliente read GetContratoCliente write SetContratoCliente;
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
procedure RefrescarDireccion;
|
|||
|
|
procedure CambioDireccionAlmacen;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uEditorRegistryUtils, uCustomView, uStringsUtils, uFactuGES_App;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.actBotonElegirDirClienteUpdate(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := HayClienteAsociado and (rdxDestinoCliente.Checked);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.actListaClienteExecute(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
actListaCliente.Checked := True;
|
|||
|
|
CambioDireccionCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.actListaExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
actLista.Checked := True;
|
|||
|
|
RefrescarDireccion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.actOtroExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
actOtro.Checked := True;
|
|||
|
|
// txtDireccion.Enabled := True;
|
|||
|
|
|
|||
|
|
if Assigned(FContrato) then
|
|||
|
|
begin
|
|||
|
|
FController.VerDireccionEntrega(FContrato);
|
|||
|
|
{
|
|||
|
|
if (FContrato.ID_ALMACEN > 0) then
|
|||
|
|
begin
|
|||
|
|
FContrato.Edit;
|
|||
|
|
FContrato.ID_ALMACEN := 0;
|
|||
|
|
end;
|
|||
|
|
}
|
|||
|
|
end;
|
|||
|
|
RefrescarDireccion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.bModificarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
actOtro.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.CambioDireccionAlmacen;
|
|||
|
|
begin
|
|||
|
|
{
|
|||
|
|
if Assigned(FPedido) and Assigned(FAlmacenes) then
|
|||
|
|
begin
|
|||
|
|
FPedido.Edit;
|
|||
|
|
FPedido.CALLE := FAlmacenes.NOMBRE + #10#13 + FAlmacenes.CALLE;
|
|||
|
|
FPedido.POBLACION := FAlmacenes.POBLACION;
|
|||
|
|
FPedido.POBLACION := FAlmacenes.POBLACION;
|
|||
|
|
FPedido.PROVINCIA := FAlmacenes.PROVINCIA;
|
|||
|
|
FPedido.CODIGO_POSTAL := FAlmacenes.CODIGO_POSTAL;
|
|||
|
|
FPedido.PERSONA_CONTACTO := FAlmacenes.PERSONA_CONTACTO;
|
|||
|
|
FPedido.TELEFONO := FAlmacenes.MOVIL;
|
|||
|
|
RefrescarDireccion;
|
|||
|
|
end;
|
|||
|
|
}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.CambioDireccionCliente;
|
|||
|
|
begin
|
|||
|
|
if Assigned(FContrato) and Assigned(FDireccionesCliente) then
|
|||
|
|
begin
|
|||
|
|
FContrato.Edit;
|
|||
|
|
FContrato.CALLE_ENVIO := FDireccionesCliente.NOMBRE + #10#13 + FDireccionesCliente.CALLE;
|
|||
|
|
FContrato.POBLACION_ENVIO := FDireccionesCliente.POBLACION;
|
|||
|
|
FContrato.PROVINCIA_ENVIO := FDireccionesCliente.PROVINCIA;
|
|||
|
|
FContrato.CODIGO_POSTAL_ENVIO := FDireccionesCliente.CODIGO_POSTAL;
|
|||
|
|
FContrato.PERS_CONTACTO_ENVIO := FDireccionesCliente.PERSONA_CONTACTO;
|
|||
|
|
FContrato.TLFS_ENVIO := FDireccionesCliente.TELEFONO;
|
|||
|
|
RefrescarDireccion;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.cbListaDireccionesClientePropertiesValidate(
|
|||
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FContrato) and Assigned(FDireccionesCliente) then
|
|||
|
|
CambioDireccionCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.cbListaPropertiesValidate(
|
|||
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
{
|
|||
|
|
if Assigned(FPedido) and Assigned(FAlmacenes) then
|
|||
|
|
CambioDireccionAlmacen;
|
|||
|
|
}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfrViewDireccionEntregaContratoCli.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FController := TContratosClienteController.Create;
|
|||
|
|
// FAlmacenesController := TAlmacenesController.Create;
|
|||
|
|
// FAlmacenes := FAlmacenesController.BuscarTodos;
|
|||
|
|
// FAlmacenes.DataTable.Active := True;
|
|||
|
|
// dsAlmacenes.DataTable := FAlmacenes.DataTable;
|
|||
|
|
|
|||
|
|
FDireccionesCliente := NIL;
|
|||
|
|
dsDireccionesCliente.DataTable := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrViewDireccionEntregaContratoCli.Destroy;
|
|||
|
|
begin
|
|||
|
|
cbListaDireccionesCliente.Properties.OnValidate := Nil;
|
|||
|
|
cbLista.Properties.OnValidate := Nil;
|
|||
|
|
|
|||
|
|
dsDireccionesCliente.DataTable := NIL;
|
|||
|
|
FDireccionesCliente := NIL;
|
|||
|
|
|
|||
|
|
// FAlmacenesController := Nil;
|
|||
|
|
// FAlmacenes := Nil;
|
|||
|
|
// FController := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDireccionEntregaContratoCli.GetContratoCliente: IBizContratoCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewDireccionEntregaContratoCli.HayClienteAsociado: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := Assigned(FContrato) and (FContrato.ID_CLIENTE > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.RecuperarClienteAsociado;
|
|||
|
|
var
|
|||
|
|
AClientesController: IClientesController;
|
|||
|
|
AContratoController : IContratosClienteController;
|
|||
|
|
AContrato : IBizContratoCliente;
|
|||
|
|
begin
|
|||
|
|
FDireccionesCliente := NIL;
|
|||
|
|
dsDireccionesCliente.DataTable := NIL;
|
|||
|
|
|
|||
|
|
if (HayCLienteAsociado()) then
|
|||
|
|
begin
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
AClientesController := TClientesController.Create;
|
|||
|
|
AContratoController := TContratosClienteController.Create;
|
|||
|
|
try
|
|||
|
|
AContrato := FContrato;
|
|||
|
|
if Assigned(AContrato) then
|
|||
|
|
begin
|
|||
|
|
AContrato.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
FDireccionesCliente := AClientesController.DarTodasDirecciones(AContrato.ID_CLIENTE);
|
|||
|
|
if Assigned(FDireccionesCliente) then
|
|||
|
|
FDireccionesCliente.DataTable.Open;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
AClientesController := NIL;
|
|||
|
|
AContratoController := NIL;
|
|||
|
|
AContrato := NIL;
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.RefrescarDireccion;
|
|||
|
|
begin
|
|||
|
|
txtDireccion.Caption := '';
|
|||
|
|
if Assigned(FContrato) then
|
|||
|
|
begin
|
|||
|
|
txtDireccion.Enabled := True;
|
|||
|
|
txtDireccion.Caption := FContrato.CALLE_ENVIO;
|
|||
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + FContrato.CODIGO_POSTAL_ENVIO + ' ' + FContrato.POBLACION_ENVIO;
|
|||
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + FContrato.PROVINCIA_ENVIO;
|
|||
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + 'Persona contacto: ' + FContrato.PERS_CONTACTO_ENVIO;
|
|||
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + 'Tel<65>fono: ' + FContrato.TLFS_ENVIO;
|
|||
|
|
|
|||
|
|
if (actOtro.Checked) then
|
|||
|
|
begin
|
|||
|
|
txtDireccion.Enabled := True;
|
|||
|
|
bModificar.Enabled := True;
|
|||
|
|
|
|||
|
|
cbLista.Enabled := False;
|
|||
|
|
cbLista.Text := '';
|
|||
|
|
|
|||
|
|
cbListaDireccionesCliente.Enabled := False;
|
|||
|
|
cbListaDireccionesCliente.Text := '';
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
if (actListaCliente.Checked) then
|
|||
|
|
begin
|
|||
|
|
cbListaDireccionesCliente.Enabled := True;
|
|||
|
|
cbListaDireccionesCliente.DroppedDown := True;
|
|||
|
|
|
|||
|
|
cbLista.Enabled := False;
|
|||
|
|
cbLista.Text := '';
|
|||
|
|
|
|||
|
|
txtDireccion.Enabled := False;
|
|||
|
|
bModificar.Enabled := False;
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
cbLista.Enabled := True;
|
|||
|
|
cbLista.DroppedDown := True;
|
|||
|
|
|
|||
|
|
cbListaDireccionesCliente.Enabled := False;
|
|||
|
|
cbListaDireccionesCliente.Text := '';
|
|||
|
|
|
|||
|
|
txtDireccion.Enabled := False;
|
|||
|
|
bModificar.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.SetContratoCliente(
|
|||
|
|
const Value: IBizContratoCliente);
|
|||
|
|
begin
|
|||
|
|
cbLista.Properties.OnValidate := NIL;
|
|||
|
|
cbListaDireccionesCliente.Properties.OnValidate := NIL;
|
|||
|
|
dsContrato.DataTable := nil;
|
|||
|
|
|
|||
|
|
FContrato := Value;
|
|||
|
|
|
|||
|
|
RecuperarClienteAsociado;
|
|||
|
|
if Assigned(FDireccionesCliente) then
|
|||
|
|
begin
|
|||
|
|
dsDireccionesCliente.DataTable := FDireccionesCliente.DataTable;
|
|||
|
|
cbListaDireccionesCliente.Properties.OnValidate := cbListaDireccionesClientePropertiesValidate;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
cbLista.Properties.OnValidate := cbListaPropertiesValidate;
|
|||
|
|
dsContrato.DataTable := FContrato.DataTable;
|
|||
|
|
|
|||
|
|
if (FContrato.ID_DIRECCION_ENVIO < 1) then
|
|||
|
|
actOtro.Checked := True
|
|||
|
|
else
|
|||
|
|
actListaCliente.Checked := True;
|
|||
|
|
|
|||
|
|
RefrescarDireccion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.SetReadOnly(Value: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if ReadOnly then
|
|||
|
|
begin
|
|||
|
|
rdxDestino1.Enabled := False;
|
|||
|
|
rdxDestinoCliente.Enabled := False;
|
|||
|
|
rdxDestino2.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewDireccionEntregaContratoCli.txtDireccionDblClick(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
actOtro.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|