git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@715 0c75b7a4-871f-7646-8a2f-f78d34cc349f
349 lines
11 KiB
ObjectPascal
349 lines
11 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, uBizObras, uObrasController, cxButtonEdit, cxDBEdit,
|
||
ExtCtrls;
|
||
|
||
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;
|
||
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;
|
||
RadioButton1: TRadioButton;
|
||
dxLayoutControl1Item6: TdxLayoutItem;
|
||
cbListaObras: TcxDBLookupComboBox;
|
||
dsObras: TDADataSource;
|
||
actListaObras: TAction;
|
||
Bevel1: TBevel;
|
||
dxLayoutControl1Item8: TdxLayoutItem;
|
||
edtEntregarA: TcxDBButtonEdit;
|
||
dxLayoutControl1Item7: TdxLayoutItem;
|
||
dxLayoutControl1Group1: TdxLayoutGroup;
|
||
dxLayoutControl1Group2: TdxLayoutGroup;
|
||
dxLayoutControl1Group3: TdxLayoutGroup;
|
||
procedure actListaAlmacenesExecute(Sender: TObject);
|
||
procedure actOtroExecute(Sender: TObject);
|
||
procedure cbListaAlmacenesPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure cbListaObrasPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure bModificarClick(Sender: TObject);
|
||
procedure txtDireccionDblClick(Sender: TObject);
|
||
procedure actListaObrasExecute(Sender: TObject);
|
||
procedure edtEntregarAPropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
protected
|
||
FAlmacenesController : IAlmacenesController;
|
||
FAlmacenes: IBizAlmacen;
|
||
FObrasController : IObrasController;
|
||
FObras: IBizObra;
|
||
FPedido : IBizPedidoProveedor;
|
||
FController : IPedidosProveedorController;
|
||
function GetPedidoProveedor: IBizPedidoProveedor;
|
||
procedure SetPedidoProveedor(const Value: IBizPedidoProveedor);
|
||
procedure CambioDireccionAlmacen;
|
||
procedure CambioDireccionObra;
|
||
procedure RefrescarDireccion;
|
||
procedure PrepararObra;
|
||
procedure SetReadOnly(Value: Boolean); override;
|
||
procedure ID_OBRAOnChange(Sender: TDACustomField);
|
||
public
|
||
property PedidoProveedor: IBizPedidoProveedor read GetPedidoProveedor write SetPedidoProveedor;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uEditorRegistryUtils, uCustomView, uEditorElegirPersonaContactoPedido, uBizInventario;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.actListaAlmacenesExecute(Sender: TObject);
|
||
begin
|
||
actListaAlmacenes.Checked := True;
|
||
RefrescarDireccion;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.actListaObrasExecute(
|
||
Sender: TObject);
|
||
begin
|
||
actListaObras.Checked := True;
|
||
RefrescarDireccion;
|
||
CambioDireccionObra;
|
||
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;
|
||
RefrescarDireccion;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.CambioDireccionObra;
|
||
begin
|
||
if Assigned(FPedido) and Assigned(FObras) then
|
||
begin
|
||
FPedido.Edit;
|
||
FPedido.CALLE := FObras.CALLE;
|
||
FPedido.POBLACION := FObras.POBLACION;
|
||
FPedido.POBLACION := FObras.POBLACION;
|
||
FPedido.PROVINCIA := FObras.PROVINCIA;
|
||
FPedido.CODIGO_POSTAL := FObras.CODIGO_POSTAL;
|
||
RefrescarDireccion;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.cbListaObrasPropertiesValidate(
|
||
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
||
var Error: Boolean);
|
||
begin
|
||
if Assigned(FPedido) and Assigned(FObras) and (FPedido.ID_ALMACEN <> FObras.ID) then
|
||
CambioDireccionObra;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.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 TfrViewDireccionEntregaPedidoProv.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
FController := TPedidosProveedorController.Create;
|
||
FAlmacenesController := TAlmacenesController.Create;
|
||
FAlmacenes := FAlmacenesController.BuscarTodos;
|
||
FAlmacenes.DataTable.Active := True;
|
||
dsAlmacenes.DataTable := FAlmacenes.DataTable;
|
||
|
||
FObrasController := TObrasController.Create;
|
||
FObras := FObrasController.BuscarTodos;
|
||
FObras.DataTable.Active := True;
|
||
dsObras.DataTable := FObras.DataTable;
|
||
|
||
end;
|
||
|
||
destructor TfrViewDireccionEntregaPedidoProv.Destroy;
|
||
begin
|
||
cbListaObras.Properties.OnValidate := Nil;
|
||
cbListaAlmacenes.Properties.OnValidate := Nil;
|
||
|
||
FAlmacenesController := Nil;
|
||
FAlmacenes := Nil;
|
||
|
||
FObrasController := Nil;
|
||
FObras := Nil;
|
||
|
||
FController := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.edtEntregarAPropertiesButtonClick(
|
||
Sender: TObject; AButtonIndex: Integer);
|
||
var
|
||
AID_Subcontrata : Integer;
|
||
APersonaContacto : String;
|
||
begin
|
||
inherited;
|
||
AID_Subcontrata := -1;
|
||
|
||
{ ********************************************************* REPASAR
|
||
if actListaObras.Checked then
|
||
AID_Subcontrata := FObras.ID_SUBCONTRATA;}
|
||
|
||
APersonaContacto := FPedido.PERSONA_CONTACTO;
|
||
|
||
if ElegirPersonaContactoPedido(AID_Subcontrata, APersonaContacto) then
|
||
begin
|
||
FPedido.Edit;
|
||
FPedido.PERSONA_CONTACTO := APersonaContacto;
|
||
end;
|
||
end;
|
||
|
||
function TfrViewDireccionEntregaPedidoProv.GetPedidoProveedor: IBizPedidoProveedor;
|
||
begin
|
||
Result := FPedido;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.ID_OBRAOnChange(
|
||
Sender: TDACustomField);
|
||
begin
|
||
PrepararObra;
|
||
CambioDireccionObra;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.RefrescarDireccion;
|
||
begin
|
||
txtDireccion.Caption := '';
|
||
if Assigned(FPedido) then
|
||
begin
|
||
if (actOtro.Checked) then
|
||
begin
|
||
cbListaAlmacenes.Enabled := False;
|
||
cbListaAlmacenes.Text := '';
|
||
cbListaObras.Enabled := False;
|
||
cbListaObras.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
|
||
txtDireccion.Enabled := False;
|
||
cbListaObras.Enabled := False;
|
||
cbListaObras.Text := '';
|
||
|
||
cbListaAlmacenes.Enabled := True;
|
||
cbListaAlmacenes.DroppedDown := True;
|
||
bModificar.Enabled := False;
|
||
end
|
||
else begin
|
||
bModificar.Enabled := False;
|
||
|
||
txtDireccion.Enabled := False;
|
||
cbListaAlmacenes.Enabled := False;
|
||
cbListaAlmacenes.Text := '';
|
||
|
||
cbListaObras.Enabled := True;
|
||
cbListaObras.DroppedDown := True;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.PrepararObra;
|
||
begin
|
||
if Assigned(FPedido) and FPedido.Active then
|
||
if FPedido.ID_OBRAIsNull then
|
||
begin
|
||
actListaObras.Enabled := False;
|
||
actListaObras.Caption := 'Recibir el pedido en la direcci<63>n de la obra.';
|
||
|
||
if actListaObras.Checked then
|
||
actListaAlmacenes.Execute;
|
||
end
|
||
else begin
|
||
actListaObras.Enabled := True;
|
||
|
||
FObras.DataTable.First;
|
||
FObras.DataTable.Locate('ID', FPedido.ID_OBRA, []);
|
||
actListaObras.Caption := 'Recibir el pedido en la direcci<63>n de la obra (' + FObras.NOMBRE + ')';
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor(
|
||
const Value: IBizPedidoProveedor);
|
||
begin
|
||
cbListaAlmacenes.Properties.OnValidate := NIL;
|
||
cbListaObras.Properties.OnValidate := NIL;
|
||
dsPedido.DataTable := nil;
|
||
|
||
FPedido := Value;
|
||
|
||
dsPedido.DataTable := FPedido.DataTable;
|
||
FPedido.DataTable.FieldByName('ID_OBRA').OnChange := ID_OBRAOnChange;
|
||
|
||
cbListaAlmacenes.Properties.OnValidate := cbListaAlmacenesPropertiesValidate;
|
||
cbListaObras.Properties.OnValidate := cbListaObrasPropertiesValidate;
|
||
|
||
if (FPedido.EsNuevo) then
|
||
CambioDireccionAlmacen
|
||
else begin
|
||
if (FPedido.ID_ALMACEN > 0) then
|
||
if FPedido.TIPO_ALMACEN = CTE_INV_ALMACEN then
|
||
actListaAlmacenes.Checked := True
|
||
else begin
|
||
actListaObras.Checked := True
|
||
end
|
||
else
|
||
actOtro.Checked := True;
|
||
end;
|
||
PrepararObra;
|
||
RefrescarDireccion;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.SetReadOnly(Value: Boolean);
|
||
begin
|
||
inherited;
|
||
|
||
if (csLoading in Self.ComponentState) then
|
||
Exit;
|
||
|
||
rdxDestino1.Enabled := not ReadOnly;
|
||
rdxDestino2.Enabled := not ReadOnly;
|
||
RadioButton1.Enabled := not ReadOnly;
|
||
end;
|
||
|
||
procedure TfrViewDireccionEntregaPedidoProv.txtDireccionDblClick(
|
||
Sender: TObject);
|
||
begin
|
||
inherited;
|
||
actOtro.Execute;
|
||
end;
|
||
|
||
end.
|