git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@26 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
299 lines
8.8 KiB
ObjectPascal
299 lines
8.8 KiB
ObjectPascal
unit uViewDireccionEntregaPedidoCli;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, uBizPedidosCliente, cxGraphics, dxLayoutControl, cxMemo,
|
|
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit,
|
|
cxDBLookupEdit, cxDBLookupComboBox, StdCtrls, cxControls, DB, uDADataTable,
|
|
ActnList, uBizAlmacenes, uAlmacenesController, uPedidosClienteController,
|
|
Buttons, uDAInterfaces, cxButtonEdit, cxDBEdit,
|
|
ExtCtrls, cxLabel, cxDBLabel;
|
|
|
|
type
|
|
IViewDireccionEntregaPedidoCli = interface(IViewBase)
|
|
['{0F70A289-9EBA-4F78-932E-A8F87CBF4C35}']
|
|
function GetPedidoCliente: IBizPedidoCliente;
|
|
procedure SetPedidoCliente(const Value: IBizPedidoCliente);
|
|
property PedidoCliente: IBizPedidoCliente read GetPedidoCliente write SetPedidoCliente;
|
|
end;
|
|
|
|
TfrViewDireccionEntregaPedidoCli = class(TfrViewBase, IViewDireccionEntregaPedidoCli)
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
rdxDestino1: TRadioButton;
|
|
rdxDestino3: TRadioButton;
|
|
cbListaAlmacenes: TcxDBLookupComboBox;
|
|
dxLayoutGroup1: TdxLayoutGroup;
|
|
dxLayoutItem1: TdxLayoutItem;
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
ActionList1: TActionList;
|
|
actListaAlmacenes: TAction;
|
|
actOtro: TAction;
|
|
dsPedido: TDADataSource;
|
|
dsAlmacenes: TDADataSource;
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
bModificar: TBitBtn;
|
|
txtDireccion: TStaticText;
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|
rdxDestino2: TRadioButton;
|
|
dsObras: TDADataSource;
|
|
actListaObras: TAction;
|
|
Bevel1: TBevel;
|
|
dxLayoutControl1Item8: TdxLayoutItem;
|
|
edtEntregarA: TcxDBTextEdit;
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|
lblObra: TLabel;
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|
|
|
procedure cbListaAlmacenesPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|
procedure bModificarClick(Sender: TObject);
|
|
procedure txtDireccionDblClick(Sender: TObject);
|
|
|
|
procedure edtEntregarAPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
|
procedure actListaAlmacenesExecute(Sender: TObject);
|
|
procedure actOtroExecute(Sender: TObject);
|
|
procedure actListaObrasExecute(Sender: TObject);
|
|
|
|
protected
|
|
FAlmacenesController : IAlmacenesController;
|
|
FAlmacenes: IBizAlmacen;
|
|
// FObrasController : IObrasController;
|
|
// FObra: IBizObra;
|
|
FPedido : IBizPedidoCliente;
|
|
FController : IPedidosClienteController;
|
|
function GetPedidoCliente: IBizPedidoCliente;
|
|
procedure SetPedidoCliente(const Value: IBizPedidoCliente);
|
|
procedure CambioDireccionAlmacen;
|
|
procedure SetReadOnly(Value: Boolean); override;
|
|
|
|
public
|
|
property PedidoCliente: IBizPedidoCliente read GetPedidoCliente write SetPedidoCliente;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
procedure RecuperarObra;
|
|
procedure CambioDireccionObra;
|
|
procedure RefrescarControles;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
uEditorRegistryUtils, uCustomView, uBizInventario;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.actListaAlmacenesExecute(
|
|
Sender: TObject);
|
|
begin
|
|
actListaAlmacenes.Checked := True;
|
|
RefrescarControles;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.actListaObrasExecute(Sender: TObject);
|
|
begin
|
|
actListaObras.Checked := True;
|
|
RecuperarObra;
|
|
CambioDireccionObra;
|
|
// FController.AsignarIDAlmacen(FPedido, FPedido.ID_OBRA);
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.actOtroExecute(Sender: TObject);
|
|
begin
|
|
actOtro.Checked := True;
|
|
|
|
if Assigned(FPedido) then
|
|
begin
|
|
FController.VerDireccionEntrega(FPedido);
|
|
// FController.AsignarIDAlmacen(FPedido, Null);
|
|
end;
|
|
RefrescarControles;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.bModificarClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
actOtro.Execute;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.CambioDireccionAlmacen;
|
|
begin
|
|
if Assigned(FPedido) and Assigned(FAlmacenes) then
|
|
begin
|
|
FPedido.Edit;
|
|
FPedido.CALLE := FAlmacenes.CALLE;
|
|
FPedido.POBLACION := FAlmacenes.POBLACION;
|
|
FPedido.POBLACION := FAlmacenes.POBLACION;
|
|
FPedido.PROVINCIA := FAlmacenes.PROVINCIA;
|
|
FPedido.CODIGO_POSTAL := FAlmacenes.CODIGO_POSTAL;
|
|
RefrescarControles;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.CambioDireccionObra;
|
|
begin
|
|
{
|
|
if Assigned(FPedido) and Assigned(FObra) then
|
|
begin
|
|
FPedido.Edit;
|
|
FPedido.CALLE := FObra.CALLE;
|
|
FPedido.POBLACION := FObra.POBLACION;
|
|
FPedido.POBLACION := FObra.POBLACION;
|
|
FPedido.PROVINCIA := FObra.PROVINCIA;
|
|
FPedido.CODIGO_POSTAL := FObra.CODIGO_POSTAL;
|
|
RefrescarControles;
|
|
end;
|
|
}
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.cbListaAlmacenesPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
begin
|
|
// if Assigned(FPedido) and Assigned(FAlmacenes) and (FPedido.ID_ALMACEN <> FAlmacenes.ID) then
|
|
// CambioDireccionAlmacen;
|
|
end;
|
|
|
|
constructor TfrViewDireccionEntregaPedidoCli.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FController := TPedidosClienteController.Create;
|
|
FAlmacenesController := TAlmacenesController.Create;
|
|
FAlmacenes := FAlmacenesController.BuscarTodos;
|
|
FAlmacenes.DataTable.Active := True;
|
|
dsAlmacenes.DataTable := FAlmacenes.DataTable;
|
|
|
|
// FObrasController := TObrasController.Create;
|
|
// FObra := NIL;
|
|
end;
|
|
|
|
destructor TfrViewDireccionEntregaPedidoCli.Destroy;
|
|
begin
|
|
cbListaAlmacenes.Properties.OnValidate := Nil;
|
|
|
|
FAlmacenesController := Nil;
|
|
FAlmacenes := Nil;
|
|
|
|
// FObrasController := Nil;
|
|
// FObra := NIL;
|
|
|
|
FController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.edtEntregarAPropertiesButtonClick(
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
var
|
|
AID_Subcontrata : Integer;
|
|
APersonaContacto : String;
|
|
begin
|
|
inherited;
|
|
AID_Subcontrata := -1;
|
|
{
|
|
if not FPedido.ID_OBRAIsNull then
|
|
begin
|
|
RecuperarObra;
|
|
if FObrasController.LocalizarEjecucionActiva(FObra.Ejecuciones) then
|
|
begin
|
|
if not FObra.Ejecuciones.ID_SUBCONTRATAIsNull then
|
|
AID_Subcontrata := FObra.Ejecuciones.ID_SUBCONTRATA;
|
|
end;
|
|
end;
|
|
}
|
|
APersonaContacto := FPedido.PERSONA_CONTACTO;
|
|
{
|
|
if ElegirPersonaContactoPedido(AID_Subcontrata, APersonaContacto) then
|
|
begin
|
|
FPedido.Edit;
|
|
FPedido.PERSONA_CONTACTO := APersonaContacto;
|
|
end;
|
|
}
|
|
end;
|
|
|
|
function TfrViewDireccionEntregaPedidoCli.GetPedidoCliente: IBizPedidoCliente;
|
|
begin
|
|
Result := FPedido;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.RecuperarObra;
|
|
begin
|
|
{ if Assigned(FObra) and (FObra.ID = FPedido.ID_OBRA) then
|
|
Exit; // No hace falta volver a recuperarla
|
|
|
|
FObra := FObrasController.Buscar(FPedido.ID_OBRA);
|
|
FObra.Open;
|
|
}
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.RefrescarControles;
|
|
begin
|
|
txtDireccion.Caption := '';
|
|
if Assigned(FPedido) then
|
|
begin
|
|
if (actOtro.Checked) then
|
|
begin
|
|
cbListaAlmacenes.Enabled := False;
|
|
cbListaAlmacenes.Text := '';
|
|
txtDireccion.Enabled := True;
|
|
txtDireccion.Caption := FPedido.CALLE;
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + FPedido.CODIGO_POSTAL + ' ' + FPedido.POBLACION;
|
|
txtDireccion.Caption := txtDireccion.Caption + #13#10 + FPedido.PROVINCIA;
|
|
bModificar.Enabled := True;
|
|
end
|
|
else if (actListaAlmacenes.Checked) then
|
|
begin
|
|
cbListaAlmacenes.Enabled := True;
|
|
cbListaAlmacenes.DroppedDown := True;
|
|
txtDireccion.Enabled := False;
|
|
bModificar.Enabled := False;
|
|
end
|
|
else begin
|
|
cbListaAlmacenes.Enabled := False;
|
|
cbListaAlmacenes.Text := '';
|
|
bModificar.Enabled := False;
|
|
txtDireccion.Enabled := False;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.SetPedidoCliente(
|
|
const Value: IBizPedidoCliente);
|
|
begin
|
|
cbListaAlmacenes.Properties.OnValidate := NIL;
|
|
dsPedido.DataTable := nil;
|
|
|
|
FPedido := Value;
|
|
|
|
dsPedido.DataTable := FPedido.DataTable;
|
|
cbListaAlmacenes.Properties.OnValidate := cbListaAlmacenesPropertiesValidate;
|
|
|
|
actOtro.Checked := True;
|
|
RefrescarControles;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.SetReadOnly(Value: Boolean);
|
|
begin
|
|
inherited;
|
|
|
|
if (csLoading in Self.ComponentState) then
|
|
Exit;
|
|
|
|
rdxDestino1.Enabled := not ReadOnly;
|
|
rdxDestino2.Enabled := not ReadOnly;
|
|
rdxDestino3.Enabled := not ReadOnly;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoCli.txtDireccionDblClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
actOtro.Execute;
|
|
end;
|
|
|
|
end.
|