unit uViewDatosYSeleccionContacto; 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; TfrViewDatosYSeleccionContacto = class(TfrViewBase, IViewDatosYSeleccionContacto) edtlNombre: TcxDBTextEdit; dxLayoutControl1Group_Root: TdxLayoutGroup; dxLayoutControl1: TdxLayoutControl; dxLayoutControl1Group1: TdxLayoutGroup; dxLayoutControl1Item1: TdxLayoutItem; dxLayoutControl1Item2: TdxLayoutItem; edtTrabajo: TcxDBTextEdit; dxLayoutControl1Item3: TdxLayoutItem; edtParticular: TcxDBTextEdit; dxLayoutControl1Item4: TdxLayoutItem; edtMovil: TcxDBTextEdit; dxLayoutControl1Item5: TdxLayoutItem; edtCorreo: TcxDBTextEdit; dxLayoutControl1Group2: TdxLayoutGroup; dxLayoutControl1Item6: TdxLayoutItem; edtFax: 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 frViewDatosYSeleccionContacto: TfrViewDatosYSeleccionContacto; implementation {$R *.dfm} uses uDataModuleContactos; procedure TfrViewDatosYSeleccionContacto.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 TfrViewDatosYSeleccionContacto.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 TfrViewDatosYSeleccionContacto.actVerContactoExecute(Sender: TObject); begin inherited; Contacto.Show; end; procedure TfrViewDatosYSeleccionContacto.actVerContactoUpdate(Sender: TObject); begin inherited; (Sender as TAction).Enabled := Length(edtlNombre.Text) > 0; end; procedure TfrViewDatosYSeleccionContacto.cxLabel1Click(Sender: TObject); begin inherited; actVerContacto.Execute; end; function TfrViewDatosYSeleccionContacto.GetContacto: IBizContacto; begin Result := FContacto; end; procedure TfrViewDatosYSeleccionContacto.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 TfrViewDatosYSeleccionContacto.GetOnContactoChanged: TNotifyEvent; begin Result := FOnContactoChanged; end; procedure TfrViewDatosYSeleccionContacto.SetOnContactoChanged(const Value: TNotifyEvent); begin FOnContactoChanged := Value; end; end.