コード例 #1
0
 private void BtnAplicar_Click(object sender, EventArgs e)
 {
     try
     {
         if ((int?)cboPerfil.SelectedValue > 0)
         {
             bool Exclusao = new GRUPO_ACESSO_BLL().Excluir((int)cboPerfil.SelectedValue);
             if (Exclusao)
             {
                 int ID_PERFIL = (int)cboPerfil.SelectedValue;
                 foreach (TreeNode itens in trwTelasSelecionadas.Nodes[0].Nodes)
                 {
                     if (lista_telas.Exists(x => x.ID == Convert.ToInt32(itens.Tag)))
                     {
                         SYS_MENU_DTO     tela = lista_telas.First(x => x.ID == Convert.ToInt32(itens.Tag));
                         GRUPO_ACESSO_DTO DTO  = new GRUPO_ACESSO_DTO();
                         DTO.ID_PERFIL   = ID_PERFIL;
                         DTO.ID_SYS_MENU = tela.ID;
                         new GRUPO_ACESSO_BLL().Inserir(DTO);
                     }
                 }
             }
             cboPerfil.SelectedIndex = -1;
             tssMSG.Text             = "Permissões alteradas";
             tssMSG.Visible          = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro do sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        public GRUPO_ACESSO_DTO Listar(int ID_PERFIL)
        {
            using (SqlConnection cn = new SqlConnection(strConnection))
            {
                GRUPO_ACESSO_DTO list = new GRUPO_ACESSO_DTO();

                try
                {
                    SqlDataReader dr = null;

                    StringBuilder SQL_ = new StringBuilder();

                    SQL_.Append("select ");
                    SQL_.Append("X.ID,  ");
                    SQL_.Append("X.ID_SYS_MENU, ");
                    SQL_.Append("A.DESCRICAO, ");
                    SQL_.Append("A.NAME, ");
                    SQL_.Append("A.ID AS ID_SYS_MENU ");
                    SQL_.Append("from ");
                    SQL_.Append("GRUPO_ACESSO X ");
                    SQL_.Append("LEFT JOIN SYS_MENU A ");
                    SQL_.Append("ON ");
                    SQL_.Append("X.ID_SYS_MENU = A.ID ");
                    SQL_.Append("WHERE ");
                    SQL_.Append("ID_PERFIL = @ID_PERFIL ");
                    cn.Open();

                    SqlCommand cmd = new SqlCommand(SQL_.ToString(), cn);
                    cmd.Parameters.AddWithValue("@ID_PERFIL", ID_PERFIL);
                    dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        SYS_MENU_DTO menu = new SYS_MENU_DTO();
                        menu.ID        = Convert.ToInt32(dr["ID_SYS_MENU"]);
                        menu.DESCRICAO = Convert.ToString(dr["DESCRICAO"]);
                        menu.NAME      = Convert.ToString(dr["NAME"]);
                        list.SYS_MENU.Add(menu);
                    }

                    return(list);
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    cn.Close();
                }
            }
        }
コード例 #3
0
        public List <SYS_MENU_DTO> Listar()
        {
            using (SqlConnection cn = new SqlConnection(strConnection))
            {
                List <SYS_MENU_DTO> SYS_PERFIL = new List <SYS_MENU_DTO>();

                try
                {
                    SqlDataReader dr = null;

                    StringBuilder SQL_ = new StringBuilder();

                    SQL_.Append("SELECT ");
                    SQL_.Append("* ");
                    SQL_.Append("FROM ");
                    SQL_.Append("SYS_MENU ");
                    cn.Open();

                    SqlCommand cmd = new SqlCommand(SQL_.ToString(), cn);
                    dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        SYS_MENU_DTO DTO = new SYS_MENU_DTO();
                        DTO.ID        = Convert.ToInt32(dr["ID"]);
                        DTO.DESCRICAO = dr["DESCRICAO"].ToString();
                        DTO.NAME      = dr["NAME"].ToString();
                        SYS_PERFIL.Add(DTO);
                    }

                    return(SYS_PERFIL);
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    cn.Close();
                }
            }
        }