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/Albaranes de proveedor/Views/uViewDireccionEntregaAlbaranProv.pas

174 lines
5.4 KiB
ObjectPascal

unit uViewDireccionEntregaAlbaranProv;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, uBizAlbaranesProveedor, cxGraphics, dxLayoutControl, cxMemo,
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit,
cxDBLookupEdit, cxDBLookupComboBox, StdCtrls, cxControls, DB, uDADataTable,
ActnList, uBizAlmacenes, uAlmacenesController, uAlbaranesProveedorController,
Buttons;
type
IViewDireccionEntregaAlbaranProv = interface(IViewBase)
['{20124A28-C343-4A70-8016-06DDF92C75E7}']
function GetAlbaranProveedor: IBizAlbaranProveedor;
procedure SetAlbaranProveedor(const Value: IBizAlbaranProveedor);
property AlbaranProveedor: IBizAlbaranProveedor read GetAlbaranProveedor write SetAlbaranProveedor;
end;
TfrViewDireccionEntregaAlbaranProv = class(TfrViewBase, IViewDireccionEntregaAlbaranProv)
dxLayoutControl1: TdxLayoutControl;
rdxDestino1: TRadioButton;
rdxDestino2: TRadioButton;
cbLista: TcxDBLookupComboBox;
memDireccion: TcxMemo;
dxLayoutGroup1: TdxLayoutGroup;
dxLayoutItem1: TdxLayoutItem;
dxLayoutControl1Item3: TdxLayoutItem;
dxLayoutControl1Item2: TdxLayoutItem;
dxLayoutControl1Item4: TdxLayoutItem;
ActionList1: TActionList;
actLista: TAction;
actOtro: TAction;
dsAlbaran: TDADataSource;
dsAlmacenes: TDADataSource;
dxLayoutControl1Item1: TdxLayoutItem;
bModificar: TBitBtn;
dxLayoutControl1Group1: TdxLayoutGroup;
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);
protected
FAlmacenesController : IAlmacenesController;
FAlmacenes: IBizAlmacen;
FAlbaran : IBizAlbaranProveedor;
FController : IAlbaranesProveedorController;
function GetAlbaranProveedor: IBizAlbaranProveedor;
procedure SetAlbaranProveedor(const Value: IBizAlbaranProveedor);
procedure RefrescarDireccion;
public
property AlbaranProveedor: IBizAlbaranProveedor read GetAlbaranProveedor write SetAlbaranProveedor;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{$R *.dfm}
uses
uEditorRegistryUtils;
procedure TfrViewDireccionEntregaAlbaranProv.actListaExecute(Sender: TObject);
begin
cbLista.Enabled := True;
memDireccion.Enabled := False;
end;
procedure TfrViewDireccionEntregaAlbaranProv.actOtroExecute(Sender: TObject);
begin
cbLista.Text := '';
cbLista.Enabled := False;
memDireccion.Enabled := True;
if Assigned(FAlbaran) then
begin
FController.VerDireccionEntrega(FAlbaran);
if (FAlbaran.ID_ALMACEN > 0) then
begin
FAlbaran.Edit;
FAlbaran.DataTable.FieldByName('ID_ALMACEN').AsVariant := Null;
end;
end;
RefrescarDireccion;
end;
procedure TfrViewDireccionEntregaAlbaranProv.bModificarClick(Sender: TObject);
begin
inherited;
actOtro.Execute;
end;
procedure TfrViewDireccionEntregaAlbaranProv.cbListaPropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
begin
if Assigned(FAlbaran) and (FAlbaran.ID_ALMACEN <> FAlmacenes.ID) then
begin
FAlbaran.Edit;
FAlbaran.CALLE := FAlmacenes.CALLE;
FAlbaran.POBLACION := FAlmacenes.POBLACION;
FAlbaran.POBLACION := FAlmacenes.POBLACION;
FAlbaran.PROVINCIA := FAlmacenes.PROVINCIA;
FAlbaran.CODIGO_POSTAL := FAlmacenes.CODIGO_POSTAL;
FAlbaran.PERSONA_CONTACTO := FAlmacenes.PERSONA_CONTACTO;
FAlbaran.TELEFONO := FAlmacenes.TELEFONO;
RefrescarDireccion;
end;
end;
constructor TfrViewDireccionEntregaAlbaranProv.Create(AOwner: TComponent);
begin
inherited;
FController := TAlbaranesProveedorController.Create;
FAlmacenesController := TAlmacenesController.Create;
FAlmacenes := FAlmacenesController.BuscarTodos;
FAlmacenes.DataTable.Active := True;
dsAlmacenes.DataTable := FAlmacenes.DataTable;
end;
destructor TfrViewDireccionEntregaAlbaranProv.Destroy;
begin
cbLista.Properties.OnValidate := Nil;
FAlmacenesController := Nil;
FAlmacenes := Nil;
FController := NIL;
inherited;
end;
function TfrViewDireccionEntregaAlbaranProv.GetAlbaranProveedor: IBizAlbaranProveedor;
begin
Result := FAlbaran;
end;
procedure TfrViewDireccionEntregaAlbaranProv.memDireccionDblClick(
Sender: TObject);
begin
inherited;
actOtro.Execute;
end;
procedure TfrViewDireccionEntregaAlbaranProv.RefrescarDireccion;
begin
memDireccion.Lines.Clear;
if Assigned(FAlbaran) then
begin
memDireccion.Lines.Add(FAlbaran.CALLE);
memDireccion.Lines.Add(FAlbaran.CODIGO_POSTAL + ' ' + FAlbaran.POBLACION);
memDireccion.Lines.Add(FAlbaran.PROVINCIA);
end;
end;
procedure TfrViewDireccionEntregaAlbaranProv.SetAlbaranProveedor(
const Value: IBizAlbaranProveedor);
begin
cbLista.Properties.OnValidate := NIL;
dsAlbaran.DataTable := nil;
FAlbaran := Value;
if not FAlbaran.EsNuevo then
RefrescarDireccion;
// Esto al final para que no salten los eventos del cxComboBox
dsAlbaran.DataTable := FAlbaran.DataTable;
cbLista.Properties.OnValidate := cbListaPropertiesValidate;
end;
end.