using Exferia_Aplicacion.General; using Exferia_Aplicacion.Visualizacion; using Exferia_Controles; using Exferia_EntityFramework; using Exferia_General; using Exferia_KairosPRO._1_Modelos; using Exferia_KairosPRO._4_Vistas.Controladoras; using Exferia_KairosPRO.General; using Exferia_KairosPRO_EF; 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_EmpleadoContrato : Exferia_Formularios.P_Base_Mantenimientos { #region Variables Generales private P_EmpleadoContrato_Controladora g_obj_Controladora; private bool g_bol_ConstructorPantalla_Terminado_Correctamente = true; public PRV_OpcionesDetalle g_mdl_PRV_OpcionesDetalle = null; internal List g_lst_INTERNO_Permisos_Modelo = null; #endregion #region Objetos en Pantalla //Exferia_FechaSeleccion internal Exferia_FechaSeleccion Exferia_FechaSeleccion_FechaDesde { get { return ex_usc_P_EmpleadoContrato_FechaDesde; } } internal Exferia_FechaSeleccion Exferia_FechaSeleccion_FechaHasta { get { return ex_usc_P_EmpleadoContrato_FechaHasta; } } //Exferia_TextBox internal Exferia_TextBox Exferia_TextBox_NumeroHorasAnuales { get { return ex_txt_P_EmpleadoContrato_NumeroHorasAnuales; } } //Panel internal Panel Panel_CargaDias { get { return pnl_P_EmpleadoContrato_CargaDias; } } #endregion #region Constructor public P_EmpleadoContrato(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, string _str_TituloAuxiliar, KRS_Empleados _mdl_KRS_Empleados, List _lst_INTERNO_Permisos_Modelo, List _lst_KRS_Empleados_Contratos, string str_Opcion) { InitializeComponent(); try { Repintar.Empezar(this); CheckForIllegalCrossThreadCalls = false; g_obj_Controladora = new P_EmpleadoContrato_Controladora(this, _lst_KRS_Empleados_Contratos); //tabla relacionada g_obj_Controladora.g_mdl_KRS_Empleados = _mdl_KRS_Empleados; ex_lbl_P_EmpleadoContrato_Empleado.Text = _mdl_KRS_Empleados.nombre; //Empresa seleccionada y fecha de trabajo P_Base_ValoresGenerales = _mdl_INTERNO_ValoresGenerales_Modelo; P_Base_FechaTrabajo = _dtt_FechaTrabajo; //Datos de Opciones detalle g_mdl_PRV_OpcionesDetalle = Datos_Generales.PRV_Opciones_Buscar_Detalles(str_Opcion); //Bucar Permisos g_lst_INTERNO_Permisos_Modelo = _lst_INTERNO_Permisos_Modelo; //Poner los Botones que no se pueden poner bloqueados o de solo lectura ex_btn_P_EmpleadoContrato_Borrar.Exferia_Button_Bloqueable = false; ex_btn_P_EmpleadoContrato_Grabar.Exferia_Button_Bloqueable = false; //Mirar 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) { //Bloqueo los Controles SoloLectura.Empezar(this, true); } //Titulo de la Pantalla ............................................................................. P_Base_TituloPantalla = g_mdl_PRV_OpcionesDetalle.descripcion_TituloMantenimiento + " del " + _str_TituloAuxiliar; // 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.Message, ex, nameof(P_EmpleadoContrato) + "/" + nameof(P_EmpleadoContrato)); } } //.................................................................................................... //Bloquear pantalla hasta que termine la carga por defecto ..... Enabled = false; //............................................................. } catch (Control_Errores) { } catch (Exception ex) { //No se muestra mensaje pero se guarda en el log Control_Errores.Errores_Log(ex.Message, ex, nameof(P_EmpleadoContrato) + "/" + nameof(P_EmpleadoContrato)); } finally { //Bloquear pantalla hasta que termine la carga por defecto ..... this.Enabled = true; //............................................................. } } #endregion #region Inicio de Pantalla private void P_EmpleadoContrato_Shown(object sender, EventArgs e) { try { if (g_bol_ConstructorPantalla_Terminado_Correctamente) { // Si el Tipo de Apertura de Pantalla es Añadir(g_int_tipoAperturaPantalla = 0), se desactivan los botones correspondientes // Añadir if (this.P_Base_TipoAperturaPantalla == 0) { P_Base_TituloPantalla = P_Base_TituloPantalla + " - Añadir"; ActivarBotones(false); //Se cambia el valor de la variable para no salte el evento de se modifico algo g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = false; g_obj_Controladora.CargaDias_CrearControles(); g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = true; } // Modificar else { ActivarBotones(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.Message, ex, nameof(P_EmpleadoContrato) + "/" + nameof(P_EmpleadoContrato_Shown)); Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA()); Salir_P_Base(); } } private void ActivarBotones(bool _bol_Activar) { if (ex_btn_P_EmpleadoContrato_Borrar.Enabled) { ex_btn_P_EmpleadoContrato_Borrar.Enabled = _bol_Activar; } } #endregion #region Botones Grabar, Borrar private void ex_btn_P_EmpleadoContrato_Grabar_Click(object sender, EventArgs e) { Grabar(); } private void Grabar() { if (//Añadir (P_Base_TipoAperturaPantalla == 0 && Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Anadir, true)) || //Modificar (P_Base_TipoAperturaPantalla != 0 && Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Modificar, true))) { g_obj_Controladora.GrabarDatos(); } } private void ex_btn_P_EmpleadoContrato_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 #region Teclas de acceso rapido protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { // Salir sin Seleccionar if (keyData == Keys.F10) { Salir_P_Base(); return true; } // Grabar else if (keyData == Keys.F2) { Grabar(); return true; } // Borrar else if (keyData == Keys.F5) { Borrar(); return true; } return base.ProcessCmdKey(ref msg, keyData); } #endregion #region Controlar si se modifico algo private void ex_txt_Evento_TextChanged(object sender, EventArgs e) { Controlar_Modificaciones(); } public void Controlar_Modificaciones() { if (Enabled && g_obj_Controladora != null && g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial) { P_Base_SeModificoDatosPantalla = true; } } #endregion } }