示例#1
0
        private void button_modificarRol_Click(object sender, EventArgs e)
        {
            try
            {
                //Obtengo items elegidos y convierto a strings
                List <string> funcionalidades_elegidas = new List <string>();
                var           objects = checkedListBox_Funcionalidades.CheckedItems;
                if (objects.Count <= 0)
                {
                    throw new Exception("No hay Funcionalidades Elegidas");
                }

                foreach (var item in objects)
                {
                    string fun = Convert.ToString(item);
                    funcionalidades_elegidas.Add(fun);
                    //MessageBox.Show(fun, "Modificar Rol", MessageBoxButtons.OK, MessageBoxIcon.None);
                }

                var funcs_por_agregar = funcionalidades_por_agregar(funcionalidades_elegidas);
                foreach (string func in funcs_por_agregar)
                {
                    BD_Roles.insertar_funcionalidad(id_rol, func);
                }

                var funcs_por_quitar = funcionalidades_por_quitar(funcionalidades_elegidas);
                foreach (string func in funcs_por_quitar)
                {
                    BD_Roles.quitar_funcionalidad(id_rol, func);
                }


                bool estado = this.checkBox_rolHabilitado.Checked;
                BD_Roles.setear_habilitacion(id_rol, estado);

                MessageBox.Show("Rol Modificado con Exito", "Modificar Rol", MessageBoxButtons.OK, MessageBoxIcon.Information);
                button_limpiar_Click(null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al Modificar el Rol: " + ex.Message, "Modificar Rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void button_busqueda_Click(object sender, EventArgs e)
        {
            try
            {
                resetear_botones();


                this.nombreRol = comboBox_rol.Text.Trim();
                if (String.IsNullOrEmpty(nombreRol))
                {
                    throw new Exception("Nombre Vacio");
                }

                id_rol = BD_Roles.obtenerID_rol(nombreRol);

                funcionalidades_del_rol = BD_Roles.obtener_funcionalidades_rol(id_rol);

                foreach (string func in funcionalidades_del_rol)
                {
                    checkedListBox_Funcionalidades.Items.Add(func, true);
                }

                //Agrego los sin Seleccionar para el Rol
                var sinSeleccionar = funcionalidadesSinSeleccionar();
                foreach (string func in sinSeleccionar)
                {
                    checkedListBox_Funcionalidades.Items.Add(func, false);
                }

                this.checkBox_rolHabilitado.Checked = BD_Roles.obtener_estado_habilitado_rol(id_rol);

                this.label3.Text = "ID Rol: " + id_rol.ToString();
                this.checkedListBox_Funcionalidades.Enabled = true;
                this.checkBox_rolHabilitado.Enabled         = true;
                this.button_modificarRol.Enabled            = true;
            }
            catch (Exception ex)
            {
                resetear_botones();
                MessageBox.Show("Error al Busca el Rol: " + ex.Message, "Modificar Rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string nombre_rol = textBox_nombre_rol.Text.Trim();
                if (String.IsNullOrEmpty(nombre_rol))
                {
                    throw new Exception("Nombre de Rol Vacio");
                }

                //Obtengo items elegidos y convierto a strings
                List <string> funcionalidades_elegidas = new List <string>();
                var           objects = checkBox_funcionalidades.CheckedItems;
                if (objects.Count <= 0)
                {
                    throw new Exception("No hay Funcionalidades Elegidas");
                }

                foreach (var item in objects)
                {
                    string fun = Convert.ToString(item);
                    funcionalidades_elegidas.Add(fun);
                    //MessageBox.Show(fun, "Crear Rol", MessageBoxButtons.OK, MessageBoxIcon.None);
                }

                BD_Roles.crear_rol(nombre_rol, funcionalidades_elegidas);

                MessageBox.Show("Rol Creado con Exito", "Crear Rol", MessageBoxButtons.OK, MessageBoxIcon.None);

                button_limpiar_Click(null, null);
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;
                if (mensaje.ToUpper().Contains("DUPLIC") && mensaje.ToUpper().Contains("KFC.ROLES"))
                {
                    mensaje = "Rol Duplicado. Ya existe un Rol con ese nombre";
                }

                MessageBox.Show("Error al Crear Rol: " + mensaje, "Crear Rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void ModificarRol_Load(object sender, EventArgs e)
        {
            try
            {
                id_rol    = 0;
                nombreRol = null;
                funcionalidades_del_rol  = new List <string>();
                funcionalidades_posibles = InteraccionDB.obtener_todas_funcionalidades();

                var lista = BD_Roles.obtener_roles();
                ComboData.llenarCombo(this.comboBox_rol, lista);
                this.comboBox_rol.DropDownStyle = ComboBoxStyle.DropDownList;

                resetear_botones();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al Cargar Ventana:" + ex.Message, "Modificar Rol", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            deshabilitar_componentes();
            this.AcceptButton = boton_loguear;

            Configuracion_Global.cargar_archivo_configuracion();
            label_fecha.Text = "Fecha Actual: " + Configuracion_Global.fecha_actual;

            try
            {
                var lista = BD_Roles.obtener_roles();
                ComboData.llenarCombo(this.comboBox_rol, lista);
                this.comboBox_rol.DropDownStyle = ComboBoxStyle.DropDownList;
                this.comboBox_rol.Text          = "ADMINISTRADOR GENERAL";
            }
            catch (Exception ex)
            {
                InteraccionDB.ImprimirExcepcion(ex);
                MessageBox.Show("Error al Pedir Roles contra la Base. Compruebe que la Base de Datos este Poblada. " + ex.Message, "Log_In", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Lista_Estudiante ListaEstudiantes = Lista_Estudiante.Instance();
        // Co_Gestion_Estudiantes Controladora_Estudiantes = new Co_Gestion_Estudiantes();

        public void Agregar(string mail, string dni, string nombre, string telefono, InstitucionEducativa institucion)
        {
            Estudiante oEstudiante = new Estudiante(mail, dni, dni, nombre, mail, telefono, "", DateTime.Today, false, BD_Roles.Instance().Buscar_por_Nombre("estudiante"), institucion);

            estudiantes.Agregar(oEstudiante);
        }