protected void btnCadastroPerfil_Click(object sender, EventArgs e) { if (ValidateField()) { try { PerfilBusiness business = new PerfilBusiness(); int idPerfil = int.Parse(txtCodigo.Text); Perfil p = business.ConsultarPerfil(idPerfil); p.Nome = txtNomePerfil.Text; p.IdPerfil = int.Parse(txtCodigo.Text); business.Atualizar(p); lblMensagem.Text = "Perfil " + p.Nome + " atualizado com sucesso."; lblMensagem.ForeColor = Color.DarkBlue; } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } } }
public ActionResult BuscarTotalDocsInbox() { int iTotal = 0; int iPessoal = 0; int iGrupos = 0; if (memoryCacheDefault.Contains(CustomAuthorizationProvider.UsuarioAutenticado.Login + "InboxTotal")) { List <int> lista = (List <int>)memoryCacheDefault[CustomAuthorizationProvider.UsuarioAutenticado.Login + "InboxTotal"]; iTotal = lista[0]; iPessoal = lista[1]; iGrupos = lista[2]; } else { List <string> perfis = (from usuarioperfil in UsuarioPerfilBusiness.Consulta.Where(p => string.IsNullOrEmpty(p.UsuarioExclusao)).ToList() join perfil in PerfilBusiness.Consulta.Where(p => string.IsNullOrEmpty(p.UsuarioExclusao)).ToList() on usuarioperfil.UKPerfil equals perfil.UniqueKey where usuarioperfil.UKUsuario.Equals(CustomAuthorizationProvider.UsuarioAutenticado.UniqueKey) select "'" + perfil.Nome + "'").ToList(); string sql = @"select 'Pessoal' as tipo, COUNT(*) as Total from OBJIncidente i where i.Responsavel in ('" + CustomAuthorizationProvider.UsuarioAutenticado.Login + @"') and i.UsuarioExclusao is null union all select 'Grupos' as tipo, COUNT(*) as Total from OBJIncidente i where i.Responsavel in (" + string.Join(",", perfis) + @") and i.UsuarioExclusao is null "; DataTable dtInbox = PerfilBusiness.GetDataTable(sql); if (dtInbox.Rows.Count > 0) { foreach (DataRow row in dtInbox.Rows) { if (row[0].ToString().Equals("Pessoal")) { iPessoal = int.Parse(row[1].ToString()); } else { iGrupos = int.Parse(row[1].ToString()); } } iTotal = iPessoal + iGrupos; } List <int> lista = new List <int>(); lista.Add(iTotal); lista.Add(iPessoal); lista.Add(iGrupos); memoryCacheDefault.Add(CustomAuthorizationProvider.UsuarioAutenticado.Login + "InboxTotal", lista, DateTime.Today.AddHours(2)); } return(Json(new { resultado = new { Total = iTotal, Pessoal = iPessoal, Grupos = iGrupos } })); }
private void CarregarPagina() { int idPerfil = int.Parse(Request.QueryString["id"]); PerfilBusiness business = new PerfilBusiness(); Perfil p = business.ConsultarPerfil(idPerfil); txtNomePerfil.Text = p.Nome; txtCodigo.Text = p.IdPerfil.ToString(); }
private void CarregarPagina() { try { PerfilBusiness business = new PerfilBusiness(); List <Perfil> lista = business.ConsultarTodos(); gridPerfis.DataSource = lista; gridPerfis.DataBind(); } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
public ActionResult Cadastrar(Perfil Perfil) { if (ModelState.IsValid) { try { //Perfil.UsuarioInclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login; Perfil.UsuarioInclusao = "Antonio"; PerfilBusiness.Inserir(Perfil); Extensions.GravaCookie("MensagemSucesso", "O perfil '" + Perfil.Nome + "' foi cadastrado com sucesso.", 10); return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Perfil") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
private void PreenchendoCadastro() { CargoBusiness business = new CargoBusiness(); List <Cargo> lista = business.ConsultarTodos(); ddlCargo.DataSource = lista; ddlCargo.DataValueField = "IdCargo"; ddlCargo.DataTextField = "Nome"; ddlCargo.DataBind(); ddlCargo.Items.Insert(0, new ListItem("- Selecione um Cargo - ", "")); PerfilBusiness pbusiness = new PerfilBusiness(); List <Perfil> todos = pbusiness.ConsultarTodos(); ddlPerfil.DataSource = todos; ddlPerfil.DataValueField = "IdPerfil"; ddlPerfil.DataTextField = "Nome"; ddlPerfil.DataBind(); ddlPerfil.Items.Insert(0, new ListItem("- Selecione um Perfil -", "")); }
public ActionResult Atualizar(Perfil Perfil) { if (ModelState.IsValid) { try { PerfilBusiness.Alterar(Perfil); Extensions.GravaCookie("MensagemSucesso", "O perfil '" + Perfil.Nome + "' foi atualizado com sucesso.", 10); return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Perfil") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
protected void btnExcluir_Click(object sender, EventArgs e) { try { PerfilBusiness business = new PerfilBusiness(); int idPerfil = int.Parse(txtCodigo.Text); Perfil p = business.ConsultarPerfil(idPerfil); p.Nome = txtNome.Text; p.IdPerfil = int.Parse(txtCodigo.Text); business.Excluir(p.IdPerfil); lblMensagem.Text = "Perfil " + p.Nome + " excluído com sucesso."; lblMensagem.ForeColor = Color.DarkBlue; btnExcluir.Enabled = false; } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
protected void btnCadastroPerfil_Click(object sender, EventArgs e) { if (ValidateField()) { try { PerfilBusiness business = new PerfilBusiness(); Perfil p = new Perfil(); p.Nome = txtNomePerfil.Text; business.Cadastrar(p); lblMensagem.Text = "Perfil " + p.Nome + " cadastrado com sucesso."; lblMensagem.ForeColor = Color.DarkBlue; txtNomePerfil.Text = string.Empty; } catch (Exception ex) { lblMensagem.Text = ex.Message; } } }
public PerfilController() { this._bus = new PerfilBusiness(); }
public TelaController() { this._bus = new TelaBusiness(); this._busperfil = new PerfilBusiness(); this._busPerfilTelaBusiness = new PerfilTelaBusiness(); }
public ActionResult CarregarInboxGrupos(string tab) { try { List <string> perfis = (from usuarioperfil in UsuarioPerfilBusiness.Consulta.Where(p => string.IsNullOrEmpty(p.UsuarioExclusao)).ToList() join perfil in PerfilBusiness.Consulta.Where(p => string.IsNullOrEmpty(p.UsuarioExclusao)).ToList() on usuarioperfil.UKPerfil equals perfil.UniqueKey where usuarioperfil.UKUsuario.Equals(CustomAuthorizationProvider.UsuarioAutenticado.UniqueKey) select "'" + perfil.Nome + "'").ToList(); switch (tab) { case "Incidentes": List <VMIncidente> lista = new List <VMIncidente>(); string sql = @"select i.UniqueKey, i.Codigo, i.DataIncidente, i.ETipoAcidente, d.Sigla, i.AcidenteFatal, i.AcidenteGraveIP102, i.Status, i.MensagemPasso from OBJIncidente i, OBJDepartamento d where i.Responsavel in (" + string.Join(",", perfis) + @") and i.UsuarioExclusao is null and i.UKOrgao = d.UniqueKey and d.UsuarioExclusao is null order by i.datainclusao desc "; DataTable dtInbox = PerfilBusiness.GetDataTable(sql); if (dtInbox.Rows.Count > 0) { foreach (DataRow row in dtInbox.Rows) { lista.Add(new VMIncidente() { UniqueKey = row[0].ToString(), Codigo = row[1].ToString(), DataIncidente = ((DateTime)row[2]).ToString("dd/MM/yyyy"), ETipoAcidente = ((ETipoAcidente)Enum.Parse(typeof(ETipoAcidente), row[3].ToString())).GetDisplayName(), Orgao = row[4].ToString(), AcidenteFatal = ((bool)row[5]) ? "Sim" : "Não", AcidenteGraveIP102 = ((bool)row[6]) ? "Sim" : "Não", Status = row[7].ToString(), MensagemPasso = row[8].ToString() }); } } return(PartialView("_ListarIncidente", lista)); case "IncidentesVeiculos": return(PartialView("_ListarIncidenteVeiculo")); case "QuaseIncidentes": return(PartialView("_ListarQuaseIncidente")); case "QuaseIncidentesVeiculos": return(PartialView("_ListarQuaseIncidenteVeiculo")); default: throw new Exception("Tab não reconhecida."); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
public UsuarioController() { this._busUsuario = new UsuarioBusiness(); this._busPerfil = new PerfilBusiness(); }
public PerfilController() { perfilBusiness = new PerfilBusiness(); bitacoraBusiness = new BitacoraBusiness(); }
public PermissaoController() { this._busTela = new TelaBusiness(); this._busPerfil = new PerfilBusiness(); this._busPerfilTela = new PerfilTelaBusiness(); }