This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.pas

195 lines
5.9 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;
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 memDireccionDblClick(Sender: TObject);
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 RefrescarDireccion;
public
property PedidoProveedor: IBizPedidoProveedor read GetPedidoProveedor write SetPedidoProveedor;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{$R *.dfm}
uses
uEditorRegistryUtils;
procedure TfrViewDireccionEntregaPedidoProv.actListaExecute(Sender: TObject);
begin
cbLista.Enabled := True;
txtDireccion.Enabled := False;
end;
procedure TfrViewDireccionEntregaPedidoProv.actOtroExecute(Sender: TObject);
begin
cbLista.Text := '';
cbLista.Enabled := False;
txtDireccion.Enabled := True;
if Assigned(FPedido) then
begin
FController.VerDireccionEntrega(FPedido);
if (FPedido.ID_ALMACEN > 0) then
begin
FPedido.Edit;
FPedido.DataTable.FieldByName('ID_ALMACEN').AsVariant := Null;
end;
end;
RefrescarDireccion;
end;
procedure TfrViewDireccionEntregaPedidoProv.bModificarClick(Sender: TObject);
begin
inherited;
actOtro.Execute;
end;
procedure TfrViewDireccionEntregaPedidoProv.cbListaPropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
begin
if Assigned(FPedido) and (FPedido.ID_ALMACEN <> FAlmacenes.ID) 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;
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.memDireccionDblClick(
Sender: TObject);
begin
inherited;
actOtro.Execute;
end;
procedure TfrViewDireccionEntregaPedidoProv.RefrescarDireccion;
begin
txtDireccion.Caption := '';
if Assigned(FPedido) then
begin
if (FPedido.ID_ALMACEN < 1) then
begin
actLista.Checked := False;
actOtro.Checked := True;
cbLista.Enabled := False;
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;
end
else begin
actLista.Checked := True;
actOtro.Checked := False;
cbLista.Enabled := True;
txtDireccion.Enabled := False;
end;
end;
end;
procedure TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor(
const Value: IBizPedidoProveedor);
begin
cbLista.Properties.OnValidate := NIL;
dsPedido.DataTable := nil;
FPedido := Value;
if not (FPedido.EsNuevo) then
RefrescarDireccion;
// Esto al final para que no salten los eventos del cxComboBox
dsPedido.DataTable := FPedido.DataTable;
cbLista.Properties.OnValidate := cbListaPropertiesValidate;
end;
procedure TfrViewDireccionEntregaPedidoProv.txtDireccionDblClick(
Sender: TObject);
begin
inherited;
actOtro.Execute;
end;
end.