Exemple #1
0
        private void buttonAgregarRol(object sender, EventArgs e)
        {
            //AGREGA EL ROL
            if (textBoxNombreRol.Text.Equals(""))
            {
                //VALIDA SI EL NOMBRE ES CORRECTO

                MessageBox.Show("El nombre no puede ser vacío");
            }
            else
            {
                if (checkedListBoxFuncionalidades.CheckedItems.Count == 0)
                //VALIDA LA CANTIDAD DE FUNCIONALIDADES ESCOGIDAS
                {
                    MessageBox.Show("Debe seleccionar al menos una funcionalidad");
                }
                else
                {
                    if (FuncionesRol.existeNombreRol(textBoxNombreRol.Text) == false)
                    {
                        //INSERTA EN LA BASE EL NUEVO ROL
                        cc.executeQuery("insert into BUGDEVELOPING.ROL (ROL_NOMBRE, ROL_HABILITACION) values ('" + textBoxNombreRol.Text + "', 1)");
                        dt = cc.executeQuery("select ROL_ID FROM BUGDEVELOPING.ROL  WHERE ( ROL_NOMBRE = '" + textBoxNombreRol.Text + "')");
                        String idRolCreado = dt.Rows[0].ItemArray[0].ToString();
                        foreach (DataRowView FilaSeleccionados in checkedListBoxFuncionalidades.CheckedItems)
                        {   //INGRESA EN LA BASE PARA LA TABLA FUN/ROL
                            String strFunCod = FilaSeleccionados["FUNCIONALIDAD_ID"].ToString();
                            cc.executeQuery("INSERT INTO BUGDEVELOPING.FUNROL (FUNCIONALIDAD_ID, ROL_ID) VALUES (" + strFunCod + "," + idRolCreado + ")");
                        }

                        MessageBox.Show("Rol Creado Exitosamente");
                    }
                    else
                    {
                        MessageBox.Show("Ya existe un rol con ese nombre");
                    }
                }
            }
        }
Exemple #2
0
        private void FormModifRol_Load(object sender, EventArgs e)
        {
            txtbNOMBRE.Text = RolNombre;
            //SETEA PARAMETROS DE ROL ACTIVO O INACTIVO
            if (RolActivo == "True")
            {
                cbActivo.Text = "Activo";
            }
            else
            {
                cbActivo.Text = "Desactivado";
            }

            //MUESTRA EL CONTEXTO ACTUAL DE FUNCIONALIDAD POR ROL

            ConnectorClass con = ConnectorClass.Instance;
            DataTable      dt  = con.executeQuery("select FUNCIONALIDAD_ID, FUNCIONALIDAD_NOMBRE from BUGDEVELOPING.FUNCIONALIDAD order by FUNCIONALIDAD_NOMBRE");

            clbFuncionalidades.DataSource    = dt;
            clbFuncionalidades.DisplayMember = "FUNCIONALIDAD_NOMBRE";
            clbFuncionalidades.ValueMember   = "FUNCIONALIDAD_ID";

            bool   Existe;
            String CodFun;

            TotFunc = Convert.ToInt16(clbFuncionalidades.Items.Count.ToString());

            for (int i = 0; i < TotFunc; i++)
            {
                CodFun = dt.Rows[i].ItemArray[0].ToString();
                Existe = FuncionesRol.existeFunEnRol(RolCodigo, CodFun);
                if (Existe)
                {
                    //ACTIVA EL CHECKBOX PARA LAS QUE YA ESTAN SETEADAS
                    clbFuncionalidades.SetItemChecked(i, true);
                }
            }
        }
Exemple #3
0
        private void buttonMODIFICAR_Click(object sender, EventArgs e)
        {
            if (clbFuncionalidades.CheckedItems.Count == 0)
            {
                MessageBox.Show("Debe seleccionar al menos una funcionalidad", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (txtbNOMBRE.Text == "")
                {
                    MessageBox.Show("El rol debe tener un nombre", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (txtbNOMBRE.Text.Contains('%') || txtbNOMBRE.Text.Contains('$') ||
                        txtbNOMBRE.Text.Contains('&') || txtbNOMBRE.Text.Contains('!') ||
                        txtbNOMBRE.Text.Contains('?') || txtbNOMBRE.Text.Contains('/') ||
                        txtbNOMBRE.Text.Contains('¿') || txtbNOMBRE.Text.Contains('&') ||
                        txtbNOMBRE.Text.Contains(')') || txtbNOMBRE.Text.Contains('(') ||
                        txtbNOMBRE.Text.Contains('¡') || txtbNOMBRE.Text.Contains('#') ||
                        txtbNOMBRE.Text.Contains('*') || txtbNOMBRE.Text.Contains('}') ||
                        txtbNOMBRE.Text.Contains('{'))
                    {
                        MessageBox.Show("Ha elegido un nombre de rol inválido");
                    }
                    else
                    {
                        //Si no cambió el nombre
                        bool ModificarOk;
                        //Hay que verificar si cambió el nombre del rol
                        if (txtbNOMBRE.Text == RolNombre)
                        {
                            ModificarOk = true;
                        }
                        //Si lo cambió hay que verificar que el nombre no esté repetido en la base
                        //sin contar al que tenía antes de cambiarlo
                        else
                        {
                            if (FuncionesRol.existeNombreRol(txtbNOMBRE.Text) == false)
                            {
                                ModificarOk = true;
                            }
                            else
                            {
                                ModificarOk = false;
                            }
                        }

                        //Si es true es porque, o bien, no cambió el nombre, o lo cambió y no estaba en la base
                        if (ModificarOk == true)
                        {
                            if (cbActivo.Text == "Activo")
                            {
                                RolActivo = "1";
                            }
                            else
                            {
                                RolActivo = "0";
                                //Se quita todos el Rol a los Usuarios que lo tengan
                                FuncionesRol.borrarRolXUsuario(RolCodigo);
                            }
                            RolNombre = txtbNOMBRE.Text;

                            FuncionesRol.modificarNombreYHabilitacion(RolCodigo, RolNombre, RolActivo);

                            /**Borra todos las funcionalidades asociadas al rol**/
                            FuncionesRol.borrarFuncionalidades(RolCodigo);

                            /**Inserta todas las funcionalidades clickeadas relacionandalas con el rol **/
                            foreach (DataRowView FilaSeleccionados in clbFuncionalidades.CheckedItems)
                            {
                                String strFunCod = FilaSeleccionados["FUNCIONALIDAD_ID"].ToString();
                                FuncionesRol.InsertarFuncionalidades(RolCodigo, strFunCod);
                            }



                            MessageBox.Show("Rol actualizado con éxito", "Actualización de Rol", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            abm.reRenderAfterMod();
                            this.Close();
                        }
                        //Se le avisa al usuario que el nombre del rol ya existe
                        else
                        {
                            MessageBox.Show("El nombre de rol ya existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }