unit uEditorDireccionEntregaAlbaranCliente; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls, Mask, DBCtrls, DB, uDADataTable, cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, uIEditorDireccionEntregaAlbaranCliente, uBizAlbaranesCliente, uDAInterfaces, cxMemo, cxGraphics, cxMaskEdit, cxDropDownEdit; type TfEditorDireccionEntregaAlbaranCliente = class(TForm, IEditorDireccionEntregaAlbaranCliente) OKBtn: TButton; CancelBtn: TButton; Bevel1: TBevel; eDireccion2: TDBEdit; ePoblacion: TDBEdit; eProvincia: TDBEdit; eCodigoPostal: TDBEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; dsDireccion: TDADataSource; Label6: TLabel; ePersonaContacto: TDBEdit; Label7: TLabel; eTelefono: TDBEdit; eDireccion: TcxDBMemo; cbPais: TcxDBComboBox; Label5: TLabel; procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure cbPaisPropertiesInitPopup(Sender: TObject); private pDireccion: String; pPoblacion: String; pProvincia: String; pCodigoPostal: String; pPersonaContacto: String; pTelefono: String; pPais: String; FPaises : TStringList; FAlbaran : IBizAlbaranCliente; procedure CargarPaises; function GetAlbaran: IBizAlbaranCliente; procedure SetAlbaran(const Value: IBizAlbaranCliente); property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran; end; implementation {$R *.dfm} { TfEditorDireccionEntrega } uses uProvinciasPoblacionesController; procedure TfEditorDireccionEntregaAlbaranCliente.CargarPaises; var i : integer; begin with TProvinciasPoblacionesController.Create do try FPaises := DarListaPaises; with cbPais.Properties.Items do begin BeginUpdate; try Clear; for i := 0 to FPaises.Count - 1 do Add(FPaises.Names[i]); finally EndUpdate; end; end; finally Free; end; end; procedure TfEditorDireccionEntregaAlbaranCliente.cbPaisPropertiesInitPopup( Sender: TObject); begin ShowHourglassCursor; try if not Assigned(FPaises) then CargarPaises; finally HideHourglassCursor; end; end; procedure TfEditorDireccionEntregaAlbaranCliente.FormClose(Sender: TObject; var Action: TCloseAction); begin //En el caso de cancelar se recuperan los valores iniciales if (Self.ModalResult <> mrOk) and (dsDireccion.DataTable.State in dsEditModes) then begin eDireccion.EditValue := pDireccion; ePoblacion.Field.Value := pPoblacion; eProvincia.Field.Value := pProvincia; cbPais.EditValue := pPais; eCodigoPostal.Field.Value := pCodigoPostal; ePersonaContacto.Field.Value := pPersonaContacto; eTelefono.Field.Value := pTelefono; end; end; procedure TfEditorDireccionEntregaAlbaranCliente.FormShow(Sender: TObject); begin //Guardamos los valores iniciales por si al final el usuario cancela pDireccion := eDireccion.Text; pPoblacion := ePoblacion.Text; pProvincia := eProvincia.Text; pCodigoPostal := eCodigoPostal.Text; pPersonaContacto := ePersonaContacto.Text; pTelefono := eTelefono.Text; pPais := cbPais.EditValue; end; function TfEditorDireccionEntregaAlbaranCliente.GetAlbaran: IBizAlbaranCliente; begin Result := FAlbaran; end; procedure TfEditorDireccionEntregaAlbaranCliente.SetAlbaran(const Value: IBizAlbaranCliente); begin FAlbaran := Value; if Assigned(FAlbaran) then dsDireccion.DataTable := FAlbaran.DataTable else dsDireccion.DataTable := NIL; end; end.