unit uViewEmpleado; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewContacto, dxLayoutLookAndFeels, DB, uDADataTable, dxLayoutControl, cxMemo, cxDBEdit, cxContainer, cxEdit, cxTextEdit, cxControls, cxMaskEdit, cxSpinEdit, ImgList, PngImageList, ActnList, cxHyperLinkEdit, Buttons, PngSpeedButton, cxDropDownEdit, cxCalendar, cxGraphics, uGruposEmpleadoController; type IViewEmpleado = interface(IViewContacto) ['{245F4A36-39A4-4081-9826-F05FBBC729AE}'] end; TfrViewEmpleado = class(TfrViewContacto, IViewEmpleado) eFechaNacimiento: TcxDBDateEdit; dxLayoutControlContactoItem16: TdxLayoutItem; dxLayoutControlContactoItem19: TdxLayoutItem; eFechaAltaEmpresa: TcxDBDateEdit; dxLayoutControlContactoGroup10: TdxLayoutGroup; dxLayoutControlContactoItem20: TdxLayoutItem; cbCategoria: TcxDBComboBox; procedure CustomViewCreate(Sender: TObject); procedure CustomViewDestroy(Sender: TObject); procedure cbCategoriaPropertiesInitPopup(Sender: TObject); procedure cbCategoriaPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); protected FGrupoController: IGruposEmpleadoController; public { Public declarations } end; implementation {$R *.dfm} uses uBizGruposEmpleado, uBizContactos; procedure TfrViewEmpleado.cbCategoriaPropertiesInitPopup(Sender: TObject); begin inherited; with cbCategoria.Properties.Items do begin BeginUpdate; try Clear; AddStrings(FGrupoController.DarListaGruposEmpleado); finally EndUpdate; end; end; end; procedure TfrViewEmpleado.cbCategoriaPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var AGrupo : IBizGrupoEmpleado; begin inherited; with (Sender as TcxDBComboBox) do begin if (Length(DisplayValue) > 0) and (DisplayValue <> (Contacto as IBizEmpleado).CATEGORIA) then if Properties.LookupItems.IndexOf(DisplayValue) < 0 then begin Properties.LookupItems.BeginUpdate; AGrupo := FGrupoController.BuscarTodos; AGrupo.DataTable.Active := True; try FGrupoController.Anadir(AGrupo); AGrupo.DESCRIPCION := DisplayValue; FGrupoController.Guardar(AGrupo); Properties.LookupItems.Add(DisplayValue); finally Properties.LookupItems.EndUpdate; AGrupo := NIL; end; end; end; end; procedure TfrViewEmpleado.CustomViewCreate(Sender: TObject); begin inherited; FGrupoController := TGruposEmpleadoController.Create; end; procedure TfrViewEmpleado.CustomViewDestroy(Sender: TObject); begin FGrupoController := NIL; inherited; end; end.