示例#1
0
    protected void rdgIns_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        try
        {
            string            strResultado = string.Empty;
            GridEditableItem  ObjItem      = (GridEditableItem)e.Item;
            Hashtable         ObjHashtable = new Hashtable();
            incription_course objIns       = new incription_course();

            ObjItem.ExtractValues(ObjHashtable);

            objIns.id = Convert.ToInt32(ObjHashtable["id"]);

            clsInscripcion asignacion = new clsInscripcion();
            asignacion.prInscripcion = objIns;

            strResultado = asignacion.EliminarAsignacion();

            if (string.IsNullOrEmpty(strResultado))
            {
                this.rdgIns.Rebind();
                base.EnvioMensaje("Inscripción eliminada correctamente.", 2, Manejador);
            }
            else
            {
                this.rdgIns.Rebind();
                base.EnvioMensaje(strResultado, 1, Manejador);
            }
        }
        catch (Exception ex)
        {
            base.EnvioMensaje("Error al eliminar datos.", 1, this.Manejador);
        }
    }
示例#2
0
    private void InscribirCurso()
    {
        string            strResultado = string.Empty;
        incription_course objIns       = new incription_course();

        objIns.id_course   = Convert.ToInt16(this.cmbCursos.SelectedValue);
        objIns.id_student  = base.getIdUsuario();
        objIns.id_state    = 1;
        objIns.observation = null;
        objIns.note        = 0;

        clsInscripcion inscripcion = new clsInscripcion();

        inscripcion.prInscripcion = objIns;

        strResultado = inscripcion.AsignarCursoEstudiante();

        if (string.IsNullOrEmpty(strResultado))
        {
            base.EnvioMensaje("Inscripcion realizada con éxito.", 2, this.Manejador);
            this.rdgIns.Rebind();
        }
        else
        {
            base.EnvioMensaje(strResultado, 1, this.Manejador);
        }
    }
示例#3
0
    private string ReglasNegocio(incription_course objIns)
    {
        string strResultado = string.Empty;

        if (objIns.note == -1)
        {
            strResultado = "Es necesario ingresar la nota del curso.";
        }
        else if (objIns.note > 100 || objIns.note < 0)
        {
            strResultado = "El rango de la nota está entre 0 y 100.";
        }

        return(strResultado);
    }
示例#4
0
    protected void rdgNotas_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        try
        {
            string            strResultado = string.Empty;
            GridEditableItem  ObjItem      = (GridEditableItem)e.Item;
            Hashtable         ObjHashTable = new Hashtable();
            incription_course objIns       = new incription_course();

            ObjItem.ExtractValues(ObjHashTable);

            objIns.id          = Convert.ToInt32(ObjHashTable["id"]);
            objIns.note        = IsNull(ObjHashTable["nota"]) ? -1 : Convert.ToInt32(ObjHashTable["nota"]);
            objIns.observation = IsNull(ObjHashTable["observacion"]) ? "" : ObjHashTable["observacion"].ToString();
            objIns.id_state    = IsNull(ObjHashTable["estado"]) ? 1 : Convert.ToInt32(ObjHashTable["estado"].ToString());

            strResultado = ReglasNegocio(objIns);

            if (strResultado.Equals(string.Empty))
            {
                clsNotas notas = new clsNotas();
                notas.prInscripcion = objIns;

                strResultado = notas.ActualizarNota();

                if (strResultado.Equals(string.Empty))
                {
                    base.EnvioMensaje("Nota actualizada correctamente.", 2, this.Manejador);
                    this.rdgNotas.Rebind();
                }
                else
                {
                    base.EnvioMensaje(strResultado, 2, this.Manejador);
                }
            }
            else
            {
                base.EnvioMensaje(strResultado, 1, this.Manejador);
            }
        }
        catch (Exception ex)
        {
            this.rdgNotas.MasterTableView.ClearEditItems();
            base.EnvioMensaje("Error al actualizar datos: " + ex.Message.ToString(), 1, this.Manejador);
        }
    }
    public string AsignarCursoEstudiante()
    {
        string strResultado = string.Empty;

        try
        {
            using (universityEntities DbContext = new universityEntities())
            {
                var AsignacionExistente = DbContext.incription_course.FirstOrDefault(x => (x.id_course == this.objIns.id_course &&
                                                                                           (x.id_student == this.objIns.id_student)));

                if (AsignacionExistente != null)
                {
                    strResultado = String.Format("El alumno actual ya tiene asignado el curso seleccionado.");
                }
                else
                {
                    incription_course newInscription = new incription_course();
                    newInscription.id_course   = this.objIns.id_course;
                    newInscription.id_state    = this.objIns.id_state;
                    newInscription.id_student  = this.objIns.id_student;
                    newInscription.note        = this.objIns.note;
                    newInscription.observation = this.objIns.observation;

                    DbContext.incription_course.Add(newInscription);
                    DbContext.SaveChanges();
                }
            }
        }
        catch (Exception e)
        {
            strResultado = "Error al guardar el curso ingresado: " + e.Message.ToString();
        }

        return(strResultado);
    }