git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@153 93f398dd-4eb6-7a46-baf6-13f46f578da2
259 lines
7.5 KiB
ObjectPascal
259 lines
7.5 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);
|
||
procedure CustomViewShow(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 not FPedido.DataTable.ReadOnly then
|
||
begin
|
||
if Assigned(FPedido)
|
||
and Assigned(FAlmacenes) then
|
||
begin
|
||
cbLista.EditText := FAlmacenes.NOMBRE;
|
||
FPedido.Edit;
|
||
FPedido.CALLE := FAlmacenes.CALLE;
|
||
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;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.cbListaPropertiesValidate(
|
||
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
||
var Error: Boolean);
|
||
begin
|
||
if Assigned(FPedido) and Assigned(FAlmacenes) 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;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.CustomViewShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if Assigned(FPedido) and not FPedido.ID_ALMACENIsNull then
|
||
begin
|
||
CambioDireccionAlmacen;
|
||
end;
|
||
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
|
||
|
||
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;
|
||
txtDireccion.Caption := txtDireccion.Caption + #13#10 + 'Persona contacto: ' + FPedido.PERSONA_CONTACTO;
|
||
txtDireccion.Caption := txtDireccion.Caption + #13#10 + 'Tel<65>fono: ' + FPedido.TELEFONO;
|
||
|
||
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 TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor(
|
||
const Value: IBizPedidoProveedor);
|
||
begin
|
||
cbLista.Properties.OnValidate := NIL;
|
||
dsPedido.DataTable := nil;
|
||
|
||
FPedido := Value;
|
||
if Assigned(FPedido) then
|
||
begin
|
||
cbLista.Properties.OnValidate := cbListaPropertiesValidate;
|
||
dsPedido.DataTable := FPedido.DataTable;
|
||
|
||
if (FPedido.ID_ALMACEN < 1) then
|
||
begin
|
||
// if (FPedido.ID_DIRECCION_CLIENTE < 1) then
|
||
// actOtro.Checked := True
|
||
// else
|
||
// actListaCliente.Checked := True
|
||
end
|
||
else
|
||
actLista.Checked := True;
|
||
|
||
RefrescarDireccion;
|
||
end;
|
||
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.
|