590 lines
30 KiB
C#
590 lines
30 KiB
C#
using Exferia_Aplicacion.General;
|
|
using Exferia_Aplicacion.Visualizacion;
|
|
using Exferia_Controles;
|
|
using Exferia_EntityFramework;
|
|
using Exferia_Formularios;
|
|
using Exferia_General;
|
|
using Exferia_KairosPRO._1_Modelos;
|
|
using Exferia_KairosPRO._4_Vistas.Controladoras;
|
|
using Exferia_KairosPRO._4_Vistas.ListadosSeleccion;
|
|
using Exferia_KairosPRO.General;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using static Exferia_Aplicacion.General.Enumerados;
|
|
|
|
namespace Exferia_KairosPRO._4_Vistas
|
|
{
|
|
public partial class P_Calendario : Exferia_Formularios.P_Base_Mantenimientos
|
|
{
|
|
#region Variables General
|
|
private P_Calendario_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;
|
|
|
|
//Timer Buscar
|
|
private System.Windows.Forms.Timer g_timer_Buscar_Empleados = new System.Windows.Forms.Timer();
|
|
#endregion
|
|
|
|
#region Obtejos en pantalla
|
|
internal Exferia_CheckBox Exferia_CheckBox_PalabraCompleta { get { return ex_chk_P_Calendario_PalabraCompleta; } }
|
|
internal Exferia_CheckBox Exferia_CheckBox_MayusculasMinusculas { get { return ex_chk_P_Calendario_MayusculasMinusculas; } }
|
|
|
|
//Exferia_DataGridView
|
|
internal Exferia_DataGridView Exferia_DataGridView_Empleados { get { return ex_dgv_P_Calendario_Empleados; } }
|
|
internal Exferia_DataGridView Exferia_DataGridView_Calendario { get { return ex_dgv_P_Calendario_Calendario; } }
|
|
|
|
//Exferia_F3_SoloSeleccion
|
|
internal Exferia_F3_SoloSeleccion Exferia_F3_SoloSeleccion_Ejercicio { get { return ex_usc_F3_P_Calendario_Ejercicio; } }
|
|
|
|
//Exferia_TextBox
|
|
internal Exferia_TextBox Exferia_TextBox_Buscar { get { return ex_txt_P_Calendario_Buscar; } }
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public P_Calendario(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle)
|
|
{
|
|
Constructor(_mdl_INTERNO_ValoresGenerales_Modelo, _dtt_FechaTrabajo, _mdl_PRV_OpcionesDetalle, -1);
|
|
}
|
|
|
|
public P_Calendario(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle, long _lng_idEmpleado)
|
|
{
|
|
Constructor(_mdl_INTERNO_ValoresGenerales_Modelo, _dtt_FechaTrabajo, _mdl_PRV_OpcionesDetalle, _lng_idEmpleado);
|
|
}
|
|
private void Constructor(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle, long _lng_idEmpleado)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Repintar.Empezar(this);
|
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
|
|
|
//Comprobamos que el codigo cliente exista y este bien
|
|
if (Variables.G_LNG_IDCLIENTE_LICENCIAVALIDADO.Equals(-1))
|
|
{
|
|
//Tendriamos que avisar y no dejar abrir la pantalla
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_LICENCIA_VALIDACIONES_LICENCIANOESTAACTIVA);
|
|
Salir_P_Base();
|
|
}
|
|
|
|
//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_Calendario_Controladora(this);
|
|
|
|
g_obj_Controladora.g_lng_idEmpleado_Seleccionado = _lng_idEmpleado;
|
|
|
|
//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;
|
|
|
|
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_Calendario) + "/" + nameof(Constructor));
|
|
}
|
|
}
|
|
//..................................................................................................................................
|
|
|
|
//Bloquear pantalla hasta que termine la carga por defecto.....
|
|
Enabled = false;
|
|
//.............................................................
|
|
|
|
//EJERCICIO
|
|
ex_usc_F3_P_Calendario_Ejercicio.Exferia_F3_SoloSeleccion_PRINCIPAL_Opcion_BuscarDatos = Variables.G_STR_OPCION_GEN_EJERCICIOACTIVO;
|
|
ex_usc_F3_P_Calendario_Ejercicio.Exferia_F3_SoloSeleccion_PantallaContenedora = this;
|
|
ex_usc_F3_P_Calendario_Ejercicio.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_Calendario) + "/" + nameof(Constructor));
|
|
}
|
|
finally
|
|
{
|
|
//Bloquear pantalla hasta que termine la carga por defecto .....
|
|
Enabled = true;
|
|
//.............................................................
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Inicio de pantalla
|
|
private void P_Calendario_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//Configurar el Timer para Busqueda en el Listado #####################################################
|
|
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_Calendario_Buscar.Text);
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//No se muestra mensaje pero se guarda en el log
|
|
Control_Errores.Errores_Log(ex.Message, ex, nameof(P_Calendario) + "/" + nameof(P_Calendario_Load));
|
|
|
|
g_bol_ConstructorPantalla_Terminado_Correctamente = false;
|
|
}
|
|
}
|
|
private void P_Calendario_Shown(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
g_obj_Controladora.Datos_PorDefecto();
|
|
|
|
if (g_bol_ConstructorPantalla_Terminado_Correctamente)
|
|
{
|
|
g_obj_Controladora.CargaInicial();
|
|
|
|
}
|
|
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_Calendario) + "/" + nameof(P_Calendario_Shown));
|
|
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
|
|
Salir_P_Base();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Botones Añadir o Ver los DiasFestivos, Ausencias y Presencias programadas,Grabar
|
|
private void ex_btn_P_Calendario_DiasFestivos_VER_Click(object sender, EventArgs e)
|
|
{
|
|
AbrirDetalle_Festivos();
|
|
}
|
|
private void AbrirDetalle_Festivos()
|
|
{
|
|
try
|
|
{
|
|
if (ex_dgv_P_Calendario_Calendario.CurrentCell.Value != null)
|
|
{
|
|
//Obtenemos las opciones
|
|
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_KRS_CALENDARIO_DETALLE);
|
|
|
|
List<DataGridViewCell> lst_DataGridViewCell_CeldasSeleccionadas = ex_dgv_P_Calendario_Calendario.SelectedCells
|
|
.Cast<DataGridViewCell>()
|
|
.Where(r => r.ColumnIndex > 0 && r.Value != null)
|
|
.OrderBy(m => m.ColumnIndex).OrderBy(m => m.RowIndex)
|
|
.ToList();
|
|
|
|
List<List<DateTime>> lst_Rangos_Fechas = null;
|
|
if (lst_DataGridViewCell_CeldasSeleccionadas != null && lst_DataGridViewCell_CeldasSeleccionadas.Count > 0)
|
|
{
|
|
//Obtenemos un listado con todos los rtangos de celdas seleccionadas transformadaos a Datetime
|
|
lst_Rangos_Fechas = g_obj_Controladora.Obtener_RangoFechas_Por_Celdas_Seleccionadas(lst_DataGridViewCell_CeldasSeleccionadas);
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
return;
|
|
}
|
|
|
|
INTERNO_AUX_Calendario_Modelo mdl_INTERNO_AUX_Calendario_Modelo = null;
|
|
List<INTERNO_AUX_Calendario_Modelo> lst_AUX_Calendario_Modelo = new List<INTERNO_AUX_Calendario_Modelo>();
|
|
foreach (DataGridViewCell dgv_Cell in lst_DataGridViewCell_CeldasSeleccionadas)
|
|
{
|
|
mdl_INTERNO_AUX_Calendario_Modelo = (INTERNO_AUX_Calendario_Modelo)dgv_Cell.Tag;
|
|
|
|
if (mdl_INTERNO_AUX_Calendario_Modelo != null)
|
|
{
|
|
if (mdl_INTERNO_AUX_Calendario_Modelo.DiasFestivos != null)
|
|
{
|
|
if (lst_Rangos_Fechas.Count == 1)
|
|
{
|
|
TimeSpan tms = mdl_INTERNO_AUX_Calendario_Modelo.DiasFestivos.fechaHasta - mdl_INTERNO_AUX_Calendario_Modelo.DiasFestivos.fechaDesde;
|
|
int int_dias = tms.Days;
|
|
|
|
//Si la cantidad de celdas seleccionadas corresponde a los dias del registro seleccionadao, abrimos el borrar el registro completo
|
|
if (int_dias.Equals(lst_DataGridViewCell_CeldasSeleccionadas.Count - 1))
|
|
{
|
|
AbrirPantalla(1, mdl_INTERNO_AUX_Calendario_Modelo.DiasFestivos.id, mdl_INTERNO_OpcionesDetalle_Modelo, null, null, null);
|
|
return;
|
|
}
|
|
}
|
|
lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo);
|
|
}
|
|
else
|
|
{ lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo); }
|
|
}
|
|
else
|
|
{ lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo); }
|
|
}
|
|
|
|
foreach (INTERNO_AUX_Calendario_Modelo mdl_INTERNO_AUX_Calendario in lst_AUX_Calendario_Modelo)
|
|
{
|
|
//Si encuentra algun festivo en las celdas seleccionadas usamos el grabar por rangos
|
|
if (mdl_INTERNO_AUX_Calendario != null && mdl_INTERNO_AUX_Calendario.DiasFestivos != null)
|
|
{
|
|
g_obj_Controladora.g_bol_Modificar_SIMPLE = false;
|
|
//Abrimos el detalle cargando el registro de las celdas seleccionadas
|
|
AbrirPantalla(1, mdl_INTERNO_AUX_Calendario.DiasFestivos.id, mdl_INTERNO_OpcionesDetalle_Modelo, null, lst_Rangos_Fechas, lst_AUX_Calendario_Modelo);
|
|
return;
|
|
}
|
|
}
|
|
//Grabamos normal el registro
|
|
AbrirPantalla(1, -1, mdl_INTERNO_OpcionesDetalle_Modelo, null, lst_Rangos_Fechas, null);
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Calendario) + "/" + nameof(AbrirDetalle_Festivos));
|
|
}
|
|
}
|
|
|
|
private void ex_btn_P_Calendario_PresenciasProgramadas_VER_Click(object sender, EventArgs e)
|
|
{
|
|
AbrirDetalle_PresenciasProgramadas();
|
|
}
|
|
private void AbrirDetalle_PresenciasProgramadas()
|
|
{
|
|
try
|
|
{
|
|
if (ex_dgv_P_Calendario_Calendario.CurrentCell.Value != null)
|
|
{
|
|
//Obtenemos las opciones
|
|
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_KRS_CALENDARIO_DETALLE);
|
|
|
|
//Rellenamos el modelo con los datos del datagridview
|
|
INTERNO_AUX_Empleado_Modelo mdl_INTERNO_AUX_Empleado_Modelo = new INTERNO_AUX_Empleado_Modelo();
|
|
mdl_INTERNO_AUX_Empleado_Modelo.id = ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[0].Value.ToString().Trim().Length == 0 ? -1 : long.Parse(ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[0].Value.ToString());
|
|
mdl_INTERNO_AUX_Empleado_Modelo.NombreEmpleado = ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[1].Value.ToString();
|
|
|
|
List<DataGridViewCell> lst_DataGridViewCell_CeldasSeleccionadas = ex_dgv_P_Calendario_Calendario.SelectedCells
|
|
.Cast<DataGridViewCell>()
|
|
.Where(r => r.ColumnIndex > 0 && r.Value != null)
|
|
.OrderBy(m => m.ColumnIndex).OrderBy(m => m.RowIndex)
|
|
.ToList();
|
|
|
|
List<List<DateTime>> lst_Rangos_Fechas = null;
|
|
if (lst_DataGridViewCell_CeldasSeleccionadas != null && lst_DataGridViewCell_CeldasSeleccionadas.Count > 0)
|
|
{
|
|
//Obtenemos un listado con todos los rtangos de celdas seleccionadas transformadaos a Datetime
|
|
lst_Rangos_Fechas = g_obj_Controladora.Obtener_RangoFechas_Por_Celdas_Seleccionadas(lst_DataGridViewCell_CeldasSeleccionadas);
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
return;
|
|
}
|
|
|
|
INTERNO_AUX_Calendario_Modelo mdl_INTERNO_AUX_Calendario_Modelo = null;
|
|
List<INTERNO_AUX_Calendario_Modelo> lst_AUX_Calendario_Modelo = new List<INTERNO_AUX_Calendario_Modelo>();
|
|
foreach (DataGridViewCell dgv_Cell in lst_DataGridViewCell_CeldasSeleccionadas)
|
|
{
|
|
mdl_INTERNO_AUX_Calendario_Modelo = (INTERNO_AUX_Calendario_Modelo)dgv_Cell.Tag;
|
|
|
|
if (mdl_INTERNO_AUX_Calendario_Modelo != null)
|
|
{
|
|
if (mdl_INTERNO_AUX_Calendario_Modelo.PresenciasProgramadas != null)
|
|
{
|
|
if (lst_Rangos_Fechas.Count == 1)
|
|
{
|
|
TimeSpan tms = mdl_INTERNO_AUX_Calendario_Modelo.PresenciasProgramadas.fechaHasta - mdl_INTERNO_AUX_Calendario_Modelo.PresenciasProgramadas.fechaDesde;
|
|
int int_dias = tms.Days;
|
|
|
|
//Si la cantidad de celdas seleccionadas corresponde a los dias del registro seleccionadao, abrimos el borrar el registro completo
|
|
if (int_dias.Equals(lst_DataGridViewCell_CeldasSeleccionadas.Count - 1))
|
|
{
|
|
AbrirPantalla(2, mdl_INTERNO_AUX_Calendario_Modelo.PresenciasProgramadas.id, mdl_INTERNO_OpcionesDetalle_Modelo, mdl_INTERNO_AUX_Empleado_Modelo, null, null);
|
|
return;
|
|
}
|
|
}
|
|
lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo);
|
|
}
|
|
else
|
|
{ lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo); }
|
|
}
|
|
else
|
|
{ lst_AUX_Calendario_Modelo.Add(mdl_INTERNO_AUX_Calendario_Modelo); }
|
|
}
|
|
|
|
foreach (INTERNO_AUX_Calendario_Modelo mdl_INTERNO_AUX_Calendario in lst_AUX_Calendario_Modelo)
|
|
{
|
|
//Si encuentra algun festivo en las celdas seleccionadas usamos el grabar por rangos
|
|
if (mdl_INTERNO_AUX_Calendario != null && mdl_INTERNO_AUX_Calendario.PresenciasProgramadas != null)
|
|
{
|
|
g_obj_Controladora.g_bol_Modificar_SIMPLE = false;
|
|
//Abrimos el detalle cargando el registro de las celdas seleccionadas
|
|
AbrirPantalla(2, mdl_INTERNO_AUX_Calendario.PresenciasProgramadas.id, mdl_INTERNO_OpcionesDetalle_Modelo, mdl_INTERNO_AUX_Empleado_Modelo, lst_Rangos_Fechas, lst_AUX_Calendario_Modelo);
|
|
return;
|
|
}
|
|
}
|
|
//Grabamos normal el registro
|
|
AbrirPantalla(2, -1, mdl_INTERNO_OpcionesDetalle_Modelo, mdl_INTERNO_AUX_Empleado_Modelo, lst_Rangos_Fechas, null);
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Calendario) + nameof(AbrirDetalle_PresenciasProgramadas));
|
|
}
|
|
}
|
|
|
|
private void ex_btn_P_Calendario_AusenciasProgramadas_VER_Click(object sender, EventArgs e)
|
|
{
|
|
AbrirDetalle_AusenciasProgramadas();
|
|
}
|
|
private void AbrirDetalle_AusenciasProgramadas()
|
|
{
|
|
try
|
|
{
|
|
if (ex_dgv_P_Calendario_Calendario.CurrentCell.Value != null)
|
|
{
|
|
//Obtenemos las opciones
|
|
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_KRS_CALENDARIO_DETALLE);
|
|
|
|
//Rellenamos el modelo con los datos del datagridview
|
|
INTERNO_AUX_Empleado_Modelo mdl_INTERNO_AUX_Empleado_Modelo = new INTERNO_AUX_Empleado_Modelo();
|
|
mdl_INTERNO_AUX_Empleado_Modelo.id = ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[0].Value.ToString().Trim().Length == 0 ? -1 : long.Parse(ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[0].Value.ToString());
|
|
mdl_INTERNO_AUX_Empleado_Modelo.NombreEmpleado = ex_dgv_P_Calendario_Empleados.CurrentRow.Cells[1].Value.ToString();
|
|
|
|
//Celdas seleccionadas en el Calendario
|
|
List<DataGridViewCell> lst_DataGridViewCell_CeldasSeleccionadas = ex_dgv_P_Calendario_Calendario.SelectedCells
|
|
.Cast<DataGridViewCell>()
|
|
.Where(r => r.ColumnIndex > 0 && r.Value != null)
|
|
.OrderBy(m => m.ColumnIndex).OrderBy(m => m.RowIndex)
|
|
.ToList();
|
|
|
|
List<DateTime> lst_Fechas_Seleccionadas = null;
|
|
if (lst_DataGridViewCell_CeldasSeleccionadas != null && lst_DataGridViewCell_CeldasSeleccionadas.Count > 0)
|
|
{
|
|
//Obtenemos un listado con todos los rangos de celdas seleccionadas transformadaos a Datetime
|
|
lst_Fechas_Seleccionadas = g_obj_Controladora.ObtenerFechaSeleccionadas();
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
return;
|
|
}
|
|
|
|
List<INTERNO_AUX_Calendario_Modelo> lst_AUX_Calendario_Modelo = new List<INTERNO_AUX_Calendario_Modelo>();
|
|
|
|
//Grabamos normal el registro
|
|
P_Calendario_Detalle_AusenciaProgramada frm_P_Calendario_Detalle_AusenciaProgramada = new P_Calendario_Detalle_AusenciaProgramada(g_obj_Controladora,P_Base_ValoresGenerales, P_Base_FechaTrabajo, mdl_INTERNO_OpcionesDetalle_Modelo, mdl_INTERNO_AUX_Empleado_Modelo, g_obj_Controladora.g_dct_ValoresTag_Calendario, lst_Fechas_Seleccionadas,g_obj_Controladora.g_lst_KRS_DiasFestivos);
|
|
|
|
//Se llamo desde una pantalla
|
|
frm_P_Calendario_Detalle_AusenciaProgramada.P_Base_TipoAperturaPantalla = 1;
|
|
frm_P_Calendario_Detalle_AusenciaProgramada.P_Base_PantallaPadre_IdentificadorTAG = this.Tag.ToString();
|
|
frm_P_Calendario_Detalle_AusenciaProgramada.P_Base_PantallaOrigen = this;
|
|
frm_P_Calendario_Detalle_AusenciaProgramada.P_Base_TituloPantalla_CaminoHormigas = mdl_INTERNO_OpcionesDetalle_Modelo.descripcion_TituloMantenimiento.ToUpper() + " -> Alta";
|
|
|
|
Funciones_PanelPrincipal.Cargar_PantallaEmpotrada(frm_P_Calendario_Detalle_AusenciaProgramada, mdl_INTERNO_OpcionesDetalle_Modelo.opcion);
|
|
}
|
|
else
|
|
{
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_CALENDARIOLABORAL_VALIDACIONES_CELDANOVALIDA());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Calendario) + nameof(AbrirDetalle_AusenciasProgramadas));
|
|
}
|
|
}
|
|
|
|
private void AbrirPantalla(int _intTipoApertura, long _lng_idObjeto_A_Abrir, INTERNO_OpcionesDetalle_Modelo _mdl_INTERNO_OpcionesDetalle_Modelo, INTERNO_AUX_Empleado_Modelo _mdl_INTERNO_AUX_Empleado_Modelo, List<List<DateTime>> _lst_Rangos_Fechas, List<INTERNO_AUX_Calendario_Modelo> _lst_INTERNO_AUX_Calendario_Modelo)
|
|
{
|
|
try
|
|
{
|
|
P_Calendario_Detalle frm_P_Calendario_Detalle = new P_Calendario_Detalle(_intTipoApertura, g_obj_Controladora, _lng_idObjeto_A_Abrir, P_Base_ValoresGenerales, P_Base_FechaTrabajo, _mdl_INTERNO_OpcionesDetalle_Modelo, _mdl_INTERNO_AUX_Empleado_Modelo, _lst_Rangos_Fechas, _lst_INTERNO_AUX_Calendario_Modelo);
|
|
|
|
//Se llamo desde una pantalla
|
|
frm_P_Calendario_Detalle.P_Base_TipoAperturaPantalla = _lng_idObjeto_A_Abrir.Equals(-1) ? 0 : 1;
|
|
frm_P_Calendario_Detalle.P_Base_PantallaPadre_IdentificadorTAG = this.Tag.ToString();
|
|
frm_P_Calendario_Detalle.P_Base_PantallaOrigen = this;
|
|
frm_P_Calendario_Detalle.P_Base_TituloPantalla_CaminoHormigas = _mdl_INTERNO_OpcionesDetalle_Modelo.descripcion_TituloMantenimiento.ToUpper() + " -> Alta";
|
|
|
|
Funciones_PanelPrincipal.Cargar_PantallaEmpotrada(frm_P_Calendario_Detalle, _mdl_INTERNO_OpcionesDetalle_Modelo.opcion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Calendario) + nameof(AbrirPantalla));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Empleado
|
|
private void ex_txt_P_Calendario_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_Calendario_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_Calendario_MayusculasMinusculas_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora != null)
|
|
{
|
|
g_timer_Buscar_Empleados.Stop();
|
|
g_timer_Buscar_Empleados.Start();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Procedimientos F3
|
|
private void ex_usc_F3_P_Perfil_Ejercicio_Exferia_F3_SoloSeleccion_Evento_TerminoBusqueda(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//Empleado seleccionado
|
|
g_obj_Controladora.g_lng_idEmpleado_Seleccionado = -1;
|
|
if (ex_dgv_P_Calendario_Empleados.RowCount > 0 &&
|
|
ex_dgv_P_Calendario_Empleados.SelectedRows != null &&
|
|
ex_dgv_P_Calendario_Empleados.SelectedRows.Count > 0)
|
|
{
|
|
g_obj_Controladora.g_lng_idEmpleado_Seleccionado = long.Parse(ex_dgv_P_Calendario_Empleados.SelectedRows[0].Cells[0].Value.ToString().Trim());
|
|
}
|
|
|
|
if (ex_usc_F3_P_Calendario_Ejercicio.Exferia_F3_SoloSeleccion_Id > -1)
|
|
{
|
|
g_obj_Controladora.g_mdl_GEN_EjerciciosActivos_Empresa = P_Base_ValoresGenerales.Ejercicios_Listado.Where(m => m.id.Equals(ex_usc_F3_P_Calendario_Ejercicio.Exferia_F3_SoloSeleccion_Id)).FirstOrDefault();
|
|
|
|
//Limpiamos los datagridview
|
|
ex_dgv_P_Calendario_Calendario.Rows.Clear();
|
|
ex_dgv_P_Calendario_Empleados.Rows.Clear();
|
|
|
|
Funciones_KairosPRO.FormarCalendario(ex_dgv_P_Calendario_Calendario, g_obj_Controladora.g_mdl_GEN_EjerciciosActivos_Empresa, P_Base_FechaTrabajo);
|
|
|
|
g_obj_Controladora.g_dct_ValoresTag_Calendario = new Dictionary<DateTime, INTERNO_AUX_Calendario_Modelo>();
|
|
g_obj_Controladora.CargaInicial();
|
|
}
|
|
|
|
//Se pone para que no pregunte al salir de la pantalla, si se cambia de ejercicio
|
|
P_Base_SeModificoDatosPantalla = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Perfil) + "/" + nameof(ex_usc_F3_P_Perfil_Ejercicio_Exferia_F3_SoloSeleccion_Evento_TerminoBusqueda));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Eventos del Datagridview
|
|
private void ex_dgv_P_Calendario_Calendario_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
{
|
|
g_obj_Controladora.FormatearColor_Calendario(e);
|
|
}
|
|
|
|
private void ex_dgv_P_Calendario_Empleados_SelectionChanged(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora!=null && g_obj_Controladora.g_bol_Cargando_Empleados == false)
|
|
{
|
|
Exferia_DataGridView ex_dgv = (Exferia_DataGridView)sender;
|
|
g_obj_Controladora.Cambiar_Empleado(long.Parse(ex_dgv.CurrentRow.Cells[0].Value.ToString().Trim()));
|
|
}
|
|
}
|
|
#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;
|
|
}
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
}
|
|
#endregion
|
|
|
|
#region Controlar si se modifica algo
|
|
private void Controlar_Modificaciones_TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
Controlar_Modificaciones();
|
|
}
|
|
|
|
private void Controlar_Modificaciones_ComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Controlar_Modificaciones();
|
|
}
|
|
|
|
private void Controlar_Modificaciones()
|
|
{
|
|
if (Enabled && g_obj_Controladora != null && g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial)
|
|
{
|
|
P_Base_SeModificoDatosPantalla = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|