Exemple #1
0
 private void ExtraerPropiedadesRoles()
 {
     Services.OperacionesRoles OR = new Services.OperacionesRoles();
     try
     {
         if (cbRoles.SelectedIndex >= 0)
         {
             List <DataRepository.PropiedadesRol> miLista = new List <DataRepository.PropiedadesRol>();
             idSeguridad = cbRoles.SelectedValue.ToString();
             foreach (var item in OR.PopularLista(int.Parse(idSeguridad)))
             {
                 lstpermisos.Items.Add(item);
             }
             SelecionarCheck();
             miLista             = OR.ConsultarRol(int.Parse(idSeguridad));
             txtNombre.Text      = miLista[0].Rol;
             txtDescripcion.Text = miLista[1].Descripcion;
         }
         else
         {
             txtNombre.Clear();
             txtDescripcion.Clear();
         }
     }
     catch (FormatException ex)
     {
     }
 }
Exemple #2
0
        public void SelecionarCheck()
        {
            Services.OperacionesRoles m = new Services.OperacionesRoles();


            if (lstpermisos.Items.Count > 0)
            {
                foreach (var item2 in m.PopularLista(int.Parse(cbRoles.SelectedValue.ToString())))
                {
                    if (item2.ToString() == chkcargos.Text)
                    {
                        chkcargos.Checked = true;
                    }
                    if (item2.ToString() == chkclientesProveedores.Text)
                    {
                        chkclientesProveedores.Checked = true;
                    }
                    if (item2.ToString() == chkcompras.Text)
                    {
                        chkcompras.Checked = true;
                    }
                    if (item2.ToString() == chkempleados.Text)
                    {
                        chkempleados.Checked = true;
                    }
                    if (item2.ToString() == chkimpuestos.Text)
                    {
                        chkimpuestos.Checked = true;
                    }
                    if (item2.ToString() == chkinventario.Text)
                    {
                        chkinventario.Checked = true;
                    }
                    if (item2.ToString() == chkroles.Text)
                    {
                        chkroles.Checked = true;
                    }
                    if (item2.ToString() == chksucursales.Text)
                    {
                        chksucursales.Checked = true;
                    }
                    if (item2.ToString() == chkusuario.Text)
                    {
                        chkusuario.Checked = true;
                    }
                    if (item2.ToString() == chkventas.Text)
                    {
                        chkventas.Checked = true;
                    }
                    if (item2.ToString() == chkDevoluciones.Text)
                    {
                        chkDevoluciones.Checked = true;
                    }
                    if (item2.ToString() == chklistar.Text)
                    {
                        chklistar.Checked = true;
                    }
                }
            }
        }
Exemple #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Any() && txtDescripcion.Text.Any() && lstpermisos.Items.Count > 0)
            {
                DataRepository.PropiedadesRol PR = new DataRepository.PropiedadesRol();
                Services.OperacionesRoles     OR = new Services.OperacionesRoles();

                PR.Rol         = txtNombre.Text.ToString();
                PR.Descripcion = txtDescripcion.Text.ToString();
                OR.InsertarRol(PR);
                int id;
                id = OR.ObtenerIdRol(txtNombre.Text.ToString());
                foreach (var item in lstpermisos.Items)
                {
                    OR.AgregarPermisos(id, item.ToString());
                }
                chkselecionar.Text = "Seleccionar todo";
                txtNombre.Clear();
                txtDescripcion.Clear();
                chkselecionar.Checked = false;
                lstpermisos.Items.Clear();
                selecionarFalse();
                txtNombre.Focus();
            }
            else
            {
                MessageBox.Show("Debe de ingresar datos para poder guardar.");
                txtNombre.Focus();
            }
        }
Exemple #4
0
        public void ValidacionPermisos(int id)
        {
            Services.OperacionesRoles OR = new Services.OperacionesRoles();


            foreach (var item in OR.ComprobarRoles(id))
            {
                if (item.ToString() == "Inventario")
                {
                    inventarioToolStripMenuItem.Enabled = true;
                }
                if (item.ToString() == "Nueva venta")
                {
                    nuevaVentaToolStripMenuItem1.Enabled = true;
                }
                if (item.ToString() == "Nueva compra")
                {
                    nuevaCompraToolStripMenuItem1.Enabled = true;
                    Popularmensaje();
                }
                if (item.ToString() == "Clientes/Proveedores")
                {
                    balanceGeneralToolStripMenuItem.Enabled = true;
                }
                if (item.ToString() == "Empleados")
                {
                    toolStripMenuItem5.Enabled = true;
                }
                if (item.ToString() == "Usuarios")
                {
                    toolStripMenuItem1.Enabled = true;
                }
                if (item.ToString() == "Cargos")
                {
                    toolStripMenuItem12.Enabled = true;
                }
                if (item.ToString() == "Impuestos")
                {
                    toolStripMenuItem15.Enabled = true;
                }
                if (item.ToString() == "Roles")
                {
                    toolStripMenuItem9.Enabled = true;
                }
                if (item.ToString() == "Sucursales")
                {
                    estadoDeResultadosToolStripMenuItem.Enabled = true;
                }
                if (item.ToString() == "Devolución")
                {
                    devoluciónToolStripMenuItem.Enabled = true;
                }
                if (item.ToString() == "Listar ordenes")
                {
                    listarOrdenesToolStripMenuItem1.Enabled = true;
                }
            }
        }
Exemple #5
0
        private void PopularRol()
        {
            ComboBox cbP = new ComboBox();

            Services.OperacionesRoles     OR = new Services.OperacionesRoles();
            DataRepository.PropiedadesRol PR = new DataRepository.PropiedadesRol();
            cbRoles.DataSource    = OR.ConsultarRoles();
            cbRoles.DisplayMember = "Rol";
            cbRoles.ValueMember   = "IdSeguridad";
        }
Exemple #6
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Any() && txtDescripcion.Text.Any() && lstpermisos.Items.Count > 0)
            {
                id = int.Parse(idSeguridad);
                DataRepository.PropiedadesRol PR = new DataRepository.PropiedadesRol();
                Services.OperacionesRoles     OR = new Services.OperacionesRoles();
                PR.Rol         = txtNombre.Text.ToString();
                PR.Descripcion = txtDescripcion.Text.ToString();
                OR.ModificarRol(PR, id);
                int id2;
                id2 = OR.ObtenerIdRol(txtNombre.Text.ToString());

                foreach (var item in OR.PopularLista(id2))
                {
                    OR.QuitarPermisos(id2, item.ToString());
                }
                foreach (var item in lstpermisos.Items)
                {
                    OR.AgregarPermisos(id2, item.ToString());
                }
                MessageBox.Show("Se ha actualizado exitosamente el rol.");
                chkselecionar.Text = "Seleccionar todo";
                cbRoles.DataSource = new List <string>();
                txtNombre.Clear();
                txtDescripcion.Clear();
                chkselecionar.Checked = false;
                lstpermisos.Items.Clear();
                selecionarFalse();
                txtNombre.Focus();
            }
            else
            {
                MessageBox.Show("Debe de ingresar datos para poder modificar.");
                txtNombre.Focus();
            }
        }