688 lines
29 KiB
C#
688 lines
29 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;
|
|
using Exferia_Aplicacion.General;
|
|
using System.Globalization;
|
|
|
|
namespace Exferia_Controles
|
|
{
|
|
public partial class Exferia_CalendarioMes : UserControl
|
|
{
|
|
#region Variables Privadas
|
|
private Color g_clr_Color_Hoy= ColorTranslator.FromHtml("#5785fb");
|
|
private Color g_clr_Color_Dia_Normal = ColorTranslator.FromHtml("#000000");
|
|
private Color g_clr_Color_Dia_Mes_NoActual = ColorTranslator.FromHtml("#b5b5b5");
|
|
private Color g_clr_Color_Fondo_Seleccion = ColorTranslator.FromHtml("#7ddb88");
|
|
private Color g_clr_Color_Fondo_Normal = ColorTranslator.FromHtml("#FFFFFF");
|
|
|
|
private DateTime g_dtt_Hoy = DateTime.Now.Date;
|
|
private DateTime g_dtt_Fecha_Actual;
|
|
|
|
|
|
#endregion
|
|
|
|
#region Propiedades Publicas
|
|
private string g_str_Tipo= "1";
|
|
public string Exferia_CalendarioMes_Tipo
|
|
{
|
|
set
|
|
{
|
|
g_str_Tipo = value;
|
|
}
|
|
get
|
|
{
|
|
return g_str_Tipo;
|
|
}
|
|
}
|
|
|
|
private DateTime g_dtt_Fecha_Desde_Seleccionada;
|
|
public DateTime Exferia_CalendarioMes_Fecha_Desde
|
|
{
|
|
get
|
|
{
|
|
return g_dtt_Fecha_Desde_Seleccionada;
|
|
}
|
|
}
|
|
|
|
private DateTime g_dtt_Fecha_Hasta_Seleccionada;
|
|
public DateTime Exferia_CalendarioMes_Fecha_Hasta
|
|
{
|
|
get
|
|
{
|
|
return g_dtt_Fecha_Hasta_Seleccionada;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Eventos publicos
|
|
public event EventHandler<INTERNO_EventArgs_TresValores> Exferia_CalendarioMes_Seleccion_Fechas;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public Exferia_CalendarioMes()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Repintar.Empezar(this);
|
|
|
|
//Hoy
|
|
g_dtt_Hoy = DateTime.Now.Date;
|
|
ex_lbl_Hoy.Text = g_dtt_Hoy.ToString("dd/MM/yyyy");
|
|
|
|
g_dtt_Fecha_Actual = DateTime.Now.Date;
|
|
g_dtt_Fecha_Desde_Seleccionada = DateTime.Now.Date;
|
|
g_dtt_Fecha_Hasta_Seleccionada = DateTime.Now.Date;
|
|
|
|
Redibujar();
|
|
}
|
|
#endregion
|
|
|
|
#region Cambio Año
|
|
private void ex_btn_Anyo_Adelante_Click(object sender, EventArgs e)
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Actual.AddYears(1);
|
|
Redibujar();
|
|
}
|
|
|
|
private void ex_btn_Anyo_Atras_Click(object sender, EventArgs e)
|
|
{
|
|
if (g_dtt_Fecha_Actual.Year>1900)
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Actual.AddYears(-1);
|
|
Redibujar();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Cambio Mes
|
|
private void ex_btn_Mes_Adelante_Click(object sender, EventArgs e)
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Actual.AddMonths(1);
|
|
Redibujar();
|
|
}
|
|
|
|
private void ex_btn_Mes_Atras_Click(object sender, EventArgs e)
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Actual.AddMonths(-1);
|
|
Redibujar();
|
|
}
|
|
#endregion
|
|
|
|
public void Fechas(DateTime _dtt_Fecha_Desde,DateTime _dtt_Fecha_Hasta,string _str_Tipo)
|
|
{
|
|
g_dtt_Fecha_Desde_Seleccionada = _dtt_Fecha_Desde;
|
|
g_dtt_Fecha_Hasta_Seleccionada = _dtt_Fecha_Hasta;
|
|
g_str_Tipo = _str_Tipo;
|
|
|
|
if (g_dtt_Fecha_Hasta_Seleccionada.Month== g_dtt_Fecha_Actual.Month)
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Hasta_Seleccionada;
|
|
}
|
|
else
|
|
{
|
|
g_dtt_Fecha_Actual = g_dtt_Fecha_Desde_Seleccionada;
|
|
}
|
|
|
|
//Si es de tipo Semanal o Semanal laboral, se marca la semana
|
|
if (g_str_Tipo=="2" ||
|
|
g_str_Tipo=="3")
|
|
{
|
|
ex_lbl_Semana_1.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_2.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_3.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_4.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_5.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_6.BackColor = g_clr_Color_Fondo_Normal;
|
|
|
|
//Ver a que semana pertenece
|
|
Exferia_Label_SinColor ex_lbl_Dia = null;
|
|
for (int int_Contador = 1; int_Contador <= 42; int_Contador++)
|
|
{
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (ex_lbl_Dia != null &&
|
|
ex_lbl_Dia.Visible &&
|
|
DateTime.ParseExact(ex_lbl_Dia.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture)== g_dtt_Fecha_Actual)
|
|
{
|
|
//Semana 1
|
|
if (int_Contador<8)
|
|
{
|
|
ex_lbl_Semana_1.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
//Semana 2
|
|
else if (int_Contador < 15)
|
|
{
|
|
ex_lbl_Semana_2.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
//Semana 3
|
|
else if (int_Contador < 22)
|
|
{
|
|
ex_lbl_Semana_3.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
//Semana 4
|
|
else if (int_Contador < 29)
|
|
{
|
|
ex_lbl_Semana_4.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
//Semana 5
|
|
else if (int_Contador < 36)
|
|
{
|
|
ex_lbl_Semana_5.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
//Semana 6
|
|
else
|
|
{
|
|
ex_lbl_Semana_6.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ex_lbl_Semana_1.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_2.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_3.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_4.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_5.BackColor = g_clr_Color_Fondo_Normal;
|
|
ex_lbl_Semana_6.BackColor = g_clr_Color_Fondo_Normal;
|
|
}
|
|
|
|
|
|
Redibujar();
|
|
}
|
|
|
|
#region Redibujar Calendario
|
|
public void Redibujar()
|
|
{
|
|
try
|
|
{
|
|
//Año
|
|
ex_lbl_Anyo.Text = g_dtt_Fecha_Actual.Year.ToString();
|
|
|
|
#region Mes
|
|
//Enero
|
|
if (g_dtt_Fecha_Actual.Month==1)
|
|
{
|
|
ex_lbl_Mes.Text= Variables.G_STR_CALENDARIO_MES_ENERO;
|
|
}
|
|
//Febrero
|
|
else if (g_dtt_Fecha_Actual.Month == 2)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_FEBRERO;
|
|
}
|
|
//Marzo
|
|
else if (g_dtt_Fecha_Actual.Month == 3)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_MARZO;
|
|
}
|
|
//Abril
|
|
else if (g_dtt_Fecha_Actual.Month == 4)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_ABRIL;
|
|
}
|
|
//Mayo
|
|
else if (g_dtt_Fecha_Actual.Month == 5)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_MAYO;
|
|
}
|
|
//Junio
|
|
else if (g_dtt_Fecha_Actual.Month == 6)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_JUNIO;
|
|
}
|
|
//Julio
|
|
else if (g_dtt_Fecha_Actual.Month == 7)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_JULIO;
|
|
}
|
|
//Agosto
|
|
else if (g_dtt_Fecha_Actual.Month == 8)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_AGOSTO;
|
|
}
|
|
//Septiembre
|
|
else if (g_dtt_Fecha_Actual.Month == 9)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_SEPTIEMBRE;
|
|
}
|
|
//Octubre
|
|
else if (g_dtt_Fecha_Actual.Month == 10)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_OCTUBRE;
|
|
}
|
|
//Noviembre
|
|
else if (g_dtt_Fecha_Actual.Month == 11)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_NOVIEMBRE;
|
|
}
|
|
//Diciembre
|
|
else if (g_dtt_Fecha_Actual.Month == 12)
|
|
{
|
|
ex_lbl_Mes.Text = Variables.G_STR_CALENDARIO_MES_DICIEMBRE;
|
|
}
|
|
#endregion
|
|
|
|
int int_Dia_Semana = 0;
|
|
int int_Dia_Mes = 1;
|
|
|
|
//Cambiar año pro ejercico actual
|
|
DayOfWeek dow_Dia_Semana = new DateTime(g_dtt_Fecha_Actual.Year, g_dtt_Fecha_Actual.Month, 1).DayOfWeek;
|
|
int int_Total_Dias_Mes = DateTime.DaysInMonth(g_dtt_Fecha_Actual.Year, g_dtt_Fecha_Actual.Month);
|
|
|
|
if (dow_Dia_Semana == DayOfWeek.Monday)
|
|
{
|
|
int_Dia_Semana = 0;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Tuesday)
|
|
{
|
|
int_Dia_Semana = 1;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Wednesday)
|
|
{
|
|
int_Dia_Semana = 2;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Thursday)
|
|
{
|
|
int_Dia_Semana = 3;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Friday)
|
|
{
|
|
int_Dia_Semana = 4;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Saturday)
|
|
{
|
|
int_Dia_Semana = 5;
|
|
}
|
|
else if (dow_Dia_Semana == DayOfWeek.Sunday)
|
|
{
|
|
int_Dia_Semana = 6;
|
|
}
|
|
|
|
//Actualizo los componentes
|
|
Panel pnl_Dia = null;
|
|
Exferia_Label_SinColor ex_lbl_Dia=null;
|
|
|
|
//Siguiente
|
|
int int_Contador_MesSiguiente = 1;
|
|
bool? bol_Mostrar_Dias_Mes_Siguiente =null;
|
|
ex_lbl_Semana_6.Visible = true;
|
|
DateTime dtt_MesSiguiente = new DateTime(g_dtt_Fecha_Actual.Year, g_dtt_Fecha_Actual.Month,1).AddMonths(1);
|
|
|
|
//Anterior
|
|
int int_Contador_MesAnterior = 0;
|
|
DateTime dtt_MesAnterior = new DateTime(g_dtt_Fecha_Actual.Year, g_dtt_Fecha_Actual.Month, 1).AddMonths(-1);
|
|
dtt_MesAnterior = dtt_MesAnterior.AddDays(DateTime.DaysInMonth(dtt_MesAnterior.Year, dtt_MesAnterior.Month)-1);
|
|
|
|
for (int int_Contador = 1; int_Contador <= 42; int_Contador++)
|
|
{
|
|
pnl_Dia = (Panel)this.Controls.Find("pnl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (pnl_Dia!=null && ex_lbl_Dia!=null)
|
|
{
|
|
pnl_Dia.Visible = true;
|
|
ex_lbl_Dia.Visible = true;
|
|
|
|
if (int_Dia_Mes <= int_Total_Dias_Mes)
|
|
{
|
|
//mes anterior
|
|
if (int_Dia_Semana >= int_Contador)
|
|
{
|
|
DateTime dtt_Dia_Mes_Anterior = dtt_MesAnterior.AddDays(-((int_Dia_Semana-1) - int_Contador_MesAnterior));
|
|
ex_lbl_Dia.Text = dtt_Dia_Mes_Anterior.Day.ToString();
|
|
|
|
DateTime dtt_Fecha_Dia = new DateTime(dtt_Dia_Mes_Anterior.Year, dtt_Dia_Mes_Anterior.Month, dtt_Dia_Mes_Anterior.Day);
|
|
ex_lbl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
pnl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
|
|
//Es Hoy?
|
|
if (dtt_Fecha_Dia == g_dtt_Hoy)
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Hoy;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = g_clr_Color_Hoy;
|
|
}
|
|
else
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Dia_Mes_NoActual;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = ex_lbl_Dia.BackColor;
|
|
}
|
|
|
|
//Si es la Fecha Seleccionada
|
|
if (dtt_Fecha_Dia >= g_dtt_Fecha_Desde_Seleccionada && dtt_Fecha_Dia <= g_dtt_Fecha_Hasta_Seleccionada)
|
|
{
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
|
|
int_Contador_MesAnterior++;
|
|
}
|
|
//Mes Actual
|
|
else
|
|
{
|
|
DateTime dtt_Fecha_Dia = new DateTime(g_dtt_Fecha_Actual.Year, g_dtt_Fecha_Actual.Month, int_Dia_Mes);
|
|
|
|
ex_lbl_Dia.Text = int_Dia_Mes.ToString();
|
|
ex_lbl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
pnl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
|
|
//Es Hoy?
|
|
if (dtt_Fecha_Dia == g_dtt_Hoy)
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Hoy;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = g_clr_Color_Hoy;
|
|
}
|
|
else
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Dia_Normal;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = ex_lbl_Dia.BackColor;
|
|
}
|
|
|
|
//Si es la Fecha Seleccionada
|
|
if (dtt_Fecha_Dia >= g_dtt_Fecha_Desde_Seleccionada && dtt_Fecha_Dia<=g_dtt_Fecha_Hasta_Seleccionada)
|
|
{
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
|
|
int_Dia_Mes++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Primera Vez
|
|
if (bol_Mostrar_Dias_Mes_Siguiente==null)
|
|
{
|
|
//Si es lunes no se muestran los dias del mes siguiente
|
|
if (dtt_MesSiguiente.DayOfWeek== DayOfWeek.Monday)
|
|
{
|
|
bol_Mostrar_Dias_Mes_Siguiente = false;
|
|
|
|
ex_lbl_Semana_6.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
bol_Mostrar_Dias_Mes_Siguiente = true;
|
|
}
|
|
}
|
|
//Si despues de estar mostrar los dia del mes siguiente se salta de semana, hay que ocultarlos
|
|
else
|
|
{
|
|
if (new DateTime(dtt_MesSiguiente.Year, dtt_MesSiguiente.Month, int_Contador_MesSiguiente).DayOfWeek == DayOfWeek.Monday)
|
|
{
|
|
bol_Mostrar_Dias_Mes_Siguiente = false;
|
|
|
|
ex_lbl_Semana_6.Visible = false;
|
|
}
|
|
}
|
|
|
|
if (bol_Mostrar_Dias_Mes_Siguiente.Value)
|
|
{
|
|
ex_lbl_Dia.Text = int_Contador_MesSiguiente.ToString();
|
|
|
|
DateTime dtt_Fecha_Dia = new DateTime(dtt_MesSiguiente.Year, dtt_MesSiguiente.Month, int_Contador_MesSiguiente);
|
|
ex_lbl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
pnl_Dia.Tag = dtt_Fecha_Dia.ToString("dd/MM/yyyy");
|
|
|
|
//Es Hoy?
|
|
if (dtt_Fecha_Dia == g_dtt_Hoy)
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Hoy;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = g_clr_Color_Hoy;
|
|
}
|
|
else
|
|
{
|
|
ex_lbl_Dia.ForeColor = g_clr_Color_Dia_Mes_NoActual;
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Normal;
|
|
pnl_Dia.BackColor = ex_lbl_Dia.BackColor;
|
|
}
|
|
|
|
//Si es la Fecha Seleccionada
|
|
if (dtt_Fecha_Dia >= g_dtt_Fecha_Desde_Seleccionada && dtt_Fecha_Dia <= g_dtt_Fecha_Hasta_Seleccionada)
|
|
{
|
|
ex_lbl_Dia.BackColor = g_clr_Color_Fondo_Seleccion;
|
|
}
|
|
|
|
int_Contador_MesSiguiente++;
|
|
}
|
|
else
|
|
{
|
|
pnl_Dia.Visible = false;
|
|
ex_lbl_Dia.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(Exferia_CalendarioMes) + "/" + nameof(Redibujar));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void Evento_Dia_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DateTime? dtt_Fecha = null;
|
|
|
|
if (sender.GetType().Name==nameof(Panel))
|
|
{
|
|
dtt_Fecha = DateTime.ParseExact(((Panel)sender).Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else if (sender.GetType().Name == nameof(Exferia_Label_SinColor))
|
|
{
|
|
dtt_Fecha = DateTime.ParseExact(((Exferia_Label_SinColor)sender).Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
|
|
if (dtt_Fecha!=null)
|
|
{
|
|
Fechas(dtt_Fecha.Value, dtt_Fecha.Value,"1");
|
|
|
|
//Salta el Evento de Seleccion Fechas
|
|
Exferia_CalendarioMes_Seleccion_Fechas?.Invoke(this, new INTERNO_EventArgs_TresValores(dtt_Fecha.Value.ToString("dd/MM/yyyy"), dtt_Fecha.Value.ToString("dd/MM/yyyy"), "1"));
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("",ex,nameof(Exferia_CalendarioMes) + "/" + nameof(Evento_Dia_Click));
|
|
}
|
|
}
|
|
|
|
private void Evento_Semana_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DateTime? dtt_Fecha_Desde = null;
|
|
DateTime? dtt_Fecha_Hasta = null;
|
|
|
|
int int_Semana =int.Parse(((Exferia_Label_SinColor)sender).Tag.ToString());
|
|
|
|
if (int_Semana==1)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_1.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo=="3")
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_5.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_7.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
else if (int_Semana == 2)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_8.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo == "3")
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_12.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_14.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
else if (int_Semana == 3)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_15.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo == "3")
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_19.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_21.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
else if (int_Semana == 4)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_22.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo == "3")
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_26.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_28.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
else if (int_Semana == 5)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_29.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo == "3")
|
|
{
|
|
if (ex_lbl_Dia_33.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_33.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
Exferia_Label_SinColor ex_lbl_Dia=null;
|
|
for (int int_Contador = 33; int_Contador >= 29; int_Contador--)
|
|
{
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (ex_lbl_Dia != null && ex_lbl_Dia.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ex_lbl_Dia_35.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_35.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
Exferia_Label_SinColor ex_lbl_Dia = null;
|
|
for (int int_Contador = 35; int_Contador >= 29; int_Contador--)
|
|
{
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (ex_lbl_Dia != null && ex_lbl_Dia.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (int_Semana == 6)
|
|
{
|
|
dtt_Fecha_Desde = DateTime.ParseExact(ex_lbl_Dia_36.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
if (g_str_Tipo == "3")
|
|
{
|
|
if (ex_lbl_Dia_40.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_40.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
Exferia_Label_SinColor ex_lbl_Dia = null;
|
|
for (int int_Contador = 40; int_Contador >= 36; int_Contador--)
|
|
{
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (ex_lbl_Dia != null && ex_lbl_Dia.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ex_lbl_Dia_42.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia_42.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
}
|
|
else
|
|
{
|
|
Exferia_Label_SinColor ex_lbl_Dia = null;
|
|
for (int int_Contador = 42; int_Contador >= 36; int_Contador--)
|
|
{
|
|
ex_lbl_Dia = (Exferia_Label_SinColor)this.Controls.Find("ex_lbl_Dia_" + int_Contador, true).FirstOrDefault();
|
|
|
|
if (ex_lbl_Dia != null && ex_lbl_Dia.Visible)
|
|
{
|
|
dtt_Fecha_Hasta = DateTime.ParseExact(ex_lbl_Dia.Tag.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dtt_Fecha_Desde != null && dtt_Fecha_Hasta!=null)
|
|
{
|
|
//Si el tipo esta a 1 le pongo 2
|
|
if (g_str_Tipo == "1")
|
|
{
|
|
g_str_Tipo = "2";
|
|
}
|
|
|
|
Fechas(dtt_Fecha_Desde.Value, dtt_Fecha_Hasta.Value, g_str_Tipo);
|
|
|
|
//Salta el Evento de Seleccion Fechas
|
|
Exferia_CalendarioMes_Seleccion_Fechas?.Invoke(this, new INTERNO_EventArgs_TresValores(dtt_Fecha_Desde.Value.ToString("dd/MM/yyyy"), dtt_Fecha_Hasta.Value.ToString("dd/MM/yyyy"),g_str_Tipo));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Control_Errores.Errores_Log("", ex, nameof(Exferia_CalendarioMes) + "/" + nameof(Evento_Semana_Click));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|