Exemple #1
0
        private void CargarPrivilegiosDelUsuario()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                ModuloInterfazUsuariosEN oRegistroEN = new ModuloInterfazUsuariosEN();
                ModuloInterfazUsuariosLN oRegistroLN = new ModuloInterfazUsuariosLN();

                oRegistroEN.oUsuarioEN.idUsuario = Program.oLoginEN.idUsuario;

                if (oRegistroLN.ListadoPrivilegiosDelUsuariosPorModulo(oRegistroEN, Program.oDatosDeConexion))
                {
                    //PRIVILEGIOS A BARRA DE MENÚS
                    foreach (ToolStripMenuItem item in this.menuStrip.Items)
                    {
                        if (item.Tag != null)
                        {
                            if (item.Tag.ToString().Trim().Length > 0)
                            {
                                //item.Enabled = oRegistroLN.VerificarSiTengoAcceso(item.Tag.ToString());
                                if (item.DropDownItems.Count > 0)
                                {
                                    foreach (ToolStripItem Subitem in item.DropDownItems)
                                    {
                                        if (Subitem.GetType() == typeof(ToolStripMenuItem))
                                        {
                                            if (Subitem.Tag != null)
                                            {
                                                if (Subitem.Tag.ToString().Length > 0)
                                                {
                                                    Subitem.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz(Subitem.Tag.ToString());
                                                }
                                            }
                                            else
                                            {
                                                Subitem.Enabled = false;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    foreach (ToolStripItem item in tsMenu.Items)
                    {
                        if (item.Tag != null)
                        {
                            if (item.GetType() == typeof(ToolStripButton))
                            {
                                item.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz(item.Tag.ToString());
                            }
                        }
                        else
                        {
                            item.Enabled = false;
                        }
                    }
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }


                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Verificacion de Privilegios del Usuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }
Exemple #2
0
        private void CargarPrivilegiosDelUsuario()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                ModuloInterfazUsuarioEN oRegistroEN = new ModuloInterfazUsuarioEN();
                ModuloInterfazUsuarioLN oRegistroLN = new ModuloInterfazUsuarioLN();

                oRegistroEN.oUsuarioEN.IdUsuario = Program.oLoginEN.IdUsuario;

                if (oRegistroLN.ListadoPrivilegiosDelUsuariosPorModulo(oRegistroEN, Program.oDatosDeConexioEN))
                {
                    //PRIVILEGIOS A BARRA DE MENÚS
                    foreach (ToolStripMenuItem item in this.menuStrip.Items)
                    {
                        if (item.Tag != null)
                        {
                            if (item.Tag.ToString().Trim().Length > 0)
                            {
                                //item.Enabled = oRegistroLN.VerificarSiTengoAcceso(item.Tag.ToString());
                                if (item.DropDownItems.Count > 0)
                                {
                                    foreach (ToolStripItem Subitem in item.DropDownItems)
                                    {
                                        if (Subitem.GetType() == typeof(ToolStripMenuItem))
                                        {
                                            if (Subitem.Tag != null)
                                            {
                                                if (Subitem.Tag.ToString().Length > 0)
                                                {
                                                    Subitem.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz(Subitem.Tag.ToString());
                                                }
                                            }
                                            else
                                            {
                                                Subitem.Enabled = false;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    /*foreach (ToolStripItem item in tsMenu.Items)
                     * {
                     *  if (item.Tag != null)
                     *  {
                     *      if (item.GetType() == typeof(ToolStripButton))
                     *      {
                     *          item.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz(item.Tag.ToString());
                     *      }
                     *  }
                     *  else {
                     *      item.Enabled = false;
                     *  }
                     * }*/

                    foreach (Control item in splitContainer1.Panel2.Controls)
                    {
                        if (item.GetType() == typeof(System.Windows.Forms.Button))
                        {
                            Button btn = (Button)item;
                            if (btn.Tag != null)
                            {
                                if (btn.Tag.ToString() == "Débitos" || btn.Tag.ToString() == "Créditos")
                                {
                                    btn.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz("Movimientos");
                                }
                                else
                                {
                                    if (btn.Tag.ToString() == "Reportes del Historico")
                                    {
                                        btn.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz("Reportes");
                                    }
                                    else
                                    {
                                        btn.Enabled = oRegistroLN.VerificarSiTengoAccesoDeInterfaz(btn.Tag.ToString().Trim());
                                    }
                                }
                            }
                            else
                            {
                                btn.Enabled = false;
                            }
                        }
                    }
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }


                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Verificacion de Privilegios del Usuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }