diff --git a/Source/ApplicationBase/uFactuGES_App.pas b/Source/ApplicationBase/uFactuGES_App.pas index d5cbdf44..f1cc9408 100644 --- a/Source/ApplicationBase/uFactuGES_App.pas +++ b/Source/ApplicationBase/uFactuGES_App.pas @@ -46,6 +46,7 @@ type function GetAppSplashForm : IAppSplashForm; procedure SetAppSplashForm (AAppSplashForm : IAppSplashForm); + procedure SeleccionarEmpresa; procedure CambiarEmpresa(const AIDEmpresa : Integer); procedure CambiarEmpresaPorDefecto; procedure CambiarEjercicio(const AIDEmpresa : Integer); @@ -138,6 +139,7 @@ type procedure Configurar; + procedure SeleccionarEmpresa; procedure CambiarEmpresa(const AIDEmpresa : Integer); procedure CambiarEmpresaPorDefecto; procedure CambiarEjercicio(const AIDEmpresa : Integer); @@ -168,7 +170,7 @@ var implementation uses - Dialogs, uDialogUtils, cxControls, uUsuariosViewRegister, uDMBase, + Windows, Dialogs, JSDialog, JSDialogs, uDialogUtils, cxControls, uUsuariosViewRegister, uDMBase, uEmpresasViewRegister, uEjerciciosController, uAppInfoUtils; procedure TAppFactuGES.CambiarEjercicio(const AIDEmpresa: Integer); @@ -429,6 +431,49 @@ begin FDoMainFormEvent := AMainFormEvent; end; +procedure TAppFactuGES.SeleccionarEmpresa; +var + JsDialog: TJSDialog; + AEmpresas: IBizEmpresa; + AEmpresasController: IEmpresasController; +begin + JsDialog := TJSDialog.Create(nil); + try + JsDialog.Content.Add('Selección de empresa'); + JsDialog.Instruction.Text := 'Elija la empresa con la que desea trabajar.'; + JsDialog.DialogOptions := [doCommandLinks, doModal]; + JsDialog.ButtonBar.Buttons := [cbOk]; + JsDialog.Width := 600; + + + //Añadimos las diferentes empresas que existan + AEmpresasController := TEmpresasController.Create; + AEmpresas := AEmpresasController.BuscarTodos; + AEmpresas.DataTable.Active := True; + + AEmpresas.Datatable.First; + while not AEmpresas.Datatable.eof do + begin + with JsDialog.CustomButtons.Add do + begin + Caption := AEmpresas.NIF_CIF + ' - ' + AEmpresas.NOMBRE; + Value := AEmpresas.ID; + end; + AEmpresas.DataTable.Next; + end; + AEmpresas.DataTable.First; + + if JsDialog.Execute <> IDCANCEL then + if JsDialog.CustomButtonResult > 0 then + CambiarEmpresa(JsDialog.CustomButtonResult); + + finally + FreeAndNIL(JsDialog); + AEmpresasController:= NIL; + AEmpresas := NIL; + end; +end; + procedure TAppFactuGES.SetAppSplashForm(AAppSplashForm: IAppSplashForm); begin FAppSplashForm := AAppSplashForm; diff --git a/Source/Cliente/uPantallaPrincipal.dfm b/Source/Cliente/uPantallaPrincipal.dfm index 6d68be0b..13b329af 100644 --- a/Source/Cliente/uPantallaPrincipal.dfm +++ b/Source/Cliente/uPantallaPrincipal.dfm @@ -310,7 +310,6 @@ object fPantallaPrincipal: TfPantallaPrincipal Category = 'Menus' Caption = 'Empresa' OnExecute = actMenuEmpresaExecute - OnUpdate = actMenuComprasUpdate end object actMenuInformes: TAction Category = 'Menus' @@ -644,8 +643,8 @@ object fPantallaPrincipal: TfPantallaPrincipal Tag = 1000 Action = actMenuEmpresa object Listadeempresas1_OLD: TMenuItem - Caption = 'Lista de empresas' - Visible = False + Caption = 'Selecci'#243'n de empresas' + OnClick = Listadeempresas1_OLDClick end object N1_OLD: TMenuItem Caption = '-' diff --git a/Source/Cliente/uPantallaPrincipal.pas b/Source/Cliente/uPantallaPrincipal.pas index c5d98708..ef72c71d 100644 --- a/Source/Cliente/uPantallaPrincipal.pas +++ b/Source/Cliente/uPantallaPrincipal.pas @@ -123,6 +123,7 @@ type procedure actMenuContabilidadExecute(Sender: TObject); procedure actMenuEmpresaExecute(Sender: TObject); procedure actMenuInformesExecute(Sender: TObject); + procedure Listadeempresas1_OLDClick(Sender: TObject); private FContenido : TCustomEditor; procedure ShowEmbedded(AEditor : ICustomEditor); @@ -198,6 +199,9 @@ begin ClientWidth := Screen.Width ; ClientHeight := Screen.Height; Refresh; + + //Sacamos la lista de empresas para que el usuario elija con la que va a trabajar + AppFactuGES.SeleccionarEmpresa; end; procedure TfPantallaPrincipal.RefrescarUI; @@ -314,7 +318,8 @@ end; procedure TfPantallaPrincipal.Informacindeempresa1Click(Sender: TObject); begin - AppFactuGES.EmpresasController.Ver(AppFactuGES.EmpresaActiva); + if Assigned(AppFactuGES.EmpresaActiva) then + AppFactuGES.EmpresasController.Ver(AppFactuGES.EmpresaActiva); end; procedure TfPantallaPrincipal.InicializarUI; @@ -597,6 +602,11 @@ begin RefrescarUI; end; +procedure TfPantallaPrincipal.Listadeempresas1_OLDClick(Sender: TObject); +begin + AppFactuGES.SeleccionarEmpresa; +end; + procedure TfPantallaPrincipal.actConexionExecute(Sender: TObject); begin dmConexion.ConfigurarConexion;