private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                validarEntidad();

                ProfesorService s = new ProfesorService();

                if (this.profesor.Id != 0)
                {
                    s.Update(profesor);
                }
                else
                {
                    s.Insert(profesor);
                }

                CommonHelper.ShowInfo("Profesor guardado con éxito.");
                this.DialogResult = DialogResult.OK;
            }
            catch (WarningException ex)
            {
                CommonHelper.ShowWarning(ex.Message);
            }
            catch (Exception ex)
            {
                CommonHelper.ShowError(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void frmComision_Load(object sender, EventArgs e)
        {
            cmbCarrera.DataSource      = new CarreraService().GetAll().FindAll(x => !x.Deshabilitado);
            cmbMateria.DataSource      = new MateriaService().GetAll().FindAll(x => !x.Deshabilitado);
            cmbCuatrimestre.DataSource = new List <byte> {
                1, 2
            };
            cmbTurno.DataSource     = new TurnoService().GetAll().OrderBy(x => x.Id).ToList();
            cmbModalidad.DataSource = new ModalidadService().GetAll().FindAll(x => !x.Deshabilitado);
            cmbProfesor.DataSource  = new ProfesorService().GetAll().FindAll(x => !x.Deshabilitado);

            List <Profesor> ayudantes = new ProfesorService().GetAll().FindAll(x => !x.Deshabilitado);

            ayudantes.Insert(0, new Profesor());
            cmbAyudante.DataSource = ayudantes;

            if (this.comision != null)
            {
                cmbCarrera.SelectedIndex      = cmbCarrera.FindString(comision.Materia.Carrera.ToString());
                cmbMateria.SelectedIndex      = cmbMateria.FindString(comision.Materia.ToString());
                dtpAño.Value                  = new DateTime(comision.Año, DateTime.Today.Month, DateTime.Today.Day);
                cmbCuatrimestre.SelectedIndex = comision.Cuatrimestre == null ? -1 : (byte)(comision.Cuatrimestre - 1);
                cmbTurno.SelectedIndex        = cmbTurno.FindString(comision.Turno.ToString());
                cmbModalidad.SelectedItem     = comision.Modalidad;
                cmbProfesor.SelectedIndex     = cmbProfesor.FindString(comision.Profesor.ToString());
                cmbAyudante.SelectedIndex     = comision.Ayudante == null ? -1 : cmbAyudante.FindString(comision.Ayudante.ToString());
            }
            else
            {
                cmbCarrera.SelectedIndex      = -1;
                cmbMateria.SelectedIndex      = -1;
                cmbMateria.Enabled            = false;
                cmbCuatrimestre.SelectedIndex = -1;
                cmbCuatrimestre.Enabled       = false;
                cmbTurno.SelectedIndex        = -1;
                cmbModalidad.SelectedIndex    = -1;
                cmbProfesor.SelectedIndex     = -1;
                cmbAyudante.SelectedIndex     = -1;
            }
        }