296 lines
12 KiB
C#
296 lines
12 KiB
C#
using Exferia_Aplicacion.General;
|
|
using Exferia_Aplicacion.Visualizacion;
|
|
using Exferia_Controles;
|
|
using Exferia_EntityFramework;
|
|
using Exferia_General;
|
|
using Exferia_Previsiones._3_Vistas.Controladoras;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using static Exferia_Aplicacion.General.Enumerados;
|
|
|
|
namespace Exferia_Previsiones._3_Vistas
|
|
{
|
|
public partial class P_PrevisionesCalendario : Exferia_Formularios.P_Base_Mantenimientos
|
|
{
|
|
#region Variables Generales
|
|
private P_PrevisionesCalendario_Controladora g_obj_Controladora;
|
|
|
|
public bool g_bol_ConstructorPantalla_Terminado_Correctamente = true;
|
|
public PRV_OpcionesDetalle g_mdl_PRV_Opciones_Detalle = null;
|
|
|
|
internal List<INTERNO_Permisos_Modelo> g_lst_INTERNO_Permisos_Modelo = null;
|
|
#endregion
|
|
|
|
#region Objetos en Pantalla
|
|
//Exferia_DataGriView
|
|
internal Exferia_DataGridView Exferia_DataGridView_Bancos { get { return ex_dgv_P_PrevisionCalendario_Bancos; } }
|
|
|
|
//Exferia_TabControl
|
|
internal Exferia_TabControl Exferia_TabControl_Bancos { get { return ex_tbc_P_PrevisionCalendario_Bancos; } }
|
|
|
|
//Exferia_F3_Soloselccion
|
|
internal Exferia_F3_SoloSeleccion Exferia_F3_SoloSeleccion_Ejercicio { get{ return ex_usc_F3_P_PrevisionCalendario_Ejercicio; } }
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public P_PrevisionesCalendario(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_PrevisionesCalendario_Controladora(this);
|
|
|
|
//Datos de Opciones detalle
|
|
g_mdl_PRV_Opciones_Detalle = _mdl_PRV_OpcionesDetalle;
|
|
|
|
//Buscar los Permisos
|
|
g_lst_INTERNO_Permisos_Modelo = Datos_Generales.Permisos_Buscar(g_mdl_PRV_Opciones_Detalle.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_Opciones_Detalle.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_Opciones_Detalle.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_PrevisionesCalendario) + "/" + nameof(P_PrevisionesCalendario));
|
|
}
|
|
}
|
|
//..................................................................................................................................
|
|
|
|
//Bloquear pantalla hasta que termine la carga por defecto.....
|
|
Enabled = false;
|
|
//.............................................................
|
|
|
|
//F3###########################################################
|
|
//EJERCICIO
|
|
ex_usc_F3_P_PrevisionCalendario_Ejercicio.Exferia_F3_SoloSeleccion_PRINCIPAL_Opcion_BuscarDatos = Variables.G_STR_OPCION_GEN_EJERCICIOACTIVO;
|
|
ex_usc_F3_P_PrevisionCalendario_Ejercicio.Exferia_F3_SoloSeleccion_PantallaContenedora = this;
|
|
ex_usc_F3_P_PrevisionCalendario_Ejercicio.Exferia_F3_SoloSeleccion_PRINCIPAL_Obligatorio = true;
|
|
}
|
|
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_PrevisionesCalendario) + "/" + nameof(P_PrevisionesCalendario));
|
|
}
|
|
finally
|
|
{
|
|
//Bloquear pantalla hasta que termine la carga por defecto .............
|
|
Enabled = true;
|
|
//......................................................................
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Inicio de pantalla
|
|
private void P_PrevisionCalendario_Shown(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
g_obj_Controladora.Datos_PorDefecto();
|
|
|
|
if(g_bol_ConstructorPantalla_Terminado_Correctamente)
|
|
{
|
|
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_PrevisionesCalendario) + "/" + nameof(P_PrevisionesCalendario));
|
|
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
|
|
Salir_P_Base();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Metodos del DataGriView
|
|
private void ex_dgv_P_PrevisionCalendario_Bancos_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if(e.ColumnIndex == 1)
|
|
{
|
|
if(ex_dgv_P_PrevisionCalendario_Bancos[e.ColumnIndex,e.RowIndex].Value.ToString() == "0")
|
|
{
|
|
ex_dgv_P_PrevisionCalendario_Bancos[e.ColumnIndex, e.RowIndex].Value = 1;
|
|
}
|
|
else
|
|
{
|
|
ex_dgv_P_PrevisionCalendario_Bancos[e.ColumnIndex, e.RowIndex].Value = 0;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log(ex.Message, ex, nameof(P_PrevisionesCalendario) + "/" + nameof(ex_dgv_P_PrevisionCalendario_Bancos_CellContentClick));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Botones Generar, ExportarExcel, Eventos
|
|
private void ex_btn_P_PrevisionCalendario_Generar_Click(object sender, EventArgs e)
|
|
{
|
|
Generar();
|
|
}
|
|
private void Generar()
|
|
{
|
|
g_obj_Controladora.RecargarDatos_Bancos();
|
|
}
|
|
|
|
private void ex_btn_P_PrevisionCalendario_ExportarExcel_Click(object sender, EventArgs e)
|
|
{
|
|
ExportarExcel();
|
|
}
|
|
private void ExportarExcel()
|
|
{
|
|
if (Datos_Generales.Permisos_Comprobar(g_mdl_PRV_Opciones_Detalle.opcion, g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.ExportarAExcel, true))
|
|
{
|
|
g_obj_Controladora.Generar_ListadoEnExcel();
|
|
}
|
|
}
|
|
|
|
//Funcion para habilitar el ScrollBar en el DatagridView del TabPage
|
|
private void ex_tbc_P_PrevisionCalendario_Bancos_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Exferia_TabControl obj_Exferia_TabControl = (Exferia_TabControl)sender;
|
|
|
|
//Compruebo si se ha seleccionado un TabPage
|
|
if (obj_Exferia_TabControl.SelectedTab != null)
|
|
{
|
|
if(obj_Exferia_TabControl.SelectedTab.Controls != null && obj_Exferia_TabControl.SelectedTab.Controls.Count > 0)
|
|
{
|
|
obj_Exferia_TabControl.SelectedTab.AutoScroll = true;
|
|
obj_Exferia_TabControl.SelectedTab.HorizontalScroll.Enabled = true;
|
|
obj_Exferia_TabControl.SelectedTab.HorizontalScroll.Visible = true;
|
|
|
|
obj_Exferia_TabControl.SelectedTab.VerticalScroll.Enabled = true;
|
|
obj_Exferia_TabControl.SelectedTab.VerticalScroll.Visible = true;
|
|
|
|
//Recorro los controles hasta encontrar el DataGridView para añadirle el ScroolBar
|
|
/* foreach (Control obj_Control in obj_Exferia_TabControl.SelectedTab.Controls)
|
|
{
|
|
if(obj_Control.GetType() == typeof(Exferia_DataGridView))
|
|
{
|
|
((Exferia_DataGridView)obj_Control).ScrollBars = ScrollBars.Vertical | ScrollBars.Horizontal;
|
|
((Exferia_DataGridView)obj_Control).CurrentCell = null;
|
|
}
|
|
}*/
|
|
}
|
|
}
|
|
}
|
|
|
|
//Funcion para el formateo del DataGridView
|
|
public void Calendario_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|
{
|
|
g_obj_Controladora.FormatearColor_Calendario(e);
|
|
}
|
|
#endregion
|
|
|
|
#region Procedimientos F3
|
|
private void ex_usc_F3_P_PrevisionCalendario_Ejercicio_Exferia_F3_SoloSeleccion_Evento_TerminoBusqueda(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if(ex_usc_F3_P_PrevisionCalendario_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_PrevisionCalendario_Ejercicio.Exferia_F3_SoloSeleccion_Id)).FirstOrDefault();
|
|
|
|
//Limpiamos los datagridview
|
|
ex_tbc_P_PrevisionCalendario_Bancos.Controls.Clear();
|
|
g_obj_Controladora.g_lst_PRE_Previsiones.Clear();
|
|
|
|
g_obj_Controladora.RecargarDatos_Bancos();
|
|
}
|
|
//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_PrevisionesCalendario) + "/" + nameof(ex_usc_F3_P_PrevisionCalendario_Ejercicio_Exferia_F3_SoloSeleccion_Evento_TerminoBusqueda));
|
|
}
|
|
}
|
|
#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
|
|
}
|
|
}
|