472 lines
19 KiB
C#
472 lines
19 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._4_Vistas.Controladoras;
|
|
using Exferia_KairosPRO._4_Vistas.Listados;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using static Exferia_Aplicacion.General.Enumerados;
|
|
|
|
namespace Exferia_KairosPRO._4_Vistas
|
|
{
|
|
public partial class P_Emails : Exferia_Formularios.P_Base_Mantenimientos
|
|
{
|
|
#region Variables General
|
|
private P_Emails_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 pagiandor
|
|
public Funciones_Paginador g_obj_Funciones_Paginador;
|
|
private Timer g_timer_Paginar = new Timer();
|
|
|
|
//Listado que controla los parametros
|
|
public List<string> g_lst_Parametros_Seleccionados = new List<string>();
|
|
#endregion
|
|
|
|
#region Objetos en pantalla
|
|
//Exferia_CheckListBox
|
|
internal Exferia_CheckListBox Exferia_CheckListBox_Informe { get { return ex_chklst_P_Emails_Informes; } }
|
|
|
|
//Exferia_Label
|
|
internal Exferia_Label Exferia_Label_Informe { get { return ex_lbl_P_Emails_Informes; } }
|
|
|
|
//Exferia_Panel_Degradado
|
|
internal Exferia_Panel_Degradado Exferia_Panel_Parametros { get { return ex_pnl_P_Emails_Parametros; } }
|
|
|
|
//Exferia_Paginador
|
|
internal Exferia_Paginador Exferia_Paginador_Emails { get { return ex_Paginador; } }
|
|
|
|
//Exferia_TextBox_Email
|
|
internal Exferia_TextBox_Email Exferia_TextBox_Email_Email { get { return ex_usc_P_Emails_Email; } }
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public P_Emails(INTERNO_ValoresGenerales_Modelo _mdl_INTERNO_ValoresGenerales_Modelo, DateTime _dtt_FechaTrabajo, PRV_OpcionesDetalle _mdl_PRV_OpcionesDetalle)
|
|
{
|
|
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_Emails_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);
|
|
|
|
//Poner los botones que no se puedan poner bloqueados o solo de lectura
|
|
ex_btn_P_Emails_Borrar.Exferia_Button_Bloqueable = false;
|
|
ex_btn_P_Emails_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;
|
|
|
|
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_Emails) + "/" + nameof(P_Emails));
|
|
}
|
|
}
|
|
//..................................................................................................................................
|
|
|
|
//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;
|
|
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Emails) + "/" + nameof(P_Emails));
|
|
}
|
|
finally
|
|
{
|
|
//Bloquear pantalla hasta que termine la carga por defecto .....
|
|
Enabled = true;
|
|
//.............................................................
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Inicio de pantalla
|
|
private void P_Emails_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_Emails) + "/" + nameof(P_Emails_Load));
|
|
|
|
g_bol_ConstructorPantalla_Terminado_Correctamente = false;
|
|
}
|
|
}
|
|
|
|
private void P_Emails_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";
|
|
|
|
g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = true;
|
|
|
|
ActivarBotones(false);
|
|
|
|
//Poner Texto predeterminado y foco
|
|
if ((P_Base_Campo_1 != null && P_Base_Campo_1.Trim().Length > 0) ||
|
|
(P_Base_Campo_2 != null && P_Base_Campo_2.Trim().Length > 0))
|
|
{
|
|
if (P_Base_Campo_1 != null && P_Base_Campo_1.Trim().Length > 0)
|
|
{
|
|
ex_usc_P_Emails_Email.Text = P_Base_Campo_1;
|
|
|
|
}
|
|
if (P_Base_Campo_2 != null && P_Base_Campo_2.Trim().Length > 0)
|
|
{
|
|
ex_usc_P_Emails_Email.Focus();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ex_usc_P_Emails_Email.Focus();
|
|
}
|
|
g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial = false;
|
|
|
|
}
|
|
//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_Emails.PaginasTotales = g_obj_Funciones_Paginador.Numero_Paginas_Totales;
|
|
}
|
|
else
|
|
{
|
|
Exferia_Paginador_Emails.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 pero se guarda en el log
|
|
Control_Errores.Errores_Log("", ex, nameof(P_Emails) + "/" + nameof(P_Emails_Shown));
|
|
|
|
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGARDATOSPANTALLA());
|
|
Salir_P_Base();
|
|
}
|
|
}
|
|
|
|
public void ActivarBotones(bool _bol_Activar)
|
|
{
|
|
if (Exferia_Paginador_Emails.Visible)
|
|
{
|
|
Exferia_Paginador_Emails.Visible = _bol_Activar;
|
|
}
|
|
|
|
if (ex_btn_P_Emails_Borrar.Enabled)
|
|
{
|
|
ex_btn_P_Emails_Borrar.Enabled = _bol_Activar;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Botones Grabar, Borrar, Parametros
|
|
private void ex_btn_P_Emails_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_Emails_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);
|
|
}
|
|
}
|
|
|
|
private void ex_btn_P_Emails_Parametros_Add_Click(object sender, EventArgs e)
|
|
{
|
|
Crear_Parametro();
|
|
}
|
|
|
|
private void Crear_Parametro()
|
|
{
|
|
if((Datos_Generales.Permisos_Comprobar(g_mdl_PRV_OpcionesDetalle.opcion,g_lst_INTERNO_Permisos_Modelo, (int)G_ENUM_PERMISOS.Anadir, true)))
|
|
{
|
|
//Obtener el Listado.........................................................
|
|
ABS_ListadoSeleccion_Parametros mdl_ABS_ListadoSeleccion_Parametros = new ABS_ListadoSeleccion_Parametros();
|
|
|
|
//Listado de Parametros ...............................................................
|
|
List<INTERNO_CodigoDescripcion_Modelo> lst_INTERNO_CodigoDescripcion_Modelo = new List<INTERNO_CodigoDescripcion_Modelo>();
|
|
|
|
//Si ya esta cargado el parametro en el panel, no lo mostramos
|
|
if (!g_lst_Parametros_Seleccionados.Contains(Variables.G_MDL_PARAMETRO_EMAIL_DEPARTAMENTO.Codigo))
|
|
{ lst_INTERNO_CodigoDescripcion_Modelo.Add(Variables.G_MDL_PARAMETRO_EMAIL_DEPARTAMENTO); }
|
|
//.....................................................................................
|
|
|
|
mdl_ABS_ListadoSeleccion_Parametros.Registros = lst_INTERNO_CodigoDescripcion_Modelo.Cast<dynamic>().ToList();
|
|
|
|
//Llamada al formulario de ListadoSeleccion
|
|
PE_Listados_SoloSeleccion frm_PE_Listados_SoloSeleccion = new PE_Listados_SoloSeleccion(mdl_ABS_ListadoSeleccion_Parametros, P_Base_ValoresGenerales, P_Base_FechaTrabajo);
|
|
frm_PE_Listados_SoloSeleccion.ShowDialog();
|
|
|
|
if (frm_PE_Listados_SoloSeleccion.g_dnm_RegistroSeleccionado != null)
|
|
{
|
|
P_Base_SeModificoDatosPantalla = true;
|
|
g_obj_Controladora.Crear_CTU_Parametro(frm_PE_Listados_SoloSeleccion.g_dnm_RegistroSeleccionado.Codigo);
|
|
|
|
//Cada parametro que añadamos lo metemos en un listado, para evitar que puedan poner mas de un mismo filtro
|
|
g_lst_Parametros_Seleccionados.Add(frm_PE_Listados_SoloSeleccion.g_dnm_RegistroSeleccionado.Codigo);
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Eventos del paginador
|
|
protected void ctu_Paginacion_Primera_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_obj_Controladora.ComprobarCambios()) //Si no han habido contratiempospasamos a la pagina indicada
|
|
{
|
|
if (g_obj_Funciones_Paginador.Primera())
|
|
{
|
|
//Asignando al control la pagina actual.
|
|
Exferia_Paginador_Emails.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();
|
|
}
|
|
}
|
|
}
|
|
|
|
private 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_Emails.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_Emails.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_Emails.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_Emails.txt_ValorPaginaActual - 1);
|
|
|
|
//Asignamos al control la pagina actual
|
|
Exferia_Paginador_Emails.PaginaActual = g_obj_Funciones_Paginador.GetPaginaActual();
|
|
|
|
//Regrescamos el listad 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;
|
|
}
|
|
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()
|
|
{
|
|
if (Enabled && g_obj_Controladora != null && g_obj_Controladora.g_bol_Termino_CargaDatos_Inicial)
|
|
{
|
|
P_Base_SeModificoDatosPantalla = true;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|