using Exferia_Aplicacion.General; using Exferia_Aplicacion.Visualizacion; using Exferia_Controles; using Exferia_EntityFramework; using Exferia_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; using System.Linq; using Exferia_KairosPRO._4_Vistas.Controladoras; using Exferia_Formularios; namespace Exferia_KairosPRO._4_Vistas { public partial class P_FichajesAutomaticos : Exferia_Formularios.P_Base_Mantenimientos { #region Variables General private P_FichajesAutomaticos_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; //Timer Buscar private System.Windows.Forms.Timer g_timer_Buscar_Empleados = new System.Windows.Forms.Timer(); #endregion #region Objetos en Pantalla // Exferia_CheckBox internal Exferia_CheckBox Exferia_CheckBox_Empleados_PalabraCompleta { get { return ex_chk_P_FichajesAutomaticos_Empleados_PalabraCompleta; } } internal Exferia_CheckBox Exferia_CheckBox_Empleados_MayusculasMinusculas { get { return ex_chk_P_FichajesAutomaticos_Empleados_MayusculasMinusculas; } } internal Exferia_CheckBox Exferia_CheckBox_Empleados_DadosDeBaja { get { return ex_chk_P_FichajesAutomaticos_Empleados_DadosDeBaja; } } //Exferia_DataGridView internal Exferia_DataGridView Exferia_DataGridView_Empleados { get { return ex_dgv_P_FichajesAutomaticos_Empleados; } } //Exferia_F3_SoloSeleccion internal Exferia_F3_SoloSeleccion Exferia_F3_SoloSeleccion_Empresa { get { return ex_usc_F3_P_FichajesAutomaticos_Empresa; } } //Exferia_FechaSeleccion internal Exferia_FechaSeleccion Exferia_FechaSeleccion_Fecha_Desde { get { return ex_usc_P_FichajesAutomaticos_Fecha_Desde; } } internal Exferia_FechaSeleccion Exferia_FechaSeleccion_Fecha_Hasta { get { return ex_usc_P_FichajesAutomaticos_Fecha_Hasta; } } //Exferia_Label internal Exferia_Label Exferia_Label_Hora_Desde { get { return ex_lbl_P_FichajesAutomaticos_Hora_Desde; } } internal Exferia_Label Exferia_Label_Hora_Hasta { get { return ex_lbl_P_FichajesAutomaticos_Hora_Hasta; } } // Exferia_TextBox_ConMascara internal Exferia_TextBox_ConMascara Exferia_TextBox_ConMascara_Hora_Desde { get { return ex_txt_P_FichajesAutomaticos_Hora_Desde; } } internal Exferia_TextBox_ConMascara Exferia_TextBox_ConMascara_Hora_Hasta { get { return ex_txt_P_FichajesAutomaticos_Hora_Hasta; } } #endregion #region Constructor public P_FichajesAutomaticos(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle) { InitializeComponent(); try { 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_FichajesAutomaticos_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); //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 = _mdl_PRV_OpcionesDetalle.descripcion_TituloMantenimiento; // 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_FichajesAutomaticos) + "/" + nameof(P_FichajesAutomaticos)); } } //.................................................................................................... //Empresa ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_PRINCIPAL_Opcion_BuscarDatos = Variables.G_STR_OPCION_GEN_EMPRESA; ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_PRINCIPAL_BUSCARTITULO = false; ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_PantallaContenedora = this; //Bloquear pantalla hasta que termine la carga por defecto ..... Enabled = false; //............................................................. } catch (Control_Errores) { g_bol_ConstructorPantalla_Terminado_Correctamente = false; } catch (Exception ex) { g_bol_ConstructorPantalla_Terminado_Correctamente = false; //No se muestra mensaje pero se guarda en el log Control_Errores.Errores_Log("", ex, nameof(P_FichajesAutomaticos) + "/" + nameof(P_FichajesAutomaticos)); } finally { //Bloquear pantalla hasta que termine la carga por defecto ..... Enabled = true; //............................................................. } } #endregion #region Inicio de pantalla private void P_FichajesAutomaticos_Load(object sender, EventArgs e) { try { #region EMPLEADOS g_timer_Buscar_Empleados.Interval = 1000; g_timer_Buscar_Empleados.Tick += delegate (object s, EventArgs ee) { g_timer_Buscar_Empleados.Stop(); g_obj_Controladora.Rellenar_DataGrid_Empleados(ex_txt_P_FichajesAutomaticos_Empleados_Buscar.Text, false); }; #endregion } catch (Exception ex) { //No se muestra mensaje pero se guarda en el log Control_Errores.Errores_Log("", ex, nameof(P_FichajesAutomaticos) + "/" + nameof(P_FichajesAutomaticos_Load)); g_bol_ConstructorPantalla_Terminado_Correctamente = false; } } private void P_FichajesAutomaticos_Shown(object sender, EventArgs e) { try { if (g_bol_ConstructorPantalla_Terminado_Correctamente) { //Mostrar Empresa actual ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_Id = P_Base_ValoresGenerales.lng_idEmpresa; ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_Codigo = P_Base_ValoresGenerales.str_Empresa_Codigo; ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_Descripcion = P_Base_ValoresGenerales.str_Empresa_Descripcion; ex_usc_F3_P_FichajesAutomaticos_Empresa.Exferia_F3_SoloSeleccion_FechaBorrado = null; //Rellenar Empleados g_obj_Controladora.Rellenar_DataGrid_Empleados(ex_txt_P_FichajesAutomaticos_Empleados_Buscar.Text, true); P_Base_SeModificoDatosPantalla = false; } else { 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_FichajesAutomaticos) + "/" + nameof(P_FichajesAutomaticos_Shown)); g_bol_ConstructorPantalla_Terminado_Correctamente = false; } } #endregion #region Empleados private void ex_chk_P_FichajesAutomaticos_Empleados_DadosDeBaja_CheckedChanged(object sender, EventArgs e) { if (g_obj_Controladora != null) { g_timer_Buscar_Empleados.Stop(); g_timer_Buscar_Empleados.Start(); } } private void ex_txt_P_FichajesAutomaticos_Empleados_Buscar_Exferia_TextBox_Evento_TextChanged(object sender, EventArgs e) { if (g_obj_Controladora != null) { g_timer_Buscar_Empleados.Stop(); g_timer_Buscar_Empleados.Start(); } } private void ex_chk_P_FichajesAutomaticos_Empleados_PalabraCompleta_CheckedChanged(object sender, EventArgs e) { if (g_obj_Controladora != null) { g_timer_Buscar_Empleados.Stop(); g_timer_Buscar_Empleados.Start(); } } private void ex_chk_P_FichajesAutomaticos_Empleados_MayusculasMinusculas_CheckedChanged(object sender, EventArgs e) { if (g_obj_Controladora != null) { g_timer_Buscar_Empleados.Stop(); g_timer_Buscar_Empleados.Start(); } } private void ex_btn_P_FichajesAutomaticos_Empleados_SeleccionarTodo_Click(object sender, EventArgs e) { if (ex_dgv_P_FichajesAutomaticos_Empleados.Rows.Count > 0) { foreach (DataGridViewRow dgvr_Fila in ex_dgv_P_FichajesAutomaticos_Empleados.Rows.Cast().ToList()) { //DataGridView dgvr_Fila.Cells[1].Value = 1; //Listado g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo[g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.IndexOf(g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.Where(m => m.Id == long.Parse(dgvr_Fila.Cells[0].Value.ToString())).FirstOrDefault())].Seleccionado = true; } } } private void ex_btn_P_FichajesAutomaticos_Empleados_DeseleccionarTodos_Click(object sender, EventArgs e) { if (ex_dgv_P_FichajesAutomaticos_Empleados.Rows.Count > 0) { foreach (DataGridViewRow dgvr_Fila in ex_dgv_P_FichajesAutomaticos_Empleados.Rows.Cast().ToList()) { //DataGridView dgvr_Fila.Cells[1].Value = 0; //Listado g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo[g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.IndexOf(g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.Where(m => m.Id == long.Parse(dgvr_Fila.Cells[0].Value.ToString())).FirstOrDefault())].Seleccionado = false; } } } private void ex_dgv_P_FichajesAutomaticos_Empleados_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 1) { bool bol_Seleccionado = true; if (ex_dgv_P_FichajesAutomaticos_Empleados[e.ColumnIndex, e.RowIndex].Value.ToString() == "0") { ex_dgv_P_FichajesAutomaticos_Empleados[e.ColumnIndex, e.RowIndex].Value = 1; bol_Seleccionado = true; } else { ex_dgv_P_FichajesAutomaticos_Empleados[e.ColumnIndex, e.RowIndex].Value = 0; bol_Seleccionado = false; } //Actualizar Listado if (g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo != null && g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.Count > 0) { long lng_idAsesor = long.Parse(ex_dgv_P_FichajesAutomaticos_Empleados[0, e.RowIndex].Value.ToString()); g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo[g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.IndexOf(g_obj_Controladora.g_lst_INTERNO_Seleccion_Listado_Modelo.Where(m => m.Id == lng_idAsesor).FirstOrDefault())].Seleccionado = bol_Seleccionado; } } } catch (Exception ex) { Control_Errores.Errores_Log("", ex, nameof(P_FichajesAutomaticos) + "/" + nameof(ex_dgv_P_FichajesAutomaticos_Empleados_CellContentClick)); } } #endregion #region Generar private void ex_btn_P_FichajesAutomaticos_Generar_Click(object sender, EventArgs e) { if (Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Modificar, true)) { g_obj_Controladora.GenerarFichajes(); } } #endregion } }