Esempio n. 1
0
        private void PruebBoton(object sender, RoutedEventArgs e)
        {
            HorarioBLL _horarios = new HorarioBLL();
            List<HorarioC> lst = new List<HorarioC>()
            {
                ctrHo_lun,ctrHo_Mar,ctrHo_Mie,ctrHo_Jue,ctrHo_Vie,ctrHo_Sab,ctrHo_Dom
            };
            try
            {
                int idLab = ((Laboratorio)cbLab.SelectedValue).ID;
                int idDoc = ((Docente)cbDoc.SelectedValue).ID;
                int idAsi = ((Asignatura)cbMat.SelectedValue).ID;
                int idGrp = ((Grupo)cbGrp.SelectedValue).ID;

                foreach (var ctr in lst)
                {
                    if (ctr.Checado)
                    {
                        if (llenos(ctr.HrInicio, ctr.HrFin))
                        {
                            Horario _hora = new Horario()
                            {
                                IDAsignatura = idAsi,
                                Dia = ctr.Dia,
                                HoraInicio = ctr.HrInicio,
                                HoraFin = ctr.HrFin,
                                IDLab = idLab,
                                IDDocente = idDoc,
                                IDGrupo = idGrp
                            };
                            if (_horarios.Agregar(_hora) != -1)
                            {
                                MessageBox.Show(this, string.Format("Dia {0} Agregado correctamente", ctr.Dia), appInfo.AssemblyProduct,
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            else
                            {
                                MessageBox.Show(this, "Algo ha salido mal :(", appInfo.AssemblyProduct,
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "No debe de tener campos vacios", appInfo.AssemblyProduct,
                               MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }
            }
            catch (InvalidCastException)
            {
                MessageBox.Show(this,"Por favor seleccione un Horario ",appInfo.AssemblyProduct,
                        MessageBoxButton.OK,MessageBoxImage.Information);
            }
            catch (Exception)
            {
                MessageBox.Show(this,"Error general ", appInfo.AssemblyProduct,
                        MessageBoxButton.OK,MessageBoxImage.Information);
            }
        }