public PermissaoFormularioDTO Inserir(PermissaoFormularioDTO dto) { try { BaseDados.ComandText = "stp_SIS_UTILIZADOR_PERMISSAO_FORMULARIO_NOVO"; BaseDados.AddParameter("@FORMULARIO", dto.Formulario.Codigo); BaseDados.AddParameter("@UTILIZADOR", dto.Utilizador); BaseDados.AddParameter("@INCLUSAO", dto.AllowInsert); BaseDados.AddParameter("@ALTERACAO", dto.AllowUpdate); BaseDados.AddParameter("@.AllowDelete", dto.AllowDelete); BaseDados.AddParameter("@CONSULTA", dto.AllowSelect); BaseDados.AddParameter("@IMPRESSAO", dto.AllowPrint); BaseDados.AddParameter("@ACESSO", dto.AllowAccess); BaseDados.ExecuteNonQuery(); dto.Sucesso = true; } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } return(dto); }
// Método que Dá AllowAccess aos Modulos e Formulários para um Perfil public void AtribuirAllowAccessPerfil(PerfilDTO perfil, List <PermissaoFormularioDTO> permissoes) { int tag = 0; foreach (PermissaoFormularioDTO permissao in permissoes) { if (permissao.AllowAccess == 1) { if (tag != permissao.Formulario.TAG) { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); foreach (FormularioDTO subMenu in FormularioRN.GetInstance().ObterFormulariosSubModulo()) { if (subMenu.TAG == permissao.Formulario.TAG) { dto.Formulario = subMenu; dto.AllowAccess = 1; dto.Perfil = perfil; daoPermissaoFormulario.Excluir(dto); daoPermissaoFormulario.Inserir(dto); tag = permissao.Formulario.TAG; break; } } } } daoPermissaoFormulario.Excluir(permissao); daoPermissaoFormulario.Inserir(permissao); } EliminarSolitarios(null, perfil); }
public void AddPermissaoREST(PermissaoFormularioDTO dto) { try { BaseDados.ComandText = "stp_SIS_REST_FORMULARIO_PERMISSAO_ADICIONAR"; BaseDados.AddParameter("@FORMULARIO", dto.Formulario.Codigo); BaseDados.AddParameter("@PERFIL", dto.Perfil.Codigo); BaseDados.AddParameter("@INCLUSAO", dto.AllowInsert); BaseDados.AddParameter("@ALTERACAO", dto.AllowUpdate); BaseDados.AddParameter("@EXCLUSAO", dto.AllowDelete); BaseDados.AddParameter("@CONSULTA", dto.AllowSelect); BaseDados.AddParameter("@IMPRESSAO", dto.AllowPrint); BaseDados.AddParameter("@ACESSO", dto.AllowAccess); BaseDados.ExecuteNonQuery(); dto.Sucesso = true; } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } }
public List <PermissaoFormularioDTO> GetUserAccess(string pUtilizador) { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); dto.Utilizador = pUtilizador; return(daoPermissaoUtilizador.ObterAcessosDoUtilizador(dto)); }
public List <PermissaoFormularioDTO> ObterPermissoesFormularioPorModulo(PermissaoFormularioDTO dto) { List <PermissaoFormularioDTO> coleccao; try { BaseDados.ComandText = "stp_SIS_UTILIZADOR_PERMISSAO_FORMULARIO_OBTERPORMODULO"; BaseDados.AddParameter("@UTILIZADOR", dto.Utilizador); BaseDados.AddParameter("@MODULO", dto.Formulario.Modulo.Codigo); MySqlDataReader dr = BaseDados.ExecuteReader(); coleccao = new List <PermissaoFormularioDTO>(); while (dr.Read()) { dto = new PermissaoFormularioDTO(); dto.AllowAccess = Int32.Parse(dr["UTI_PERM_FORM_ACESSO"].ToString()); dto.AllowUpdate = Int32.Parse(dr["UTI_PERM_FORM_ALTERAR"].ToString()); dto.AllowSelect = Int32.Parse(dr["UTI_PERM_FORM_CONSULTAR"].ToString()); dto.AllowDelete = Int32.Parse(dr["UTI_PERM_FORM_EXCLUIR"].ToString()); FormularioDTO dtoForm = new FormularioDTO(); FormularioDAO daoForm = new FormularioDAO(); dtoForm.Codigo = Int32.Parse(dr["UTI_PERM_FORM_CODIGO_FORMULARIO"].ToString()); dto.Formulario = daoForm.ObterPorPK(dtoForm); dto.TituloDocumento = dto.Formulario.ShortName; UtilizadorDAO daoUtilizador = new UtilizadorDAO(); UtilizadorDTO dtoUtilizador = new UtilizadorDTO(); dtoUtilizador.Utilizador = dr["UTI_PERM_FORM_UTILIZADOR"].ToString(); dto.AllowPrint = Int32.Parse(dr["UTI_PERM_FORM_IMPRIMIR"].ToString()); dto.AllowInsert = Int32.Parse(dr["UTI_PERM_FORM_INSERIR"].ToString()); coleccao.Add(dto); } } catch (Exception ex) { dto = new PermissaoFormularioDTO(); dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); coleccao = new List <PermissaoFormularioDTO>(); coleccao.Add(dto); } finally { BaseDados.FecharConexao(); } return(coleccao); }
public List <PermissaoFormularioDTO> ObterPermissoesFormularioPorModulo(PermissaoFormularioDTO dto) { List <PermissaoFormularioDTO> coleccao; try { BaseDados.ComandText = "stp_SIS_FORMULARIO_PERMISSAO_OBTERPORMODULO"; BaseDados.AddParameter("@PERFIL", dto.Perfil.Codigo); BaseDados.AddParameter("@MODULO", dto.Formulario.Modulo.Codigo); MySqlDataReader dr = BaseDados.ExecuteReader(); coleccao = new List <PermissaoFormularioDTO>(); while (dr.Read()) { dto = new PermissaoFormularioDTO(); dto.AllowAccess = Int32.Parse(dr["FORM_PERM_ACESSO"].ToString()); dto.AllowUpdate = Int32.Parse(dr["FORM_PERM_ALTERACAO"].ToString()); dto.Codigo = Int32.Parse(dr["FORM_PERM_CODIGO"].ToString()); dto.AllowSelect = Int32.Parse(dr["FORM_PERM_CONSULTA"].ToString()); dto.AllowDelete = Int32.Parse(dr["FORM_PERM_EXCLUSAO"].ToString()); FormularioDTO dtoForm = new FormularioDTO(); FormularioDAO daoForm = new FormularioDAO(); dtoForm.Codigo = Int32.Parse(dr["FORM_PERM_CODIGO_FORMULARIO"].ToString()); dto.Formulario = daoForm.ObterPorPK(dtoForm); PerfilDAO daoPerfil = new PerfilDAO(); PerfilDTO dtoPerfil = new PerfilDTO(); dtoPerfil.Codigo = Int32.Parse(dr["FORM_PERM_CODIGO_PERFIL"].ToString()); dto.Perfil = daoPerfil.ObterPorPK(dtoPerfil); dto.AllowPrint = Int32.Parse(dr["FORM_PERM_IMPRESSAO"].ToString()); dto.AllowInsert = Int32.Parse(dr["FORM_PERM_INCLUSAO"].ToString()); coleccao.Add(dto); } } catch (Exception ex) { dto = new PermissaoFormularioDTO(); dto.MensagemErro = ex.Message.Replace("'", ""); dto.Sucesso = false; coleccao = new List <PermissaoFormularioDTO>(); coleccao.Add(dto); } finally { BaseDados.FecharConexao(); } return(coleccao); }
private void ZeraAcessos(PerfilDTO dto) { if (dto.Codigo > 0) { List <ModuloDTO> modulos = ModuloRN.GetInstance().ObterTodosModulos(); ModuloDTO dtoModulo = null; for (int i = 0; i < modulos.Count; i++) { PermissaoModuloDTO dtoPerMod = new PermissaoModuloDTO(); dtoModulo = new ModuloDTO(); dtoModulo.Codigo = modulos[i].Codigo; dtoPerMod.Modulo = dtoModulo; dto = new PerfilDTO(); dtoPerMod.Perfil = dto; dtoPerMod.Acesso = 0; dtoPerMod.Autorizar = 0; dtoPerMod.Visibilidade = 0; PermissaoModuloRN.GetInstance().Inserir(dtoPerMod); // Instancia os Formulários FormularioDTO dtoForm = new FormularioDTO(); dtoForm.Modulo = dtoModulo; // Obtem os Formulário do Módulo List <FormularioDTO> formularios = FormularioRN.GetInstance().ObterFormulariosPorModulo(dtoForm); if (formularios.Count > 0) { for (int f = 0; f < formularios.Count; f++) { PermissaoFormularioDTO dtoPermForm = new PermissaoFormularioDTO(); dtoForm = new FormularioDTO(); dtoForm.Codigo = formularios[f].Codigo; dtoPermForm.Formulario = dtoForm; dtoPermForm.Perfil = dto; dtoPermForm.AllowAccess = 0; dtoPermForm.AllowUpdate = 0; dtoPermForm.AllowSelect = 0; dtoPermForm.AllowDelete = 0; dtoPermForm.AllowPrint = 0; dtoPermForm.AllowInsert = 0; PermissaoFormularioRN.GetInstance().InserirPermissoesFormulario(dtoPermForm); } } } } }
public Boolean TemAllowAccessAoFormulario(PermissaoFormularioDTO dto) { Boolean confirmacao = false; dto = daoPermissaoFormulario.ObterPorPK(dto); if (dto.Codigo > 0 && dto.AllowAccess == 1) { confirmacao = true; } return(confirmacao); }
public List <PermissaoFormularioDTO> ObterPermissoesFormularioREST(UtilizadorDTO objUser) { List <PermissaoFormularioDTO> coleccao = new List <PermissaoFormularioDTO>(); PermissaoFormularioDTO dto; try { BaseDados.ComandText = "stp_SIS_REST_FORMULARIO_PERMISSAO_PERFIL"; BaseDados.AddParameter("@UTILIZADOR", objUser.Utilizador); BaseDados.AddParameter("@PERFIL", objUser.Perfil.Codigo); MySqlDataReader dr = BaseDados.ExecuteReader(); while (dr.Read()) { dto = new PermissaoFormularioDTO(); dto.AllowAccess = Int32.Parse(dr["FORM_PERM_ACESSO"].ToString()); dto.AllowUpdate = Int32.Parse(dr["FORM_PERM_ALTERACAO"].ToString()); dto.Codigo = Int32.Parse(dr["FORM_PERM_CODIGO"].ToString()); dto.AllowSelect = Int32.Parse(dr["FORM_PERM_CONSULTA"].ToString()); dto.AllowDelete = Int32.Parse(dr["FORM_PERM_EXCLUSAO"].ToString()); dto.Formulario = new FormularioDTO(Int32.Parse(dr["FORM_PERM_CODIGO_FORMULARIO"].ToString()), dr["FORM_TITULO"].ToString(), dr["FORM_LINK"].ToString()); dto.Perfil = new PerfilDTO { Codigo = Int32.Parse(dr["FORM_PERM_CODIGO_PERFIL"].ToString()) }; dto.AllowPrint = Int32.Parse(dr["FORM_PERM_IMPRESSAO"].ToString()); dto.AllowInsert = Int32.Parse(dr["FORM_PERM_INCLUSAO"].ToString()); coleccao.Add(dto); } } catch (Exception ex) { dto = new PermissaoFormularioDTO(); dto.MensagemErro = ex.Message.Replace("'", ""); dto.Sucesso = false; coleccao = new List <PermissaoFormularioDTO>(); coleccao.Add(dto); } finally { BaseDados.FecharConexao(); } return(coleccao); }
public Boolean UtilizadorTemAllowAccessAoFormulario(PermissaoFormularioDTO dto) { bool confirmacao = false; PermissaoFormularioDTO dtoResultante = new PermissaoFormularioDTO(); dtoResultante = daoPermissaoUtilizador.ObterPorPK(dto); if (dtoResultante != null && dtoResultante.Utilizador == dto.Utilizador && dtoResultante.AllowAccess == 1) { confirmacao = true; } return(confirmacao); }
public Boolean SetUserAccess(UtilizadorDTO objUser, List <PermissaoFormularioDTO> Documentos) { bool sucesso = false; int tag = 0; foreach (PermissaoFormularioDTO pemissao in Documentos) { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); pemissao.Utilizador = objUser.Utilizador; FormularioDTO cabecalhoForm = FormularioRN.GetInstance().ObterPorSubModulo(pemissao.Formulario); if (pemissao.AllowAccess == 1) { if (tag != pemissao.Formulario.TAG) { dto = new PermissaoFormularioDTO(); dto.AllowAccess = 1; dto.Formulario = cabecalhoForm; dto.Utilizador = pemissao.Utilizador; ExcluirAcessoDoUtilizadorAoFormulario(dto); sucesso = daoPermissaoUtilizador.Inserir(dto).Sucesso; tag = pemissao.Formulario.TAG; } if (pemissao.Formulario.Codigo.Equals(48)) { pemissao.AllowSelect = 1; } } sucesso = true; if (sucesso) { ExcluirAcessoDoUtilizadorAoFormulario(pemissao); daoPermissaoUtilizador.Inserir(pemissao); } else { sucesso = false; break; } } EliminarSolitarios(objUser, null); return(sucesso); }
public void ExcluirTodosAcessos(PermissaoFormularioDTO dto) { try { BaseDados.ComandText = "stp_SIS_UTILIZADOR_PERMISSAO_FORMULARIO_EXCLUIR_TODOS"; BaseDados.AddParameter("@UTILIZADOR", dto.Utilizador); BaseDados.ExecuteNonQuery(); } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } }
public List <PermissaoFormularioDTO> ObterFormulariosPOS() { List <PermissaoFormularioDTO> coleccao = new List <PermissaoFormularioDTO>(); PermissaoFormularioDTO dto; try { BaseDados.ComandText = "stp_SIS_POS_FORMULARIOS_POS"; MySqlDataReader dr = BaseDados.ExecuteReader(); while (dr.Read()) { dto = new PermissaoFormularioDTO(); dto.AllowAccess = Int32.Parse(dr["FORM_PERM_ACESSO"].ToString()); dto.AllowUpdate = Int32.Parse(dr["FORM_PERM_ALTERACAO"].ToString()); //dto.FormPermCodigo = Int32.Parse(dr["FORM_PERM_CODIGO"].ToString()); dto.AllowSelect = Int32.Parse(dr["FORM_PERM_CONSULTA"].ToString()); dto.AllowDelete = Int32.Parse(dr["FORM_PERM_EXCLUSAO"].ToString()); dto.Formulario = new FormularioDTO(Int32.Parse(dr["POS_FORM_CODIGO"].ToString()), dr["FORM_TITULO"].ToString(), ""); dto.Perfil = new PerfilDTO(); dto.AllowPrint = Int32.Parse(dr["FORM_PERM_IMPRESSAO"].ToString()); dto.AllowInsert = Int32.Parse(dr["FORM_PERM_INCLUSAO"].ToString()); coleccao.Add(dto); } } catch (Exception ex) { dto = new PermissaoFormularioDTO(); dto.MensagemErro = ex.Message.Replace("'", ""); dto.Sucesso = false; coleccao = new List <PermissaoFormularioDTO>(); coleccao.Add(dto); } finally { BaseDados.FecharConexao(); } return(coleccao); }
public void ExcluirDesemparelhados(PermissaoFormularioDTO dto) { try { BaseDados.ComandText = "stp_SIS_UTILIZADOR_PERMISSAO_CORRIGIR"; BaseDados.AddParameter("@UTILIZADOR", dto.Utilizador); BaseDados.AddParameter("@TAG", dto.Formulario.TAG); BaseDados.ExecuteNonQuery(); } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } }
public void ExcluirTodas(PermissaoFormularioDTO dto) { try { BaseDados.ComandText = "stp_SIS_FORMULARIO_PERMISSAO_EXCLUIR_TODOS"; BaseDados.AddParameter("@PERFIL", dto.Perfil.Codigo); BaseDados.ExecuteNonQuery(); dto.Sucesso = true; } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } }
public void AllowSysAdmin() { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); try { BaseDados.ComandText = "stp_SIS_FORMULARIO_PERMISSAO_SYSADMIN_ADICIONAR"; BaseDados.ExecuteNonQuery(); dto.Sucesso = true; } catch (Exception ex) { dto.Sucesso = false; dto.MensagemErro = ex.Message.Replace("'", ""); } finally { BaseDados.FecharConexao(); } }
public List <PermissaoFormularioDTO> ObterFormulariosDoUtilizador(PermissaoFormularioDTO dto) { List <PermissaoFormularioDTO> permissoesGerais = daoPermissaoUtilizador.ObterPermissoesFormulario(dto); List <PermissaoFormularioDTO> permissoesModulo = new List <PermissaoFormularioDTO>(); if (dto.Formulario.Modulo.Codigo > 0) { foreach (PermissaoFormularioDTO permissao in permissoesGerais) { if (dto.Formulario.Modulo.Codigo == permissao.Formulario.Modulo.Codigo) { permissoesModulo.Add(permissao); } } return(permissoesModulo); } else { return(permissoesGerais); } }
// Obtem os SubModulos do Sistema public void EliminarSolitarios(UtilizadorDTO objUtilizador, PerfilDTO objPerfil) { if (objUtilizador != null && objUtilizador.Utilizador != "") { foreach (FormularioDTO menu in FormularioRN.GetInstance().ObterFormulariosSubModulo()) { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); dto.Formulario = menu; dto.Utilizador = objUtilizador.Utilizador; daoPermissaoUtilizador.ExcluirDesemparelhados(dto); } } else if (objPerfil != null && objPerfil.Codigo > 0) { foreach (FormularioDTO menu in FormularioRN.GetInstance().ObterFormulariosSubModulo()) { PermissaoFormularioDTO dto = new PermissaoFormularioDTO(); dto.Formulario = menu; dto.Perfil = objPerfil; daoPermissaoFormulario.ExcluirSolitarios(dto); } } }
public void AtribuirPermissoesPadrao(string utilizador) { UtilizadorDTO dtoUser = new UtilizadorDTO(); dtoUser.Utilizador = utilizador; List <FormularioDTO> formularios = FormularioRN.GetInstance().ObterTodosFormularios(); List <PermissaoFormularioDTO> permissoes = new List <PermissaoFormularioDTO>(); foreach (FormularioDTO dtoForm in formularios) { PermissaoFormularioDTO dtoPermissao = new PermissaoFormularioDTO(); dtoPermissao.AllowAccess = 0; dtoPermissao.AllowUpdate = 0; dtoPermissao.AllowSelect = 0; dtoPermissao.AllowDelete = 0; dtoPermissao.Formulario = dtoForm; dtoPermissao.AllowPrint = 0; dtoPermissao.Utilizador = dtoUser.Utilizador; permissoes.Add(dtoPermissao); this.AddUserAccess(dtoPermissao); } }
public List <PermissaoFormularioDTO> ObterPermissoesFormularioPorModulo(PermissaoFormularioDTO dto) { return(daoPermissaoFormulario.ObterPermissoesFormularioPorModulo(dto)); }
public PermissaoFormularioDTO ObterAcessoDoUtilizadorAoFormularioPorPK(PermissaoFormularioDTO dto) { return(daoPermissaoUtilizador.ObterPorPK(dto)); }
public List <PermissaoFormularioDTO> ObterFormulariosDoUtilizadorNoModulo(PermissaoFormularioDTO dto) { return(daoPermissaoUtilizador.ObterPermissoesFormularioPorModulo(dto)); }
public void SavePOSAccess(PermissaoFormularioDTO dto) { daoPermissaoFormulario.AddPermissaoPOS(dto); }
public void SaveRESTAccess(PermissaoFormularioDTO dto) { daoPermissaoFormulario.AddPermissaoREST(dto); }
public PermissaoFormularioDTO ObterPermissaoPerfil(PermissaoFormularioDTO dto) { return(daoPermissaoFormulario.ObterPorPK(dto)); }
public void AddUserAccess(PermissaoFormularioDTO dto) { daoPermissaoUtilizador.Excluir(dto); daoPermissaoUtilizador.Inserir(dto); }
public void ExcluirAcessoDoUtilizadorAoFormulario(PermissaoFormularioDTO dto) { daoPermissaoUtilizador.Excluir(dto); }
public void ExcluirTodosAllowAccesssDoUtilizadorAosFormularios(PermissaoFormularioDTO dto) { daoPermissaoUtilizador.ExcluirTodosAcessos(dto); }
public void InserirPermissoesFormulario(PermissaoFormularioDTO dtoPermPerfil) { daoPermissaoFormulario.Excluir(dtoPermPerfil); daoPermissaoFormulario.Inserir(dtoPermPerfil); }