446 lines
18 KiB
C#
446 lines
18 KiB
C#
using Exferia_Aplicacion.General;
|
|
using Exferia_Aplicacion.Visualizacion;
|
|
using Exferia_Controles;
|
|
using Exferia_EntityFramework;
|
|
using Exferia_Formularios;
|
|
using Exferia_General._0_Modelos;
|
|
using Exferia_General._3_Vistas.Controladoras;
|
|
using Exferia_General._3_Vistas.ListadosSeleccion;
|
|
using Exferia_General.General;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static Exferia_Aplicacion.General.Enumerados;
|
|
|
|
namespace Exferia_General._3_Vistas
|
|
{
|
|
public partial class P_Firmas_Electronicas : Exferia_Formularios.P_Base_Mantenimientos
|
|
{
|
|
#region Variables General
|
|
private P_Firmas_Electronicas_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;
|
|
|
|
//Variables paginador......................................................................................
|
|
public Funciones_Paginador g_obj_Funciones_Paginador;
|
|
private System.Windows.Forms.Timer g_timer_Paginar = new System.Windows.Forms.Timer();
|
|
#endregion
|
|
|
|
#region Objetos en Pantalla
|
|
//Exferia_Label
|
|
internal Exferia_Label Exferia_Label_Codigo { get{ return ex_lbl_P_Firma_Electronica_Codigo; } }
|
|
internal Exferia_Label Exferia_Label_Descripcion { get{ return ex_lbl_P_Firma_Electronical_Descripcion; } }
|
|
internal Exferia_Label Exferia_Label_TextPerm { get{ return ex_lbl_P_Firma_electronica_label_text_perm; } }
|
|
|
|
|
|
//Exferia_TextBox
|
|
internal Exferia_TextBox Exferia_TextBox_Codigo { get{ return ex_txt_P_Firma_Electronica_Codigo; } }
|
|
internal Exferia_TextBox Exferia_TextBox_Descripcion { get{ return ex_txt_P_Firma_Electronica_Descripcion; } }
|
|
internal Exferia_FechaSeleccion Exferia_FechaSeleccion_Fecha { get { return ex_usc_Firma_Electronica_Fecha; } }
|
|
internal Exferia_TextBox Exferia_TextBox_TextPerm { get{ return ex_txt_P_Firma_Electronica_textPerm; } }
|
|
|
|
//Exferia_Paginador
|
|
internal Exferia_Paginador Exferia_Paginador_Firma_Electronica { get{ return ex_Paginador_Firma_Electronica; } }
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public P_Firmas_Electronicas(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;
|
|
|
|
//Datos de Opciones detalle
|
|
g_mdl_PRV_OpcionesDetalle = _mdl_PRV_OpcionesDetalle;
|
|
//Exferia_FechaSeleccion_Fecha.Exferia_FechaSeleccion_Descripcion='Fecha'
|
|
//Instanciar Controladora
|
|
g_obj_Controladora = new P_Firmas_Electronicas_Controladora(this);
|
|
g_obj_Controladora.IdEmpresaDef = P_Base_ValoresGenerales == null ? -1 : P_Base_ValoresGenerales.lng_idEmpresa;
|
|
//Buscar los Permisos
|
|
g_lst_INTERNO_Permisos_Modelo = Datos_Generales.Permisos_Buscar(g_mdl_PRV_OpcionesDetalle.opcion);
|
|
|
|
//Poner los Botones que no se pueden poner bloqueados o de solo lectura ............................................
|
|
ex_btn_P_Firma_Electronical_Borrar.Exferia_Button_Bloqueable = false;
|
|
ex_btn_P_Firma_Electronica_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 = _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_ConfiguracionEmail) + "/" + nameof(P_ConfiguracionEmail));
|
|
}
|
|
}
|
|
//..............................................................................................................
|
|
|
|
//Bloquear pantalla hasta que termine la carga por defecto ........
|
|
Enabled = false;
|
|
//.................................................................
|
|
|
|
g_obj_Funciones_Paginador = new Funciones_Paginador();
|
|
}
|
|
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_ConfiguracionEmail) + "/" + nameof(P_ConfiguracionEmail));
|
|
}
|
|
finally
|
|
{
|
|
//Bloquear pantalla hasta que termine la carga por defecto .....
|
|
Enabled = true;
|
|
//.............................................................
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Inicio de pantalla
|
|
private void P_Firma_Electronica_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//Configurar el Timer para Paginacion ###############################################################
|
|
g_timer_Paginar.Interval = 1000;
|
|
g_timer_Paginar.Tick += delegate (object s, EventArgs ee)
|
|
{
|
|
g_timer_Paginar.Stop();
|
|
try
|
|
{
|
|
g_obj_Controladora.RecargarDatos();
|
|
}
|
|
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_ConfiguracionEmail) + "/" + nameof(P_Firma_Electronica_Load));
|
|
|
|
g_bol_ConstructorPantalla_Terminado_Correctamente = false;
|
|
}
|
|
}
|
|
private void P_Firma_Electronica_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);
|
|
// g_obj_Controladora.CargarDatos();
|
|
|
|
//Se cambia el valor de la variable para que no salte el evento de se modifico algo
|
|
g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = false;
|
|
|
|
//Poner Texto predeterminado y foco
|
|
ex_txt_P_Firma_Electronica_Codigo.Exferia_TextBox_Foco();
|
|
|
|
g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = true;
|
|
}
|
|
//Modificar
|
|
else
|
|
{
|
|
ActivarBotones(true);
|
|
|
|
//Paginacion
|
|
if (P_Base_PantallaOrigen != null &&
|
|
P_Base_PantallaOrigen.P_Base_Objetos_Filtrados != null &&
|
|
P_Base_PantallaOrigen.P_Base_Objetos_Filtrados.Count > 0)
|
|
{
|
|
g_obj_Funciones_Paginador.Listado_ARecorrer(P_Base_PantallaOrigen.P_Base_Objetos_Filtrados.ToList(), 1);
|
|
|
|
// Asignando las paginas totales
|
|
Exferia_Paginador_Firma_Electronica.PaginasTotales = g_obj_Funciones_Paginador.Numero_Paginas_Totales;
|
|
}
|
|
else
|
|
{
|
|
Exferia_Paginador_Firma_Electronica.Visible = false;
|
|
}
|
|
|
|
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 para se guarda en el log
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Firmas_Electronicas) + "/" + nameof(P_Firma_Electronica_Shown));
|
|
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
|
|
Salir_P_Base();
|
|
}
|
|
}
|
|
private void ActivarBotones(bool _bol_Activar)
|
|
{
|
|
if(Exferia_Paginador_Firma_Electronica.Visible)
|
|
{
|
|
Exferia_Paginador_Firma_Electronica.Visible = _bol_Activar;
|
|
}
|
|
|
|
if (ex_btn_P_Firma_Electronical_Borrar.Enabled)
|
|
{
|
|
ex_btn_P_Firma_Electronical_Borrar.Enabled = _bol_Activar;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Botones Grabar,Borrar Email,SMTP,POP3
|
|
private void ex_btn_P_Firma_Electronica_BuscarCodigoSiguiente_Click(object sender, EventArgs e)
|
|
{
|
|
BuscarCodigoSiguiente();
|
|
}
|
|
private void BuscarCodigoSiguiente()
|
|
{
|
|
INTERNO_ValorDevuelto_Modelo mdl_ValorDevuelto_Modelo = g_obj_Controladora.Buscar_CodigoSiguiente();
|
|
if (mdl_ValorDevuelto_Modelo.TodoCorrecto == false && mdl_ValorDevuelto_Modelo.Mensaje.Trim().Length > 0)
|
|
{
|
|
Mensajes.MostrarMensaje(mdl_ValorDevuelto_Modelo.Mensaje);
|
|
}
|
|
else
|
|
{
|
|
P_Base_SeModificoDatosPantalla = true;
|
|
}
|
|
}
|
|
|
|
private void ex_btn_P_ConfiguracionEmail_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(true);
|
|
}
|
|
}
|
|
|
|
private void ex_btn_P_ConfiguracionEmail_EnviarEmailPrueba_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void ex_btn_P_ConfiguracionEmail_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(true);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Controlar si se modifico algo
|
|
private void Controlar_Modificaciones_TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
Controlar_Modificaciones();
|
|
}
|
|
private void Controlar_Modificaciones_CheckBox_CheckedChanged(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
|
|
|
|
#region Eventos del Paginador
|
|
protected void ctu_Paginacion_Primera_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) // Si no han habido contratiempos pasamos a la pagina indicada
|
|
{
|
|
if (g_obj_Funciones_Paginador.Primera())
|
|
{
|
|
// Asignando al control la pagina actual.
|
|
Exferia_Paginador_Firma_Electronica.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
// Refrescamos el listado a mostrar en el form.
|
|
P_Base_id = g_obj_Funciones_Paginador.Objeto_Devuelto.FirstOrDefault().ID;
|
|
|
|
g_timer_Paginar.Stop();
|
|
g_timer_Paginar.Start();
|
|
}
|
|
}
|
|
}
|
|
protected void ctu_Paginacion_Anterior_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) // Si no han habido contratiempos pasamos a la pagina indicada
|
|
{
|
|
if (g_obj_Funciones_Paginador.Anterior())
|
|
{
|
|
// Asignando al control la pagina actual.
|
|
Exferia_Paginador_Firma_Electronica.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
// Refrescamos el listado a mostrar en el form.
|
|
P_Base_id = g_obj_Funciones_Paginador.Objeto_Devuelto.FirstOrDefault().ID;
|
|
|
|
g_timer_Paginar.Stop();
|
|
g_timer_Paginar.Start();
|
|
}
|
|
}
|
|
}
|
|
protected void ctu_Paginacion_Siguiente_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) // Si no han habido contratiempos pasamos a la pagina indicada
|
|
{
|
|
if (g_obj_Funciones_Paginador.Siguiente())
|
|
{
|
|
// Asignando al control la pagina actual.
|
|
Exferia_Paginador_Firma_Electronica.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
// Refrescamos el listado a mostrar en el form.
|
|
P_Base_id = g_obj_Funciones_Paginador.Objeto_Devuelto.FirstOrDefault().ID;
|
|
|
|
g_timer_Paginar.Stop();
|
|
g_timer_Paginar.Start();
|
|
}
|
|
}
|
|
}
|
|
protected void ctu_Paginacion_Ultima_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) // Si no han habido contratiempos pasamos a la pagina indicada
|
|
{
|
|
|
|
if (g_obj_Funciones_Paginador.Ultima())
|
|
{
|
|
// Asignando al control la pagina actual.
|
|
Exferia_Paginador_Firma_Electronica.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
// Refrescamos el listado a mostrar en el form.
|
|
P_Base_id = g_obj_Funciones_Paginador.Objeto_Devuelto.FirstOrDefault().ID;
|
|
|
|
g_timer_Paginar.Stop();
|
|
g_timer_Paginar.Start();
|
|
}
|
|
}
|
|
}
|
|
protected void txt_PaginaActual_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
// Si pulsamos Enter.
|
|
if (e.KeyChar.Equals('\r'))
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) // Si no han habido contratiempos pasamos a la pagina indicada
|
|
{
|
|
// Asignamos a la paginacion el valor del textbox
|
|
g_obj_Funciones_Paginador.SetPaginaActual(Exferia_Paginador_Firma_Electronica.txt_ValorPaginaActual - 1);
|
|
|
|
// Asignando al control la pagina actual.
|
|
Exferia_Paginador_Firma_Electronica.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
// Refrescamos el listado a mostrar en el form.
|
|
P_Base_id = g_obj_Funciones_Paginador.Objeto_Devuelto.FirstOrDefault().ID;
|
|
|
|
g_timer_Paginar.Stop();
|
|
|
|
g_obj_Controladora.RecargarDatos();
|
|
}
|
|
}
|
|
}
|
|
#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;
|
|
}
|
|
//Enviar Email de Prueba
|
|
else if (keyData == Keys.F7)
|
|
{
|
|
// EnviarEmail();
|
|
return true;
|
|
}
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|