private void button1_Click(object sender, EventArgs e)
        {
            MenuRol form = new MenuRol();

            form.StartPosition = FormStartPosition.CenterScreen;
            form.Show();
            this.Dispose();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Debe especificar un nombre");
            }
            else if (checkedListBox1.CheckedItems.Count == 0)
            {
                MessageBox.Show("Debe al menos seleccionar una funcionalidad para su rol");
            }
            else
            {
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["GD_CRUCEROS"].ConnectionString))
                {
                    cn.Open();

                    /*+SqlCommand cmdc = new SqlCommand("select count(*) as Total from LOS_QUE_VAN_A_APROBAR.Rol where IdRol = " + textBox1.Text,cn);
                     * cmdc.CommandType = CommandType.Text;
                     * int pruebita =  Convert.ToInt32(cmdc.ExecuteScalar());
                     * MessageBox.Show(pruebita.ToString());*/
                    SqlCommand cmd = new SqlCommand("LOS_QUE_VAN_A_APROBAR.NuevoRol", cn);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@NuevoNombre", SqlDbType.NVarChar, 255).Value = textBox1.Text;
                    cmd.ExecuteNonQuery();

                    SqlCommand cmd2 = new SqlCommand("select LOS_QUE_VAN_A_APROBAR.ObtenerNuevoRolInsertado()", cn);
                    cmd2.CommandType = CommandType.Text;
                    int IdRolNuevo = Convert.ToInt32(cmd2.ExecuteScalar());

                    SqlCommand cmd3 = new SqlCommand("LOS_QUE_VAN_A_APROBAR.FuncionalidadParaRol", cn);
                    cmd3.CommandType = CommandType.StoredProcedure;
                    cmd3.Parameters.Add("@IdRol", SqlDbType.Int).Value = IdRolNuevo;
                    cmd3.Parameters.Add("@IdFuncionalidad", SqlDbType.Int);
                    DataRow row;

                    for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
                    {
                        row = ((((DataRowView)checkedListBox1.CheckedItems[i]))).Row;
                        int valor = Convert.ToInt32(row[checkedListBox1.ValueMember]);
                        cmd3.Parameters["@IdFuncionalidad"].Value = valor;
                        cmd3.ExecuteNonQuery();
                    }

                    MessageBox.Show("Rol creado exitosamente");
                    cn.Close();
                    MenuRol form = new MenuRol();
                    form.StartPosition = FormStartPosition.CenterScreen;
                    form.Show();
                    this.Dispose();
                }
            }
        }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["GD_CRUCEROS"].ConnectionString))
     {
         using (SqlCommand cmd = new SqlCommand("LOS_QUE_VAN_A_APROBAR.BajaRol", cn))
         {
             cn.Open();
             cmd.CommandType = CommandType.StoredProcedure;
             DataRowView drv         = (DataRowView)comboBox1.SelectedItem;
             Int32       valueOfItem = Convert.ToInt32(drv["IdRol"]);
             cmd.Parameters.Add("@IdRol", SqlDbType.Int).Value = valueOfItem;
             cmd.ExecuteNonQuery();
             MessageBox.Show("Rol dado de baja exitosamente");
             cn.Close();
             cn.Dispose();
             MenuRol form = new MenuRol();
             form.StartPosition = FormStartPosition.CenterScreen;
             form.Show();
             this.Dispose();
         }
     }
 }