201 lines
6.2 KiB
C#
201 lines
6.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Exferia_Aplicacion.Visualizacion;
|
|
|
|
namespace Exferia_Controles
|
|
{
|
|
public partial class Exferia_FechaSeleccion : UserControl
|
|
{
|
|
public event KeyPressEventHandler Exferia_FechaSeleccion_TextBox_KeyPress;
|
|
public event EventHandler Exferia_FechaSeleccion_TextBox_TextChanged;
|
|
public event EventHandler Exferia_FechaSeleccion_LostFocus;
|
|
public event EventHandler Exferia_FechaSeleccion_GotFocus;
|
|
|
|
public bool g_bol_Activo = false;
|
|
|
|
//Se utiliza para entrar en el codigo desde otra libreria
|
|
public void Prueba()
|
|
{}
|
|
|
|
#region Propiedades
|
|
public string Exferia_FechaSeleccion_Descripcion
|
|
{
|
|
get
|
|
{
|
|
return ex_lbl_Descripcion.Text;
|
|
}
|
|
set
|
|
{
|
|
ex_lbl_Descripcion.Text = value;
|
|
}
|
|
}
|
|
|
|
public bool Exferia_FechaSeleccion_ReadOnly
|
|
{
|
|
get
|
|
{
|
|
return ex_txtm_Fecha.Exferia_TextBox_ConMascara_ReadOnly;
|
|
}
|
|
set
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_ReadOnly = value;
|
|
ex_btn_Calendario.Enabled = !value;
|
|
}
|
|
}
|
|
|
|
internal bool g_bol_Obligatorio = false;
|
|
public bool Exferia_FechaSeleccion_Obligatorio
|
|
{
|
|
set
|
|
{
|
|
g_bol_Obligatorio = value;
|
|
if (g_bol_Obligatorio)
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Fondo = Colores.G_COLOR_FONDO_OBLIGATORIO;
|
|
}
|
|
else
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Fondo = Color.White;
|
|
}
|
|
}
|
|
get
|
|
{
|
|
return g_bol_Obligatorio;
|
|
}
|
|
}
|
|
public string Exferia_FechaSeleccion_Fecha
|
|
{
|
|
get
|
|
{
|
|
return ex_txtm_Fecha.Text;
|
|
}
|
|
set
|
|
{
|
|
ex_txtm_Fecha.Text = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
bool g_bol_Bloqueable = true;
|
|
public bool Exferia_FechaSeleccion_Bloqueable
|
|
{
|
|
set
|
|
{
|
|
g_bol_Bloqueable = value;
|
|
}
|
|
get
|
|
{
|
|
return g_bol_Bloqueable;
|
|
}
|
|
}
|
|
|
|
public void Exferia_FechaSeleccion_Foco()
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Focus();
|
|
}
|
|
|
|
public void Exferia_FechaSeleccion_SeleccionarTexto()
|
|
{
|
|
if (!string.IsNullOrEmpty(ex_txtm_Fecha.Text))
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_SelectionStart = 0;
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_SelectionLength = ex_txtm_Fecha.Text.Length;
|
|
}
|
|
}
|
|
|
|
public Exferia_FechaSeleccion()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ex_txtm_Fecha_TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (ex_txtm_Fecha.Text.Trim(' ', '/') == "" || Exferia_Aplicacion.General.Funciones.Fecha_Validacion(ex_txtm_Fecha.Text) == 0)
|
|
{
|
|
//Quitar Error de Fecha Desde
|
|
if (g_bol_Obligatorio)
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Fondo = Colores.G_COLOR_FONDO_OBLIGATORIO;
|
|
}
|
|
else
|
|
{
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Fondo = Color.White;
|
|
}
|
|
|
|
//Para que salte el evento en el otro lado
|
|
Exferia_FechaSeleccion_TextBox_TextChanged?.Invoke(this, e);
|
|
}
|
|
else
|
|
{
|
|
//Poner Error de Fecha Desde
|
|
ex_txtm_Fecha.Exferia_TextBox_ConMascara_Fondo = Colores.G_COLOR_FONDO_ERROR;
|
|
}
|
|
}
|
|
|
|
private void ex_txtm_Fecha_Exferia_TextBox_ConMascara_Evento_GotFocus(object sender, EventArgs e)
|
|
{
|
|
g_bol_Activo = true;
|
|
//Para que salte el evento en el otro lado
|
|
Exferia_FechaSeleccion_GotFocus?.Invoke(this, e);
|
|
}
|
|
|
|
private void ex_txtm_Fecha_Exferia_TextBox_ConMascara_Evento_LostFocus(object sender, EventArgs e)
|
|
{
|
|
if (g_bol_Activo && ex_btn_Calendario.Focused==false)
|
|
{
|
|
g_bol_Activo = false;
|
|
//Para que salte el evento en el otro lado
|
|
Exferia_FechaSeleccion_LostFocus?.Invoke(this, e);
|
|
}
|
|
}
|
|
|
|
private void ex_txtm_Fecha_TextBox_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
//Para que salte el evento en el otro lado
|
|
Exferia_FechaSeleccion_TextBox_KeyPress?.Invoke(this, e);
|
|
}
|
|
|
|
private void ex_btn_Calendario_Click(object sender, EventArgs e)
|
|
{
|
|
//Para que salte el evento en el otro lado
|
|
Exferia_FechaSeleccion_GotFocus?.Invoke(this, e);
|
|
|
|
MostrarCalendario(ex_txtm_Fecha);
|
|
}
|
|
|
|
private void MostrarCalendario(Exferia_TextBox_ConMascara _ex_txtm_Auxilar)
|
|
{
|
|
string str_Fecha = string.Empty;
|
|
if ((_ex_txtm_Auxilar.Text.Trim(' ', '/') != "") && (Exferia_Aplicacion.General.Funciones.Fecha_Validacion(_ex_txtm_Auxilar.Text) == 0))
|
|
{
|
|
str_Fecha = _ex_txtm_Auxilar.Text;
|
|
}
|
|
else
|
|
{
|
|
str_Fecha = DateTime.Today.ToShortDateString();
|
|
}
|
|
|
|
Exferia_Formularios.PE_Calendario frm_PE_Calendario = new Exferia_Formularios.PE_Calendario(str_Fecha);
|
|
frm_PE_Calendario.TopMost = true;
|
|
frm_PE_Calendario.ShowDialog();
|
|
if (!string.IsNullOrEmpty(frm_PE_Calendario.PE_Calendario_FechaSeleccionada))
|
|
{
|
|
_ex_txtm_Auxilar.Text = frm_PE_Calendario.PE_Calendario_FechaSeleccionada;
|
|
}
|
|
|
|
//Poner el Foco
|
|
_ex_txtm_Auxilar.Exferia_TextBox_ConMascara_Focus();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|