Exemple #1
0
    protected void GridViewModuls_SelectedIndexChanged(object sender, EventArgs e)
    {
        LabelTitolModal.Text = "Modificar";
        //Rellenaras los datos.
        GridViewRow row = GridViewModuls.SelectedRow;

        String id = row.Cells[3].Text;

        LabelIdModificar.Text = id;

        moduls_prof modul = BD.ConsultaModul(Convert.ToInt32(id));

        String cicle = modul.cursos.cicles.id.ToString();

        DropDownList2.ClearSelection();
        DropDownList2_CascadingDropDown.SelectedValue = cicle;

        String id_curs = modul.id_curs.ToString();

        DropDownList1.ClearSelection();
        DropDownList1_CascadingDropDown.SelectedValue = id_curs;

        TextBoxModalCodi.Text         = modul.codi.ToString();
        TextBoxModalNom.Text          = modul.nom.ToString();
        TextBoxModalHores.Text        = modul.hores.ToString();
        TextBoxModalHoresLliures.Text = modul.hores_lliures.ToString();

        if (modul.id_professor != null)
        {
            DropDownListProfesor.ClearSelection();
            DropDownListProfesor.Items.FindByValue(modul.id_professor.ToString()).Selected = true;
        }

        ButtonNou_ModalPopupExtender.Show();
    }
Exemple #2
0
    public static string AltaModulProfesional(int id_ciudad, string nombre, string cif, int categoria, string direccion, int telefono, string tipo)
    {
        string mensaje = "";

        moduls_prof h = new moduls_prof();

        h.id_ciudad = id_ciudad;
        h.nombre    = nombre;
        h.cif       = cif;
        h.categoria = categoria;
        h.direccion = direccion;
        h.telefono  = telefono;
        h.tipo      = tipo;

        contexto.hoteles.Add(h);
        try
        {
            contexto.SaveChanges();
        }
        catch (DbUpdateException ex)
        {
            SqlException sqlEx = (SqlException)ex.InnerException.InnerException;
            mensaje = BDErrores.MensajeError(sqlEx);

            contexto.hoteles.Remove(h);
        }

        return(mensaje);
    }
Exemple #3
0
    public static moduls_prof ConsultaModul(int id)
    {
        var moduls = (from c in contexto.moduls_prof

                      where c.id == id

                      select c).ToList();

        moduls_prof modul = moduls.First();

        return(modul);
    }
Exemple #4
0
    public static string ModificarModulProfesional(int id, int id_cicle, int id_curs, string codi, string nom, int hores, int hores_lliures, int id_professor)
    {
        string mensaje = "";

        var moduls = (from c in contexto.moduls_prof

                      where c.id == id

                      select c).ToList();

        moduls_prof modul = moduls.First();

        modul.id_curs       = id_curs;
        modul.codi          = codi;
        modul.nom           = nom;
        modul.hores         = hores;
        modul.hores_lliures = hores_lliures;
        modul.id_professor  = id_professor;
        var comprobar = (from c in contexto.moduls_prof

                         where c.id != id && c.id_curs == id_curs && (c.nom == nom || c.codi == codi)

                         select c).ToList();

        if (comprobar.Count() == 0)
        {
            try
            {
                contexto.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                SqlException sqlEx = (SqlException)ex.InnerException.InnerException;
                mensaje = BDErrores.MensajeError(sqlEx);
            }
        }
        else
        {
            mensaje = "Ja existeix un registre amb el mateix nom o codi";
        }
        return(mensaje);
    }
Exemple #5
0
    public static string AltaModulProfesional(int id_cicle, int id_curs, string codi, string nom, int hores, int hores_lliures, int id_professor)
    {
        string mensaje = "";

        moduls_prof h = new moduls_prof();

        h.id_curs       = id_curs;
        h.codi          = codi;
        h.nom           = nom;
        h.hores         = hores;
        h.hores_lliures = hores_lliures;
        h.id_professor  = id_professor;

        var comprobar = (from c in contexto.moduls_prof

                         where c.id_curs == id_curs && (c.nom == nom || c.codi == codi)

                         select c).ToList();

        if (comprobar.Count() == 0)
        {
            contexto.moduls_prof.Add(h);
            try
            {
                contexto.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                SqlException sqlEx = (SqlException)ex.InnerException.InnerException;
                mensaje = BDErrores.MensajeError(sqlEx);

                contexto.moduls_prof.Remove(h);
            }
        }
        else
        {
            mensaje = "Ja existeix un registre amb el mateix nom o codi";
        }

        return(mensaje);
    }