Пример #1
0
        public void GenerarCalendarioUI(int mes, int anio, ObservableCollection <GRUPO_HORARIO> agenda)
        {
            try
            {
                var hoy         = Fechas.GetFechaDateServer;
                var weekRow     = new WeekRowView();
                var diasMes     = DateTime.DaysInMonth(anio, mes);
                var fechaInicio = new DateTime(anio, mes, 1).Date;
                var semana      = 1;
                var dia         = Convert.ToInt32(fechaInicio.DayOfWeek);
                if (gridCalendario.Children.Count > 7) //si ya hay algo mas agregado al grid aparte del titulo
                {
                    LimpiarCalendario();
                }
                SetRowDefinitions(diasMes, dia);
                for (var diaCorriente = 1; diaCorriente <= diasMes; diaCorriente++)
                {
                    var daybox = new DayBoxView();
                    daybox.DayNumberLabel.Content = diaCorriente.ToString();
                    var dateCorriente = new DateTime(anio, mes, diaCorriente);

                    if (agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente))
                    {
                        daybox.DayAppointmentsStack.Background = Brushes.LightSkyBlue;
                    }
                    else
                    {
                        daybox.DayAppointmentsStack.Background = Brushes.White;
                    }

                    var ObjGrupoHorario = agenda.Where(w => w.HORA_INICIO.Value.Date.Equals(dateCorriente.Date)).FirstOrDefault();
                    if (!(agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente) || dateCorriente >= hoy.Date))
                    {
                        if ((agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente)))
                        {
                            daybox.DayAppointmentsStack.Background = Brushes.LightGray;
                        }
                        daybox.DayBox.IsEnabled = false;
                        daybox.DayBox.SetBinding(Button.CommandProperty, new Binding(BindCmdDay)
                        {
                            Source = this.DataContext
                        });
                    }
                    else
                    {
                        if ((agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente)) && (dateCorriente < hoy.Date) && !EsLiberados)
                        {
                            daybox.DayAppointmentsStack.Background = Brushes.LightGray;
                            daybox.DayBox.IsEnabled = false;
                        }
                        else
                        {
                            if (ObjGrupoHorario != null)
                            {
                                daybox.DayBox.CommandParameter = ObjGrupoHorario;
                            }
                            else
                            {
                                daybox.DayBox.CommandParameter = dateCorriente.Date;
                            }
                            daybox.DayBox.SetBinding(Button.CommandProperty, new Binding(BindCmdDay)
                            {
                                Source = this.DataContext
                            });
                        }
                    }

                    if (ObjGrupoHorario != null)
                    {
                        daybox.TimeAppointmentsLabel.Text    = ObjGrupoHorario.HORA_INICIO.Value.ToShortTimeString() + " - " + ObjGrupoHorario.HORA_TERMINO.Value.ToShortTimeString();
                        daybox.AreaAppointmentsLabel.Text    = ObjGrupoHorario.AREA != null ? ObjGrupoHorario.AREA.DESCR : string.Empty;
                        daybox.EstatusAppointmentsLabel.Text = ObjGrupoHorario.GRUPO_HORARIO_ESTATUS != null ? ObjGrupoHorario.GRUPO_HORARIO_ESTATUS.DESCR : string.Empty;
                        if (ObjGrupoHorario.ESTATUS == 1)
                        {
                            if (daybox.DayBox.IsEnabled)
                            {
                                daybox.DayAppointmentsStack.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#00D100"));
                            }
                        }
                        if (ObjGrupoHorario.ESTATUS == 2)
                        {
                            if (daybox.DayBox.IsEnabled)
                            {
                                daybox.DayAppointmentsStack.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#C35F57"));
                            }
                        }
                    }

                    Grid.SetColumn(daybox, dia);
                    weekRow.gridWeekRow.Children.Add(daybox);
                    dia += 1;
                    if (dia == 7 || diaCorriente == diasMes)
                    {
                        Grid.SetRow(weekRow, semana);
                        Grid.SetColumnSpan(weekRow, 7);
                        gridCalendario.Children.Add(weekRow);
                        weekRow = new WeekRowView();
                        semana += 1;
                        dia     = 0;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #2
0
        public void GenerarCalendarioUILiberado(int mes, int anio, ObservableCollection <GRUPO_HORARIO> agenda)
        {
            try
            {
                var hoy         = Fechas.GetFechaDateServer;
                var weekRow     = new WeekRowView();
                var diasMes     = DateTime.DaysInMonth(anio, mes);
                var fechaInicio = new DateTime(anio, mes, 1).Date;
                var semana      = 1;
                var dia         = Convert.ToInt32(fechaInicio.DayOfWeek);
                if (gridCalendario.Children.Count > 7) //si ya hay algo mas agregado al grid aparte del titulo
                {
                    LimpiarCalendario();
                }
                SetRowDefinitions(diasMes, dia);
                for (var diaCorriente = 1; diaCorriente <= diasMes; diaCorriente++)
                {
                    var daybox = new DayBoxView();
                    daybox.DayNumberLabel.Content = diaCorriente.ToString();
                    var dateCorriente = new DateTime(anio, mes, diaCorriente);

                    if (agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente))
                    {
                        daybox.DayAppointmentsStack.Background = Brushes.LightSkyBlue;
                    }
                    else
                    {
                        daybox.DayAppointmentsStack.Background = Brushes.White;
                    }

                    var ObjGrupoHorario = agenda.Where(w => w.HORA_INICIO.Value.Date.Equals(dateCorriente.Date)).FirstOrDefault();
                    if (!(agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente) || dateCorriente >= hoy.Date))
                    {
                        //if ((agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente)))
                        //    daybox.DayAppointmentsStack.Background = Brushes.LightGray;
                        //daybox.DayBox.IsEnabled = false;
                        if (ObjGrupoHorario != null)
                        {
                            daybox.DayBox.CommandParameter = ObjGrupoHorario;
                        }
                        else
                        {
                            daybox.DayBox.CommandParameter = dateCorriente.Date;
                        }
                        daybox.DayBox.SetBinding(Button.CommandProperty, new Binding(BindCmdDay)
                        {
                            Source = this.DataContext
                        });
                    }
                    else
                    {
                        if ((agenda.Select(s => s.HORA_INICIO.Value.Date).Contains(dateCorriente)) && (dateCorriente < hoy.Date))
                        {
                            //daybox.DayAppointmentsStack.Background = Brushes.LightGray;
                            //daybox.DayBox.IsEnabled = false;
                            if (ObjGrupoHorario != null)
                            {
                                daybox.DayBox.CommandParameter = ObjGrupoHorario;
                            }
                            else
                            {
                                daybox.DayBox.CommandParameter = dateCorriente.Date;
                            }
                            daybox.DayBox.SetBinding(Button.CommandProperty, new Binding(BindCmdDay)
                            {
                                Source = this.DataContext
                            });
                        }
                        else
                        {
                            if (ObjGrupoHorario != null)
                            {
                                daybox.DayBox.CommandParameter = ObjGrupoHorario;
                            }
                            else
                            {
                                daybox.DayBox.CommandParameter = dateCorriente.Date;
                            }
                            daybox.DayBox.SetBinding(Button.CommandProperty, new Binding(BindCmdDay)
                            {
                                Source = this.DataContext
                            });
                        }
                    }

                    if (ObjGrupoHorario != null)
                    {
                        daybox.TimeAppointmentsLabel.Text = ObjGrupoHorario.HORA_INICIO.Value.ToShortTimeString() + " - " + ObjGrupoHorario.HORA_TERMINO.Value.ToShortTimeString();
                        switch ((short)ObjGrupoHorario.ID_TIPO_PROGRAMA)
                        {
                        case (short)enumAsistencia.Asistencia:
                            if (daybox.DayBox.IsEnabled)
                            {
                                daybox.DayAppointmentsStack.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#317A2E"));
                            }
                            break;

                        case (short)enumAsistencia.Falta:
                            if (daybox.DayBox.IsEnabled)
                            {
                                daybox.DayAppointmentsStack.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#DD5448"));
                            }
                            break;

                        case (short)enumAsistencia.Falta_Justificada:
                            if (daybox.DayBox.IsEnabled)
                            {
                                daybox.DayAppointmentsStack.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFF29D"));
                            }
                            break;
                        }
                    }

                    Grid.SetColumn(daybox, dia);
                    weekRow.gridWeekRow.Children.Add(daybox);
                    dia += 1;
                    if (dia == 7 || diaCorriente == diasMes)
                    {
                        Grid.SetRow(weekRow, semana);
                        Grid.SetColumnSpan(weekRow, 7);
                        gridCalendario.Children.Add(weekRow);
                        weekRow = new WeekRowView();
                        semana += 1;
                        dia     = 0;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }