Exemple #1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            string Permisos = "";

            if (!string.IsNullOrEmpty(txtCodigoRol.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }

            if (!string.IsNullOrEmpty(txtNombreRol.Text) == false)
            {
                MessageBox.Show("Llene el nombre del rol");
                return;
            }
            if (int.Parse(txtCodigoRol.Text) == 1)
            {
                MessageBox.Show("No puede modificar el administrador");
            }
            else
            {
                if (chkPacientes.Checked)
                {
                    Permisos = (Permisos + "A");
                }
                if (chkEmpleados.Checked)
                {
                    Permisos = (Permisos + "B");
                }
                if (chkUsuarios.Checked)
                {
                    Permisos = (Permisos + "C");
                }
                if (chkFacturacion.Checked)
                {
                    Permisos = (Permisos + "D");
                }
                if (chkInventario.Checked)
                {
                    Permisos = (Permisos + "E");
                }
                if (chkDocumentos.Checked)
                {
                    Permisos = (Permisos + "F");
                }
                if (chkMantenimientos.Checked)
                {
                    Permisos = (Permisos + "G");
                }


                String estado;
                if (cmbestado.Text == "Activo")
                {
                    estado = "ACT";
                }

                else
                {
                    estado = "DSC";
                }

                int x = Base_de_datos.Actualizar_Rol(int.Parse(txtCodigoRol.Text), txtNombreRol.Text.ToUpper(), Permisos, estado);
                if (x == 1)
                {
                    MessageBox.Show("Rol modificado.");

                    Base_de_datos busc = new Base_de_datos();
                    busc.BuscarRoles();
                    dataGridView1.DataSource = busc.Mostrar_Resultados();

                    txtCodigoRol.Clear();
                    txtNombreRol.Clear();

                    btnModificar.Enabled = false;
                    this.Hide();
                }
                else
                {
                    txtCodigoRol.Clear();
                    txtNombreRol.Clear();
                    chkDocumentos.Checked     = false;
                    chkEmpleados.Checked      = false;
                    chkFacturacion.Checked    = false;
                    chkInventario.Checked     = false;
                    chkMantenimientos.Checked = false;
                    chkPacientes.Checked      = false;
                    chkUsuarios.Checked       = false;
                }
            }
        }