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, cxCheckBox, cxDBEdit; 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; cbLista: TcxDBLookupComboBox; dxLayoutGroup1: TdxLayoutGroup; dxLayoutControl1Item3: TdxLayoutItem; ActionList1: TActionList; actLista: TAction; actOtro: TAction; dsPedido: TDADataSource; dsAlmacenes: TDADataSource; dxLayoutControl1Item1: TdxLayoutItem; bModificar: TBitBtn; txtDireccion: TStaticText; dxLayoutControl1Item5: TdxLayoutItem; dxLayoutControl1Item4: TdxLayoutItem; cxLista: TcxCheckBox; dxLayoutControl1Item6: TdxLayoutItem; cxOtro: TcxCheckBox; procedure actListaExecute(Sender: TObject); procedure actOtroExecute(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 LimpiarDireccionEntrega; 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, schPedidosProveedorClient_Intf, uCustomView; procedure TfrViewDireccionEntregaPedidoProv.actListaExecute(Sender: TObject); begin if cxLista.Checked then begin cbLista.Enabled := True; cbLista.DroppedDown := True; end else begin cbLista.Enabled := False; cbLista.Text := ''; if Assigned(FPedido) and (FPedido.ID_ALMACEN > 0) then begin FPedido.Edit; FPedido.ID_ALMACEN := 0; end; end; end; procedure TfrViewDireccionEntregaPedidoProv.actOtroExecute(Sender: TObject); begin if cxOtro.Checked then begin if Assigned(FPedido) then FController.VerDireccionEntrega(FPedido); txtDireccion.Enabled := True; bModificar.Enabled := True; end else begin txtDireccion.Enabled := False; bModificar.Enabled := False; LimpiarDireccionEntrega; end; RefrescarDireccion; end; procedure TfrViewDireccionEntregaPedidoProv.bModificarClick(Sender: TObject); begin inherited; actOtro.Execute; end; procedure TfrViewDireccionEntregaPedidoProv.LimpiarDireccionEntrega; begin FController.LimpiarDireccion(FPedido); RefrescarDireccion; 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 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; end; procedure TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor( const Value: IBizPedidoProveedor); begin dsPedido.DataTable := nil; FPedido := Value; if Assigned(FPedido) then begin dsPedido.DataTable := FPedido.DataTable; actLista.Checked := True; actOtro.Checked := True; if (FPedido.EsNuevo) then begin LimpiarDireccionEntrega; actOtro.Checked := False; end else begin if (FPedido.ID_ALMACEN <= 0) then actLista.Checked := False; if (Length(FPedido.CALLE) = 0) then actOtro.Checked := False; end; end; RefrescarDireccion; cxLista.Action := actLista; cxOtro.Action := actOtro; end; procedure TfrViewDireccionEntregaPedidoProv.SetReadOnly(Value: Boolean); begin inherited; if ReadOnly then begin cxLista.Enabled := False; cxOtro.Enabled := False; end; end; procedure TfrViewDireccionEntregaPedidoProv.txtDireccionDblClick(Sender: TObject); begin inherited; actOtro.Execute; end; end.