I have a calendar, in which I am coloring the rest days in Orange, based on the start date of the employee's day and the type of day.
What I want to do now, is to bring a date ( FechaSalida
) from my database, this date tells me if I work on the rest day that I played, and if I work I mark the day in yellow and not in orange, How can I do it?
private void calFecha_DayRender(object source, DayRenderEventArgs e) //Colores en Calendario
{
bool final = true;
if (ddloperadores.SelectedValue != "Todos")
{
DataTable asistencia = OperadoresBL.OperadoresForaneosAsistencia((int)WAPS.Globals.ConvertTo(txtNumOperador.Text, 0)).Tables[0]; //Datos de Store
if (asistencia.Rows.Count > 0)
{
DataRow iRow = asistencia.Rows[0];
string Tipo = iRow["TipoJornada"].ToString();
DateTime FechaJornada = Convert.ToDateTime(iRow["Jornada_Ini"]);
if (Tipo == "1") //Tipos de Jornadas
{
if (FechaJornada <= e.Day.Date)
{
int rem = (e.Day.Date - FechaJornada).Days % 10; //Total de días
DateTime FechaSalida = Convert.ToDateTime(iRow["FechaSalida"]);
if (rem >= 0 && rem <= 7) //Días Laborales
e.Cell.BackColor = System.Drawing.Color.White;
else //días de descanso obligatorios
e.Cell.BackColor = System.Drawing.Color.DarkOrange;
}
else
e.Cell.BackColor = System.Drawing.Color.White;
}
}
}
}
Current Code with the foreach
private void calFecha_DayRender(object source, DayRenderEventArgs e) //Colores en Calendario
{
bool final = true;
if (ddloperadores.SelectedValue != "Todos")
{
DataTable asistencia = OperadoresBL.OperadoresForaneosAsistencia((int)WAPS.Globals.ConvertTo(txtNumOperador.Text, 0)).Tables[0]; //Datos de Store
if (asistencia.Rows.Count > 0)
{
DataRow iRow = asistencia.Rows[0];
string Tipo = iRow["TipoJornada"].ToString();
DateTime FechaJornada = Convert.ToDateTime(iRow["Jornada_Ini"]);
if (Tipo == "1") //Tipos de Jornadas
{
if (FechaJornada <= e.Day.Date)
{
int rem = (e.Day.Date - FechaJornada).Days % 10; //Total de días
if (rem >= 0 && rem <= 7) //Días Laborales
{
e.Cell.BackColor = System.Drawing.Color.White;
}
else
{
foreach (DataRow row in asistencia.Rows)
{
DateTime FechaSalida = Convert.ToDateTime(iRow["FechaSalida"]);
if (e.Day.Date == FechaSalida.Date)
{
e.Cell.BackColor = System.Drawing.Color.Yellow;
}
else
{
e.Cell.BackColor = System.Drawing.Color.DarkOrange;
}
}
}
}
else
{
e.Cell.BackColor = System.Drawing.Color.White;
}
}
}
}
}
This shows me only one date but I'm missing the other 2 dates that my DateExit.