Exemplo n.º 1
0
    protected void btnAceptarCrear_Click(object sender, EventArgs e)
    {
        if (this.IsValid)
        {
            int    id_cicle      = Convert.ToInt32(DropDownList2.SelectedItem.Value.ToString());
            int    id_curs       = Convert.ToInt32(DropDownList1.SelectedItem.Value.ToString());
            String codi          = TextBoxModalCodi.Text;
            String nom           = TextBoxModalNom.Text;
            int    hores         = Convert.ToInt32(TextBoxModalHores.Text);
            int    hores_lliures = Convert.ToInt32(TextBoxModalHoresLliures.Text);
            int    id_profesor   = Convert.ToInt32(DropDownListProfesor.SelectedItem.Value.ToString());

            if (LabelTitolModal.Text == "Crear")
            {
                String respuesta = BD.AltaModulProfesional(id_cicle, id_curs, codi, nom, hores, hores_lliures, id_profesor);
                if (respuesta != "")
                {
                    LabelErrorBD.Text = respuesta;
                    ButtonNou_ModalPopupExtender.Show();
                }
                else
                {
                    LimpiarPopUp();
                }
            }
            else
            {
                int    id        = Convert.ToInt32(LabelIdModificar.Text);
                String respuesta = BD.ModificarModulProfesional(id, id_cicle, id_curs, codi, nom, hores, hores_lliures, id_profesor);
                if (respuesta != "")
                {
                    LabelErrorBD.Text = respuesta;
                    ButtonNou_ModalPopupExtender.Show();
                }
                else
                {
                    LimpiarPopUp();
                }
            }
            BD.Refrescar("moduls_prof");
            RefrescarGrid();
        }
        else
        {
            ButtonNou_ModalPopupExtender.Show();
        }
    }