git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@2 93f398dd-4eb6-7a46-baf6-13f46f578da2
210 lines
6.2 KiB
ObjectPascal
210 lines
6.2 KiB
ObjectPascal
unit uViewDireccionEntregaPedidoProv;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, uBizPedidosProveedor, cxGraphics, dxLayoutControl, cxMemo,
|
|
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit,
|
|
cxDBLookupEdit, cxDBLookupComboBox, StdCtrls, cxControls, DB, uDADataTable,
|
|
ActnList, uBizAlmacenes, uAlmacenesController, uPedidosProveedorController,
|
|
Buttons, uDAInterfaces;
|
|
|
|
type
|
|
IViewDireccionEntregaPedidoProv = interface(IViewBase)
|
|
['{7467855C-066F-4A60-B88F-2837C8050B1E}']
|
|
function GetPedidoProveedor: IBizPedidoProveedor;
|
|
procedure SetPedidoProveedor(const Value: IBizPedidoProveedor);
|
|
property PedidoProveedor: IBizPedidoProveedor read GetPedidoProveedor write SetPedidoProveedor;
|
|
end;
|
|
|
|
TfrViewDireccionEntregaPedidoProv = class(TfrViewBase, IViewDireccionEntregaPedidoProv)
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
rdxDestino1: TRadioButton;
|
|
rdxDestino2: TRadioButton;
|
|
cbLista: TcxDBLookupComboBox;
|
|
dxLayoutGroup1: TdxLayoutGroup;
|
|
dxLayoutItem1: TdxLayoutItem;
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
ActionList1: TActionList;
|
|
actLista: TAction;
|
|
actOtro: TAction;
|
|
dsPedido: TDADataSource;
|
|
dsAlmacenes: TDADataSource;
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
bModificar: TBitBtn;
|
|
txtDireccion: TStaticText;
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|
procedure actListaExecute(Sender: TObject);
|
|
procedure actOtroExecute(Sender: TObject);
|
|
procedure cbListaPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|
procedure bModificarClick(Sender: TObject);
|
|
procedure txtDireccionDblClick(Sender: TObject);
|
|
protected
|
|
FAlmacenesController : IAlmacenesController;
|
|
FAlmacenes: IBizAlmacen;
|
|
FPedido : IBizPedidoProveedor;
|
|
FController : IPedidosProveedorController;
|
|
function GetPedidoProveedor: IBizPedidoProveedor;
|
|
procedure SetPedidoProveedor(const Value: IBizPedidoProveedor);
|
|
procedure CambioDireccionAlmacen;
|
|
procedure RefrescarDireccion;
|
|
procedure SetReadOnly(Value: Boolean); override;
|
|
|
|
public
|
|
property PedidoProveedor: IBizPedidoProveedor read GetPedidoProveedor write SetPedidoProveedor;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
uEditorRegistryUtils, uCustomView;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.actListaExecute(Sender: TObject);
|
|
begin
|
|
actLista.Checked := True;
|
|
RefrescarDireccion;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.actOtroExecute(Sender: TObject);
|
|
begin
|
|
actOtro.Checked := True;
|
|
// txtDireccion.Enabled := True;
|
|
|
|
if Assigned(FPedido) then
|
|
begin
|
|
FController.VerDireccionEntrega(FPedido);
|
|
|
|
if (FPedido.ID_ALMACEN > 0) then
|
|
begin
|
|
FPedido.Edit;
|
|
FPedido.ID_ALMACEN := 0;
|
|
end;
|
|
end;
|
|
RefrescarDireccion;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.bModificarClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
actOtro.Execute;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.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;
|
|
FPedido.PERSONA_CONTACTO := FAlmacenes.PERSONA_CONTACTO;
|
|
FPedido.TELEFONO := FAlmacenes.TELEFONO;
|
|
RefrescarDireccion;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.cbListaPropertiesValidate(
|
|
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 TfrViewDireccionEntregaPedidoProv.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FController := TPedidosProveedorController.Create;
|
|
FAlmacenesController := TAlmacenesController.Create;
|
|
FAlmacenes := FAlmacenesController.BuscarTodos;
|
|
FAlmacenes.DataTable.Active := True;
|
|
dsAlmacenes.DataTable := FAlmacenes.DataTable;
|
|
end;
|
|
|
|
destructor TfrViewDireccionEntregaPedidoProv.Destroy;
|
|
begin
|
|
cbLista.Properties.OnValidate := Nil;
|
|
FAlmacenesController := Nil;
|
|
FAlmacenes := Nil;
|
|
FController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
function TfrViewDireccionEntregaPedidoProv.GetPedidoProveedor: IBizPedidoProveedor;
|
|
begin
|
|
Result := FPedido;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.RefrescarDireccion;
|
|
begin
|
|
txtDireccion.Caption := '';
|
|
if Assigned(FPedido) then
|
|
begin
|
|
if (actOtro.Checked) then
|
|
begin
|
|
cbLista.Enabled := False;
|
|
cbLista.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 begin
|
|
txtDireccion.Enabled := False;
|
|
cbLista.Enabled := True;
|
|
cbLista.DroppedDown := True;
|
|
bModificar.Enabled := False;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor(
|
|
const Value: IBizPedidoProveedor);
|
|
begin
|
|
cbLista.Properties.OnValidate := NIL;
|
|
dsPedido.DataTable := nil;
|
|
|
|
FPedido := Value;
|
|
|
|
dsPedido.DataTable := FPedido.DataTable;
|
|
cbLista.Properties.OnValidate := cbListaPropertiesValidate;
|
|
|
|
if (FPedido.EsNuevo) then
|
|
CambioDireccionAlmacen
|
|
else
|
|
if (FPedido.ID_ALMACEN < 1) then
|
|
actOtro.Checked := True;
|
|
|
|
RefrescarDireccion;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.SetReadOnly(Value: Boolean);
|
|
begin
|
|
inherited;
|
|
if ReadOnly then
|
|
begin
|
|
rdxDestino1.Enabled := False;
|
|
rdxDestino2.Enabled := False;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewDireccionEntregaPedidoProv.txtDireccionDblClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
actOtro.Execute;
|
|
end;
|
|
|
|
end.
|