Exferia/Exferia_KairosPro/Exferia_KairosPRO/4_Vistas/P_ValoresGenerales.cs

179 lines
7.2 KiB
C#

using Exferia_Aplicacion.General;
using Exferia_Aplicacion.Visualizacion;
using Exferia_Controles;
using Exferia_EntityFramework;
using Exferia_General;
using Exferia_KairosPRO._4_Vistas.Controladoras;
using Exferia_KairosPRO.General;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using static Exferia_Aplicacion.General.Enumerados;
namespace Exferia_KairosPRO._4_Vistas
{
public partial class P_ValoresGenerales : Exferia_Formularios.P_Base_Mantenimientos
{
#region Variables Generales
private P_ValoresGenerales_Controladora g_obj_Controladora;
private bool g_bol_ConstructorPantalla_Terminado_Correctamente = true;
public PRV_OpcionesDetalle g_mdl_PRV_OpcionesDetalle = null;
internal List<INTERNO_Permisos_Modelo> g_lst_INTERNO_Permisos_Modelo = null;
#endregion
#region Objetos en Pantalla
//Exferia_F3_SoloSeleccion
internal Exferia_F3_SoloSeleccion Exferia_F3_SoloSeleccion_ConfiguracionEmail { get{ return ex_usc_F3_P_ValoresGenerales_ConfiguracionEmail; } }
//Exferia_TextBox
internal Exferia_TextBox Exferia_TextBox_IP { get { return ex_txt_P_ValoresGenerales_IP; } }
internal Exferia_TextBox Exferia_TextBox_Puerto { get { return ex_txt_P_ValoresGenerales_Puerto; } }
#endregion
#region Constructor
public P_ValoresGenerales(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle)
{
InitializeComponent();
Repintar.Empezar(this);
CheckForIllegalCrossThreadCalls = false;
//Empresa seleccionada y Fecha de trabajo ........................................................
P_Base_ValoresGenerales = _mdl_INTERNO_ValoresGenerales_Modelo;
P_Base_FechaTrabajo = _dtt_FechaTrabajo;
//Instanciar Controladora
g_obj_Controladora = new P_ValoresGenerales_Controladora(this);
//Datos de Opciones detalle
g_mdl_PRV_OpcionesDetalle = _mdl_PRV_OpcionesDetalle;
//Buscar los Permisos
g_lst_INTERNO_Permisos_Modelo = Datos_Generales.Permisos_Buscar(g_mdl_PRV_OpcionesDetalle.opcion);
//Mirrar si hay que bloquear los controles, si solo puede ver los datos
if ((P_Base_TipoAperturaPantalla != 0 && Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Modificar, false)) == false)
{
//Bloquear los controles
SoloLectura.Empezar(this, true);
}
//Titulo de la Pantalla
P_Base_TituloPantalla = g_mdl_PRV_OpcionesDetalle.descripcion_TituloMantenimiento;
try
{
//Label con Empresa Seleccionada
if (P_Base_ValoresGenerales != null)
{
try
{
P_Base_Mantenimientos_InformacionEmpresaSeleccionada = P_Base_ValoresGenerales.str_Empresa_Descripcion + " - " +
"(" + P_Base_FechaTrabajo.ToString("dd/MM/yyyy") + ")";
}
catch (Exception ex)
{
//No se muestra mensaje pero se guarda en el log
Control_Errores.Errores_Log("", ex, nameof(P_ValoresGenerales) + "/" + nameof(P_ValoresGenerales));
}
}
//..................................................................................................................................
//Bloquear pantalla hasta que termine la carga por defecto.....
Enabled = false;
//.............................................................
//CONFIGURACIONEMAIL
ex_usc_F3_P_ValoresGenerales_ConfiguracionEmail.Exferia_F3_SoloSeleccion_PRINCIPAL_Opcion_BuscarDatos = Variables.G_STR_OPCION_KRS_CONFIGURACIONESEMAILS;
ex_usc_F3_P_ValoresGenerales_ConfiguracionEmail.Exferia_F3_SoloSeleccion_PantallaContenedora = this;
ex_usc_F3_P_ValoresGenerales_ConfiguracionEmail.Exferia_F3_SoloSeleccion_PRINCIPAL_BUSCARTITULO = false;
}
catch (Control_Errores)
{
g_bol_ConstructorPantalla_Terminado_Correctamente = false;
}
catch (Exception ex)
{
g_bol_ConstructorPantalla_Terminado_Correctamente = false;
Control_Errores.Errores_Log("", ex, nameof(P_ValoresGenerales) + "/" + nameof(P_ValoresGenerales));
}
finally
{
//Bloquear pantalla hasta que termine la carga por defecto .............
Enabled = true;
//......................................................................
}
}
#endregion
#region Inicio Pantalla
private void P_ValoresGenerales_Shown(object sender, EventArgs e)
{
try
{
if (g_bol_ConstructorPantalla_Terminado_Correctamente)
{
if ((Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Ver, true)))
{
g_obj_Controladora.RecargarDatos();
}
}
else
{
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
Salir_P_Base();
}
}
catch (Control_Errores)
{
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
Salir_P_Base();
}
catch (Exception ex)
{
//No se muestra mensaje pero se guarda en el log
Control_Errores.Errores_Log("", ex, nameof(P_ValoresGenerales) + "/" + nameof(P_ValoresGenerales_Shown));
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
Salir_P_Base();
}
}
#endregion
#region Boton Grabar,Borrar
private void ex_btn_P_ValoresGenerales_Grabar_Click(object sender, EventArgs e)
{
Grabar();
}
private void Grabar()
{
if ((Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Anadir, true)))
{
g_obj_Controladora.GrabarDatos();
}
}
private void ex_btn_P_ValoresGenerales_Borrar_Click(object sender, EventArgs e)
{
Borrar();
}
private void Borrar()
{
if (Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Borrar, true))
{
g_obj_Controladora.BorrarDatos();
}
}
#endregion
}
}