From 8c427f87920a9d2c15b71552f6844f1c00933877 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 19 Dec 2008 17:13:36 +0000 Subject: [PATCH] =?UTF-8?q?Se=20adapta=20para=20poder=20elegir=20la=20empr?= =?UTF-8?q?esa=20nada=20mas=20arrancar=20la=20aplicaci=C3=B3n,=20ademas=20?= =?UTF-8?q?de=20poder=20cambiar=20de=20emrpesa=20en=20los=20menus=20superi?= =?UTF-8?q?ores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@375 f4e31baf-9722-1c47-927c-6f952f962d4b --- Source/ApplicationBase/uFactuGES_App.pas | 47 +++++++++++++++++++++++- Source/Cliente/uPantallaPrincipal.dfm | 5 +-- Source/Cliente/uPantallaPrincipal.pas | 12 +++++- 3 files changed, 59 insertions(+), 5 deletions(-) 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;