unit uViewDatosYSeleccionContacto2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, StdCtrls, cxControls, cxContainer, cxEdit, cxLabel, cxDBLabel, ExtCtrls, DB, uDADataTable, uBizContacto, ComCtrls, ToolWin, ActnList, ImgList, PngImageList, cxTextEdit, cxDBEdit, pngimage, JvExControls, JvComponent, JvButton, JvTransparentButton, Mask, DBCtrls, dxLayoutControl; type IViewDatosYSeleccionContacto = interface(IViewBase) ['{FCBC26C6-5B00-4985-B8AD-E91C79BE469B}'] function GetContacto: IBizContacto; procedure SetContacto(Value: IBizContacto); property Contacto: IBizContacto read GetContacto write SetContacto; function GetOnContactoChanged : TNotifyEvent; procedure SetOnContactoChanged (const Value : TNotifyEvent); property OnContactoChanged : TNotifyEvent read GetOnContactoChanged write SetOnContactoChanged; end; TfrViewDatosYSeleccionContacto2 = class(TfrViewBase, IViewDatosYSeleccionContacto) edtlNombre: TcxDBTextEdit; dxLayoutControl1Group_Root: TdxLayoutGroup; dxLayoutControl1: TdxLayoutControl; dxLayoutControl1Group1: TdxLayoutGroup; dxLayoutControl1Item1: TdxLayoutItem; dxLayoutControl1Item2: TdxLayoutItem; edtCalle: TcxDBTextEdit; dxLayoutControl1Item3: TdxLayoutItem; edtProvincia: TcxDBTextEdit; dxLayoutControl1Item5: TdxLayoutItem; edtPoblacion: TcxDBTextEdit; dxLayoutControl1Item6: TdxLayoutItem; edtCodigoPostal: TcxDBTextEdit; dxLayoutControl1Group3: TdxLayoutGroup; dxLayoutControl1Item7: TdxLayoutItem; ToolBar1: TToolBar; ToolButton1: TToolButton; ToolButton3: TToolButton; ToolButton2: TToolButton; dxLayoutControl1Item8: TdxLayoutItem; ToolBar2: TToolBar; ToolButton4: TToolButton; DADataSource: TDADataSource; ActionList1: TActionList; actElegirContacto: TAction; actAnadirContacto: TAction; actVerContacto: TAction; PngImageList: TPngImageList; edtNIFCIF: TcxDBTextEdit; dxLayoutControl1Item9: TdxLayoutItem; procedure actElegirContactoExecute(Sender: TObject); procedure actAnadirContactoExecute(Sender: TObject); procedure actVerContactoExecute(Sender: TObject); procedure actVerContactoUpdate(Sender: TObject); procedure cxLabel1Click(Sender: TObject); private FContacto : IBizContacto; FOnContactoChanged : TNotifyEvent; protected function GetContacto: IBizContacto; procedure SetContacto(Value: IBizContacto); function GetOnContactoChanged : TNotifyEvent; procedure SetOnContactoChanged (const Value : TNotifyEvent); public property Contacto: IBizContacto read GetContacto write SetContacto; property OnContactoChanged : TNotifyEvent read GetOnContactoChanged write SetOnContactoChanged; end; var frViewDatosYSeleccionContacto2: TfrViewDatosYSeleccionContacto2; implementation {$R *.dfm} uses uDataModuleContactos; procedure TfrViewDatosYSeleccionContacto2.actElegirContactoExecute(Sender: TObject); var AContacto : IBizContacto; begin inherited; AContacto := dmContactos.GetContactos; try if AContacto.ShowForSelect = mrOK then begin Contacto := dmContactos.GetItemsSeleccionados(AContacto); end; finally AContacto := NIL; end; end; procedure TfrViewDatosYSeleccionContacto2.actAnadirContactoExecute( Sender: TObject); var AContactos : IBizContacto; begin inherited; AContactos := dmContactos.GetContacto(-1); try AContactos.DataTable.Active := True; AContactos.Insert; AContactos.Show; if AContactos.DataTable.RecordCount > 0 then Contacto := AContactos; finally AContactos := NIL; end; end; procedure TfrViewDatosYSeleccionContacto2.actVerContactoExecute(Sender: TObject); begin inherited; Contacto.Show; end; procedure TfrViewDatosYSeleccionContacto2.actVerContactoUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := Length(edtlNombre.Text) > 0; end; procedure TfrViewDatosYSeleccionContacto2.cxLabel1Click(Sender: TObject); begin inherited; actVerContacto.Execute; end; function TfrViewDatosYSeleccionContacto2.GetContacto: IBizContacto; begin Result := FContacto; end; procedure TfrViewDatosYSeleccionContacto2.SetContacto(Value: IBizContacto); begin FContacto := Value; DADataSource.DataTable := FContacto.DataTable; if not FContacto.DataTable.Active then FContacto.DataTable.Active := True; if Assigned(FOnContactoChanged) then FOnContactoChanged(Self); end; function TfrViewDatosYSeleccionContacto2.GetOnContactoChanged: TNotifyEvent; begin Result := FOnContactoChanged; end; procedure TfrViewDatosYSeleccionContacto2.SetOnContactoChanged(const Value: TNotifyEvent); begin FOnContactoChanged := Value; end; end.