示例#1
0
        public AlumnoInscripto GetOne(int ID)
        {
            AlumnoInscripto inscripcion;

            try
            {
                this.OpenConnection();
                MySqlCommand cmd = new MySqlCommand("SELECT * FROM alumnos_inscripciones WHERE id_inscripcion = @ID", MySqlConn);
                cmd.Parameters.AddWithValue("@ID", ID);
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    inscripcion           = new AlumnoInscripto();
                    inscripcion.Id        = (int)reader["id_inscripcion"];
                    inscripcion.IdAlumno  = (int)reader["id_alumno"];
                    inscripcion.IdCurso   = (int)reader["id_curso"];
                    inscripcion.Condicion = (string)reader["condicion"];
                    inscripcion.Nota      = (int)reader["nota"];
                    reader.Close();
                    return(inscripcion);
                }
            }

            catch (Exception ex)
            {
                throw new NotFoundException("inscripción", ex);
            }
            finally
            {
                this.CloseConnection();
            }
            return(null);
        }
示例#2
0
        public void Listar()
        {
            List <AlumnoInscripto> alumnoList = alumnos.ListByCursoAndCondicion(currentCurso, AlumnoInscripto.Condiciones.Regular, AlumnoInscripto.Condiciones.Aprobado, AlumnoInscripto.Condiciones.Libre);

            this.dgvAlumnosCurso.DataSource = alumnoList;
            this.dgvAlumnosCurso.ClearSelection();
            foreach (DataGridViewRow row in dgvAlumnosCurso.Rows)
            {
                AlumnoInscripto alumnoInscripto = (AlumnoInscripto)row.DataBoundItem;
                row.Cells["Alumno"].Value   = alumnoInscripto.Alumno.NombreCompleto;
                row.Cells["Nota"].ValueType = typeof(string);
                if (alumnoInscripto.Nota != 0)
                {
                    ((DataGridViewTextBoxCell)row.Cells["Nota"]).ReadOnly = true;
                    row.Cells["Nota"].Value = alumnoInscripto.Nota.ToString();
                }
                if (alumnoInscripto.Condicion == AlumnoInscripto.Condiciones.Aprobado)
                {
                    row.DefaultCellStyle.ForeColor = Color.DarkGreen;
                }
                else if (alumnoInscripto.Condicion == AlumnoInscripto.Condiciones.Libre)
                {
                    row.DefaultCellStyle.ForeColor = Color.DarkRed;
                }
            }
        }
示例#3
0
 private void ClearForm()
 {
     Entity             = null;
     notaTextBox.Text   = "";
     legajoTextBox.Text = "";
     condicionDropDownList.SelectedIndex = -1;
 }
示例#4
0
 private void btnInscribir_Click(object sender, EventArgs e)
 {
     if (ValidarDGV(dgvCursos))
     {
         AlumnoLogic alumnoLogic   = new AlumnoLogic();
         Alumno      currentAlumno = alumnoLogic.GetOne(currentUser.IdPersona);
         if (currentAlumno != null)
         {
             //ahora que capturamos el alumno nos pasamos de capa para validar la inscripcion y hacerla
             CursoLogic cursoLogic   = new CursoLogic();
             int        ID           = ((Curso)this.dgvCursos.SelectedRows[0].DataBoundItem).Id;
             Curso      currentCurso = cursoLogic.GetOne(ID);
             string     rta          = inscripcionLogic.ValidarInscripcion(currentAlumno, currentCurso);
             if (rta == "")
             {
                 AlumnoInscripto currentInscripcion = new AlumnoInscripto();
                 currentInscripcion.IdAlumno  = currentAlumno.Id;
                 currentInscripcion.IdCurso   = currentCurso.Id;
                 currentInscripcion.State     = TiposDatos.States.New;
                 currentInscripcion.Condicion = "inscripto";
                 inscripcionLogic.Save(currentInscripcion);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("No se pudo inscribir al cursado por la siguiente razón:" + System.Environment.NewLine + rta, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
 }
示例#5
0
 protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Inscribirse")
     {
         int index = Convert.ToInt32(e.CommandArgument);
         gridView.SelectedIndex = index;
         int   id    = Convert.ToInt32(gridView.SelectedValue);
         Curso curso = cursos.GetOne(id);
         if (curso.Cupo - cursos.CantInscriptos(curso) > 0)
         {
             Usuario         usuario = Authenticate(true);
             AlumnoInscripto alumno  = new AlumnoInscripto()
             {
                 Alumno    = usuario.Persona,
                 Curso     = curso,
                 Condicion = AlumnoInscripto.Condiciones.Cursante,
                 Nota      = 0
             };
             alumnos.Save(alumno);
             errorLabel.Text    = "Inscripción realizada";
             errorLabel.Visible = true;
             LoadGrid();
         }
         else
         {
             errorLabel.Text    = "Error: No hay cupo disponible";
             errorLabel.Visible = true;
         }
     }
 }
示例#6
0
 private void LoadForm(int id)
 {
     Entity = alumnos.GetOne(id);
     condicionDropDownList.SelectedValue = Entity.Condicion.ToString();
     legajoTextBox.Text = Entity.Alumno.Legajo.ToString();
     notaTextBox.Text   = Entity.Nota.ToString();
 }
示例#7
0
        private void LoadEntity(AlumnoInscripto alumno)
        {
            AlumnoInscripto.Condiciones condicion = new AlumnoInscripto.Condiciones();
            switch (condicionDropDownList.SelectedValue)
            {
            case "Regular":
                condicion = AlumnoInscripto.Condiciones.Regular;
                break;

            case "Libre":
                condicion = AlumnoInscripto.Condiciones.Libre;
                break;

            case "Aprobado":
                condicion = AlumnoInscripto.Condiciones.Aprobado;
                break;

            case "Cursante":
                condicion = AlumnoInscripto.Condiciones.Cursante;
                break;
            }

            if (legajoTextBox.Text.Length > 0 && notaTextBox.Text.Length > 0 && notaTextBox.Text != "" && condicionDropDownList.SelectedItem != null)
            {
                alumno.Alumno = personas.FindByLegajo(int.Parse(legajoTextBox.Text));
            }
            alumno.Nota      = int.Parse(notaTextBox.Text);
            alumno.Condicion = condicion;
            alumno.Curso     = CurrentCurso;
        }
示例#8
0
 protected bool isRepeated(AlumnoInscripto alumno)
 {
     using (var context = new AcademiaContext())
     {
         return(context.AlumnoInscripto.Count(a => a.ID != alumno.ID && a.Curso.ID == alumno.Curso.ID && a.Alumno.ID == alumno.Alumno.ID) > 0);
     }
 }
示例#9
0
        public List <AlumnoInscripto> GetAllByIdCurso(int IdCurso)
        {
            List <AlumnoInscripto> inscripciones = new List <AlumnoInscripto>();

            try
            {
                this.OpenConnection();
                MySqlCommand cmd = new MySqlCommand("SELECT * FROM alumnos_inscripciones WHERE id_curso = @ID", MySqlConn);
                cmd.Parameters.AddWithValue("@ID", IdCurso);
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    AlumnoInscripto inscripto = new AlumnoInscripto();
                    inscripto.Id        = (int)reader["id_inscripcion"];
                    inscripto.IdAlumno  = (int)reader["id_alumno"];
                    inscripto.IdCurso   = (int)reader["id_curso"];
                    inscripto.Condicion = (string)reader["condicion"];
                    inscripto.Nota      = (int)reader["nota"];
                    inscripciones.Add(inscripto);
                }
                reader.Close();
            }

            catch (Exception ex)
            {
                throw new NotFoundException("inscripción", ex);
            }
            finally
            {
                this.CloseConnection();
            }
            return(inscripciones);
        }
示例#10
0
        private void LoadForm()
        {
            AlumnoInscripto alumno = alumnos.GetOne(CurrentAlumnoID);

            notaTextBox.Text   = alumno.Nota.ToString();
            errorLabel.Visible = false;
            alumnoLabel.Text   = "Alumno: " + alumno.Alumno.LegajoYNombre;
        }
示例#11
0
        private void Save()
        {
            int             condicion = Convert.ToInt32(condicionDropDownList.SelectedValue);
            AlumnoInscripto alumno    = alumnos.GetOne(CurrentAlumnoID);

            alumno.Condicion = (AlumnoInscripto.Condiciones)condicion;
            alumno.State     = BusinessEntity.States.Modified;
            alumnos.Save(alumno);
        }
示例#12
0
 public AlumnoInscriptoDTO(AlumnoInscripto alumno)
 {
     this.ID               = alumno.ID;
     this.AlumnoID         = alumno.Alumno.ID;
     this.Condicion        = alumno.Condicion;
     this.Nota             = alumno.Nota;
     this.CursoID          = alumno.Curso.ID;
     this.CursoDescripcion = alumno.Curso.ToString();
     this.AlumnoNombre     = alumno.Alumno.NombreCompleto;
 }
示例#13
0
 protected void editarLinkButton_Click(object sender, EventArgs e)
 {
     if (IsEntitySelected)
     {
         this.FormMode = TiposDatos.FormModes.Modificacion;
         this.PanelEditarNota.Visible  = true;
         this.gridActionsPanel.Visible = false;
         AlumnoInscripto inscripcion = ail.GetOne(SelectedID);
         txtNota.Text = inscripcion.Nota.ToString();
     }
 }
示例#14
0
 private void SaveEntity(AlumnoInscripto alumno)
 {
     try
     {
         alumnos.Save(alumno);
     }
     catch (Exception e)
     {
         Response.Redirect("/Error.aspx?m=" + e.Message, true);
     }
 }
示例#15
0
        private void dgvAlumnosCurso_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            AlumnoInscripto alumno = (AlumnoInscripto)dgvAlumnosCurso.Rows[e.RowIndex].DataBoundItem;

            if (dgvAlumnosCurso.Columns[e.ColumnIndex].Name == "Condicion")
            {
                string condString = (string)dgvAlumnosCurso.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                if (condString != "Aprobado")
                {
                    AlumnoInscripto.Condiciones condicion;
                    switch (condString)
                    {
                    case "Cursante":
                        condicion = AlumnoInscripto.Condiciones.Cursante;
                        break;

                    case "Libre":
                        condicion = AlumnoInscripto.Condiciones.Libre;
                        break;

                    case "Regular":
                        condicion = AlumnoInscripto.Condiciones.Regular;
                        break;

                    default:
                        throw new Exception("Bad option");
                    }
                    alumno.Condicion = condicion;
                    alumno.State     = BusinessEntity.States.Modified;
                }
                else
                {
                    MessageBox.Show("Esta condición no puede ser seleccionada manualmente.", "Opción inválida");
                    switch (alumno.Condicion)
                    {
                    case AlumnoInscripto.Condiciones.Cursante:
                        dgvAlumnosCurso.Rows[e.RowIndex].Cells["Condicion"].Value = "Cursante";
                        break;

                    case AlumnoInscripto.Condiciones.Libre:
                        dgvAlumnosCurso.Rows[e.RowIndex].Cells["Condicion"].Value = "Libre";
                        break;

                    case AlumnoInscripto.Condiciones.Regular:
                        dgvAlumnosCurso.Rows[e.RowIndex].Cells["Condicion"].Value = "Regular";
                        break;

                    case AlumnoInscripto.Condiciones.Aprobado:
                        dgvAlumnosCurso.Rows[e.RowIndex].Cells["Condicion"].Value = "Aprobado";
                        break;
                    }
                }
            }
        }
示例#16
0
        protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.RowState = DataControlRowState.Edit;
                AlumnoInscripto alumno = (AlumnoInscripto)e.Row.DataItem;

                ((Label)e.Row.FindControl("apnomLabel")).Text     = alumno.Alumno.NombreCompleto;
                ((Label)e.Row.FindControl("legajoLabel")).Text    = alumno.Alumno.Legajo.ToString();
                ((Label)e.Row.FindControl("condicionLabel")).Text = alumno.Condicion.ToString();
            }
        }
示例#17
0
    protected void aceptarLinkButton_Click(object sender, EventArgs e)
    {
        AlumnoInscripto inscripcion = ail.GetOne(SelectedID);

        inscripcion.Nota  = Convert.ToInt32(txtNota.Text);
        inscripcion.State = TiposDatos.States.Modified;
        this.SaveEntity(inscripcion);
        dgvAlumnosCurso.DataBind();
        this.PanelEditarNota.Visible  = false;
        this.txtNota.Text             = "";
        this.gridActionsPanel.Visible = true;
    }
示例#18
0
 protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         e.Row.RowState = DataControlRowState.Edit;
         AlumnoInscripto alumno = (AlumnoInscripto)e.Row.DataItem;
         string          nota   = "";
         if (alumno.Nota > 0)
         {
             nota = alumno.Nota.ToString();
         }
         ((Label)e.Row.FindControl("notaLabel")).Text = nota;
     }
 }
示例#19
0
        private void Save()
        {
            AlumnoInscripto alumno = alumnos.GetOne(CurrentAlumnoID);

            alumno.Nota = Convert.ToInt32(notaTextBox.Text);
            if (alumno.Nota >= 6)
            {
                alumno.Condicion = AlumnoInscripto.Condiciones.Aprobado;
            }
            else
            {
                alumno.Condicion = AlumnoInscripto.Condiciones.Libre;
            }
            alumno.State = BusinessEntity.States.Modified;
            alumnos.Save(alumno);
        }
示例#20
0
 protected void Insert(AlumnoInscripto entity)
 {
     using (var context = new AcademiaContext())
     {
         if (isRepeated(entity))
         {
             throw new Exception("Repeated entity");
         }
         var Alumno = context.Persona.Attach(entity.Alumno);
         entity.Alumno = Alumno;
         var Curso = context.Curso.Attach(entity.Curso);
         entity.Curso = Curso;
         context.AlumnoInscripto.Add(entity);
         context.SaveChanges();
     }
 }
示例#21
0
 protected void Update(AlumnoInscripto entity)
 {
     using (var context = new AcademiaContext())
     {
         if (isRepeated(entity))
         {
             throw new Exception("Repeated entity");
         }
         entity        = context.AlumnoInscripto.Attach(entity);
         entity.Alumno = context.Persona.Attach(entity.Alumno);
         entity.Curso  = context.Curso.Attach(entity.Curso);
         var entry = context.Entry(entity); // Gets the entry for entity inside context
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#22
0
    protected void dgvCursos_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.SelectedID = (int)this.dgvCursos.SelectedValue;
        //capturamos el alumno a travez del usuario

        int usuarioId = Convert.ToInt32(Session["idUsuario"]);

        try
        {
            UsuarioLogic userLogic   = new UsuarioLogic();
            Usuario      currentUser = userLogic.GetOne(usuarioId);

            if (currentUser != null)
            {
                AlumnoLogic alumnoLogic   = new AlumnoLogic();
                Alumno      currentAlumno = alumnoLogic.GetOne(currentUser.IdPersona);
                if (currentAlumno != null)
                {
                    //ahora que capturamos el alumno nos pasamos de capa para validar la inscripcion y hacerla
                    CursoLogic cursoLogic   = new CursoLogic();
                    Curso      currentCurso = cursoLogic.GetOne(SelectedID);
                    string     rta          = inscripcionLogic.ValidarInscripcion(currentAlumno, currentCurso);
                    if (rta == "")
                    {
                        AlumnoInscripto currentInscripcion = new AlumnoInscripto();
                        currentInscripcion.IdAlumno  = currentAlumno.Id;
                        currentInscripcion.IdCurso   = currentCurso.Id;
                        currentInscripcion.State     = TiposDatos.States.New;
                        currentInscripcion.Condicion = "inscripto";
                        inscripcionLogic.Save(currentInscripcion);
                        Response.Redirect("VerInscripciones.aspx");
                    }
                    else
                    {
                        lblError.Text = "Atención!: " + rta;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text = "Atención: " + ex.Message;
        }
    }
示例#23
0
        private void tsbEliminar_Click(object sender, EventArgs e)
        {
            DialogResult confirm = MessageBox.Show("¿Está seguro de que desea eliminar los elementos seleccionados?", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

            if (confirm == DialogResult.Yes)
            {
                try {
                    if (tabControl.SelectedTab == tsbAlumnos)
                    {
                        List <AlumnoInscripto> array = new List <AlumnoInscripto>();
                        foreach (DataGridViewRow row in dgvAlumnos.SelectedRows)
                        {
                            AlumnoInscripto entity = (AlumnoInscripto)row.DataBoundItem;
                            entity.State = BusinessEntity.States.Deleted;
                            alumnos.Save(entity);
                        }
                    }

                    else if (tabControl.SelectedTab == tsbDocentes)
                    {
                        List <DocenteCurso> array = new List <DocenteCurso>();
                        foreach (DataGridViewRow row in dgvDocentes.SelectedRows)
                        {
                            DocenteCurso entity = (DocenteCurso)row.DataBoundItem;
                            entity.State = BusinessEntity.States.Deleted;
                            docentes.Save(entity);
                        }
                    }
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                {
                    switch (ex.InnerException)
                    {
                    case System.Data.Entity.Core.UpdateException ue:
                        MessageBox.Show("No se ha podido eliminar un elemento ya que está referenciado por otro elemento", "Error al eliminar", MessageBoxButtons.OK, MessageBoxIcon.Warning);;
                        break;
                    }
                }
                finally
                {
                    Listar();
                }
            }
        }
示例#24
0
        private void btnInscribirse_Click(object sender, EventArgs e)
        {
            Curso        curso   = (Curso)dgvInscripciones.SelectedRows[0].DataBoundItem;
            DialogResult confirm = MessageBox.Show("Está por inscribirse al curso " + curso.ToString() + "\n¿Está seguro de que desea realizar esta operación?", "Inscripción", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

            if (confirm == DialogResult.Yes)
            {
                AlumnoInscripto alumno = new AlumnoInscripto()
                {
                    Alumno    = currentAlumno,
                    Curso     = curso,
                    Condicion = AlumnoInscripto.Condiciones.Cursante,
                    Nota      = 0,
                    State     = BusinessEntity.States.New
                };
                alumnos.Save(alumno);
                Listar();
            }
        }
示例#25
0
        private void dgvAlumnosCurso_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            AlumnoInscripto alumno = (AlumnoInscripto)dgvAlumnosCurso.Rows[e.RowIndex].DataBoundItem;

            try
            {
                if (dgvAlumnosCurso["Nota", e.RowIndex].ValueType == typeof(string))
                {
                    string value = (string)dgvAlumnosCurso["Nota", e.RowIndex].Value;
                    if (value != null)
                    {
                        int nota = int.Parse(value);
                        if (nota < 1 || nota > 10)
                        {
                            throw new FormatException();
                        }
                        alumno.Nota  = nota;
                        alumno.State = BusinessEntity.States.Modified;
                    }
                    else
                    {
                        alumno.Nota  = 0;
                        alumno.State = BusinessEntity.States.Unmodified;
                    }
                }
                else
                {
                    throw new FormatException();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("La nota debe ser un número entero entre 1 y 10", "Formato de nota incorrecto", MessageBoxButtons.OK, MessageBoxIcon.Error);
                string newValue = alumno.Nota == 0 ? "" : alumno.Nota.ToString();
                dgvAlumnosCurso["Nota", e.RowIndex].Value = newValue;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al modificar la nota. Detalle:" + ex.ToString(), "Ha ocurrido un error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#26
0
        public void Save(AlumnoInscripto entity)
        {
            switch (entity.State)
            {
            case BusinessEntity.States.Deleted:
                Delete(entity.ID);
                break;

            case BusinessEntity.States.New:
                Insert(entity);
                break;

            case BusinessEntity.States.Modified:
                Update(entity);
                break;

            default:
                entity.State = BusinessEntity.States.Unmodified;
                break;
            }
        }
示例#27
0
 protected void AceptarForm_Click(object sender, EventArgs e)
 {
     Validate();
     if (Page.IsValid)
     {
         if (FormMode == FormModes.Modificacion)
         {
             Entity       = alumnos.GetOne(SelectedID);
             Entity.State = BusinessEntity.States.Modified;
         }
         else
         {
             Entity       = new AlumnoInscripto();
             Entity.State = BusinessEntity.States.New;
         }
         LoadEntity(Entity);
         SaveEntity(Entity);
         LoadGrid();
         formPanel.Visible = false;
     }
 }
示例#28
0
        public void Save(AlumnoInscripto inscripcion)
        {
            switch (inscripcion.State)
            {
            case TiposDatos.States.New:
                this.Insert(inscripcion);
                break;

            case TiposDatos.States.Modified:
                this.Update(inscripcion);
                break;

            case TiposDatos.States.Deleted:
                this.Delete(inscripcion.Id);
                break;

            default:
                inscripcion.State = TiposDatos.States.Unmodified;
                break;
            }
        }
示例#29
0
 protected void Insert(AlumnoInscripto inscripcion)
 {
     try
     {
         this.OpenConnection();
         MySqlCommand cmd = new MySqlCommand("INSERT INTO alumnos_inscripciones (id_alumno, id_curso, condicion, nota) " +
                                             "VALUES (@id_alumno, @id_curso, @condicion, @nota);", MySqlConn);
         cmd.Parameters.AddWithValue("@id_alumno", inscripcion.IdAlumno);
         cmd.Parameters.AddWithValue("@id_curso", inscripcion.IdCurso);
         cmd.Parameters.AddWithValue("@condicion", inscripcion.Condicion);
         cmd.Parameters.AddWithValue("@nota", inscripcion.Nota);
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new InsertException("inscripción", ex);
     }
     finally
     {
         this.OpenConnection();
     }
 }
示例#30
0
        private void LoadForm()
        {
            AlumnoInscripto alumno = alumnos.GetOne(CurrentAlumnoID);

            if (alumno.Condicion == AlumnoInscripto.Condiciones.Aprobado)
            {
                condicionDropDownList.Visible = false;
                aceptarButton.Visible         = false;
                cancelarButton.Visible        = false;
                condicionLabel.Visible        = false;
                alumnoLabel.Text = "No puede modificarse la condición de un alumno ya aprobado";
            }
            else
            {
                aceptarButton.Visible         = true;
                cancelarButton.Visible        = true;
                condicionLabel.Visible        = true;
                condicionDropDownList.Visible = true;
                alumnoLabel.Text = "Alumno: " + alumno.Alumno.LegajoYNombre;
                condicionDropDownList.SelectedValue = ((int)alumno.Condicion).ToString();
            }
        }