unit uEditorDireccionEntregaContratoCliente; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls, Mask, DBCtrls, DB, uDADataTable, cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, uIEditorDireccionEntregaContratoCliente, uBizContratosCliente, uDAInterfaces, cxMemo, cxGraphics, cxMaskEdit, cxDropDownEdit; type TfEditorDireccionEntregaContratoCliente = class(TForm, IEditorDireccionEntregaContratoCliente) 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; Label5: TLabel; cbPais: TcxDBComboBox; 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; FContrato : IBizContratoCliente; procedure CargarPaises; function GetContrato: IBizContratoCliente; procedure SetContrato(const Value: IBizContratoCliente); property Contrato: IBizContratoCliente read GetContrato write SetContrato; end; implementation {$R *.dfm} { TfEditorDireccionEntrega } uses uProvinciasPoblacionesController; procedure TfEditorDireccionEntregaContratoCliente.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 TfEditorDireccionEntregaContratoCliente.cbPaisPropertiesInitPopup(Sender: TObject); begin ShowHourglassCursor; try if not Assigned(FPaises) then CargarPaises; finally HideHourglassCursor; end; end; procedure TfEditorDireccionEntregaContratoCliente.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 TfEditorDireccionEntregaContratoCliente.FormShow(Sender: TObject); begin //Guardamos los valores iniciales por si al final el usuario cancela pDireccion := eDireccion.Text; pPoblacion := ePoblacion.Text; pProvincia := eProvincia.Text; pPais := cbPais.EditValue; pCodigoPostal := eCodigoPostal.Text; pPersonaContacto := ePersonaContacto.Text; pTelefono := eTelefono.Text; end; function TfEditorDireccionEntregaContratoCliente.GetContrato: IBizContratoCliente; begin Result := FContrato; end; procedure TfEditorDireccionEntregaContratoCliente.SetContrato(const Value: IBizContratoCliente); begin FContrato := Value; if Assigned(FContrato) then dsDireccion.DataTable := FContrato.DataTable else dsDireccion.DataTable := NIL; end; end.