Ejemplo n.º 1
0
        private void btn_aceptar_mod_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != rolmod.rol_nombre || txtNombre.Text.Length == 0)
            {
                var cant = runner.Single("SELECT COUNT(*) as cant FROM SIGKILL.rol WHERE rol_nombre='{0}'", txtNombre.Text);
                if (txtNombre.Text.Length == 0 || (int)cant["cant"] == 1)
                {
                    MessageBox.Show("No ingresaste el nombre o el nombre ya existe");
                    return;
                }
            }

            runner.Delete("DELETE FROM SIGKILL.func_rol WHERE frol_rol={0}", rolmod.rol_id);
            int hab = 0;

            if (chk_habilitado.Checked)
            {
                hab = 1;
            }
            runner.Update("UPDATE SIGKILL.rol SET rol_nombre='{0}', rol_habilitado={1} WHERE rol_id={2}", txtNombre.Text, hab.ToString(), rolmod.rol_id);
            foreach (var f in checkedListBox1.CheckedItems)
            {
                runner.Insert("INSERT INTO SIGKILL.func_rol(frol_rol,frol_funcionalidad) VALUES ({0},{1})", rolmod.rol_id.ToString(), (checkedListBox1.Items.IndexOf(f) + 1).ToString());
            }
            MessageBox.Show("Rol modificado Correctamente");
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var cell = dataGridView1.Rows[e.RowIndex];

            //MessageBox.Show("Se clickeo " + cell.Cells[0].Value.ToString());
            if (tipo == 1)
            {
                var res = runner.Single("SELECT * FROM SIGKILL.rol WHERE rol_id={0}", cell.Cells[0].Value.ToString());
                Rol rol = new Adapter().Transform <Rol>(res);
                new frmRolAltaMod(rol).Show();
                this.Close();
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("¿Quieres eliminar el rol " + cell.Cells[1].Value.ToString() + "?", "Eliminar Rol", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    runner.Delete("DELETE FROM SIGKILL.func_rol WHERE frol_rol={0}", cell.Cells[0].Value);
                    runner.Delete("DELETE FROM SIGKILL.rol WHERE rol_id={0}", cell.Cells[0].Value);
                    MessageBox.Show("Se ha eliminado correctamente el Rol");
                    button1_Click(new object(), new EventArgs());
                }
            }
        }