Beispiel #1
0
        protected void ButtonAgrOpcionN2_Click(object sender, EventArgs e)
        {
            SqlConnection con;
            SqlCommand    cmd      = new SqlCommand();
            String        Perfil   = DropDownPerfil.SelectedValue;
            String        Opcion   = DropDownListOpcionPagN2.SelectedValue;
            int           i        = GridViewMenu_N0.SelectedIndex;
            Label         Modulo   = (Label)GridViewMenu_N0.Rows[i].FindControl("Modulo");
            int           j        = GridViewMenu_N1.SelectedIndex;
            Label         OpcionN1 = (Label)GridViewMenu_N1.Rows[j].FindControl("Opcion");
            int           Posicion = GridViewMenu_N2.Rows.Count + 1;

            con            = new SqlConnection(BopDBModulos.ConnectionString);
            cmd.Connection = con;
            con.Open();
            try
            {
                cmd.CommandText = "INSERT INTO [dbo].[Menu_N2] ([Perfil],[Modulo],[Posicion],[Opcion1],[Opcion2]) VALUES('" + Perfil.Trim() + "','" + Modulo.Text.Trim() + "'," + Posicion.ToString() + ",'" + OpcionN1.Text.Trim() + "','" + Opcion.Trim() + "')";
                cmd.ExecuteNonQuery();
                GridViewMenu_N2.DataBind();
            }
            catch (SqlException exception)
            {
                if (exception.Number == 2601) // Cannot insert duplicate key row in object error
                {
                    return;
                }
            }
        }
Beispiel #2
0
        protected void GridViewMenu_N1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int   i      = GridViewMenu_N1.SelectedIndex;
            Label Opcion = (Label)GridViewMenu_N1.Rows[i].FindControl("Opcion");

            OpcionSel.Text = Opcion.Text;
            GridViewMenu_N2.SelectedIndex = -1;
            GridViewMenu_N2.DataBind();
        }