public void Salvar(TUsuarioVO tusuariovo, Int32 usuarioLogado) { try { TLogVO log = new TLogVO(); log.Tabela = "TUsuario"; log.IDUsuario = usuarioLogado; log.Data = DateTime.Now; if (tusuariovo.IDUsuario > 0) { log.Tipo = "Alterar - " + tusuariovo.Login + "-" + tusuariovo.Senha; TUsuarioBLL.Alterar(tusuariovo); } else { log.Tipo = "Inserir - " + tusuariovo.Login; TUsuarioBLL.Inserir(tusuariovo); } TLogBLL.Inserir(log); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Usuário."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Usuário."); } }
public List <TUsuarioVO> ListarVendedorLivre(TUsuarioVO filtro, int idTitular) { try { List <TUsuarioVO> listaRetorno = TUsuarioBLL.VendedorLivre(filtro).ToList(); if (idTitular > 0) { TUsuarioVO usuario = TUsuarioBLL.ObterCodigo(idTitular); if (usuario != null) { listaRetorno.Insert(0, usuario); } TUsuarioVO usuarioEmpyt = new TUsuarioVO(); usuarioEmpyt.Nome = "Retirar Associação"; listaRetorno.Add(usuarioEmpyt); } return(listaRetorno); } catch (CABTECException) { throw new CABTECException("Erro ao Listar Vendedor Livre."); } catch (Exception) { throw new CABTECException("Erro ao Listar Vendedor Livre."); } }
public void ValidarMudarSenha(TUsuarioVO usuarioLogado, string novaSenha, string confirmaSenha) { try { if (!novaSenha.Equals(confirmaSenha)) { throw new CABTECException("A Nova Senha informada não confere!"); } if (usuarioLogado == null) { throw new CABTECException("O Usuário não foi informado!"); } usuarioLogado.Senha = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", novaSenha); TUsuarioBLL.Alterar(usuarioLogado); } catch (CABTECException) { throw new CABTECException("Erro ao Alterar Senha."); } catch (Exception) { throw new CABTECException("Erro ao Alterar Senha."); } }
public TUsuarioVO ValidarAcesso(string login, string senha) { try { TUsuarioVO usuarioLogado = TUsuarioBLL.LoginPrimeiroAcesso(login); if (usuarioLogado == null) { string password = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", senha); usuarioLogado = TUsuarioBLL.LoginSistema(login, password); if (usuarioLogado == null) { throw new CABTECException("Login ou Senha inválido!"); } } return(usuarioLogado); } catch (CABTECException) { throw new CABTECException("Login ou Senha inválido!"); } catch (Exception ex) { throw new CABTECException("Login ou Senha inválido!"); } }
public void EnvioSenha(string login) { try { if (string.IsNullOrEmpty(login)) { throw new CABTECException("Informe o Login."); } TUsuarioVO usuario = new TUsuarioVO(); usuario.Login = login; List <TUsuarioVO> usuarioLogin = TUsuarioBLL.Listar(usuario).ToList(); if (usuarioLogin.Count != 1) { throw new CABTECException("Login inválido!"); } string path = HttpContext.Current.Server.MapPath("Template\\EmailEsqueceuSenha.htm"); Random number = new Random(); int novaSenha = number.Next(10000000, 99999999); string password = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", novaSenha.ToString()); usuarioLogin[0].Senha = password; TUsuarioBLL.Alterar(usuarioLogin[0]); string html; using (var arquivoHtml = new StreamReader(path)) { html = arquivoHtml.ReadToEnd(); html = html.Replace("[LOGO]", WebConfigurationManager.AppSettings["DiretorioIMAGEM"] + @"LogoCliente.png"); html = html.Replace("[RODAPE]", WebConfigurationManager.AppSettings["DiretorioIMAGEM"] + @"sinafemail.png"); html = html.Replace("[SENHA]", novaSenha.ToString()); } var de = WebConfigurationManager.AppSettings["EmailPADRAO"]; List <string> emails = new List <string>(); emails.Add(usuarioLogin[0].Email); EnviarEmail.Enviar(de, emails, "SINAF - Nova Senha", html, new List <string>()); } catch (CABTECException) { throw new CABTECException("Erro ao Enviar Senha."); } catch (Exception) { throw new CABTECException("Erro ao Enviar Senha."); } }
public void Excluir(int IDUsuario) { try { TUsuarioBLL.Excluir(IDUsuario); } catch (CABTECException) { throw new CABTECException("Erro ao Excluir Usuário."); } catch (Exception) { throw new CABTECException("Erro ao Excluir Usuário."); } }
public List <TUsuarioVO> ListarSemAtendente(TUsuarioVO filtro) { try { List <TUsuarioVO> listaRetorno = TUsuarioBLL.ListarSemAtendimento(filtro).ToList(); return(listaRetorno); } catch (CABTECException) { throw new CABTECException("Erro ao Listar Vendedor Livre."); } catch (Exception) { throw new CABTECException("Erro ao Listar Vendedor Livre."); } }
public void AlterarSenha(TUsuarioVO usuarioLogado, string senhaAtual, string senhaNova, string senhaConfirma) { try { if (usuarioLogado == null) { throw new CABTECException("Usuário inválido!"); } if (!usuarioLogado.Senha.Equals(Criptografia.EncryptSymmetric("DESCryptoServiceProvider", senhaAtual))) { throw new CABTECException("Senha Atual inválida!"); } if (!senhaNova.Equals(senhaConfirma)) { throw new CABTECException("A Nova Senha informada não confere!"); } usuarioLogado.Senha = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", senhaNova); TUsuarioBLL.Alterar(usuarioLogado); TLogVO log = new TLogVO(); log.Tabela = "TUsuario"; log.IDUsuario = usuarioLogado.IDUsuario; log.Data = DateTime.Now; log.Tipo = "Alterar - " + usuarioLogado.Login + " - " + senhaAtual + " - " + senhaNova; TLogBLL.Inserir(log); } catch (CABTECException) { throw new CABTECException("Erro ao Alterar Senha."); } catch (Exception) { throw new CABTECException("Erro ao Alterar Senha."); } }
public List <TUsuarioVO> Listar(TUsuarioVO filtro) { try { if (filtro.IDUsuario > 0) { List <TUsuarioVO> listaRetorno = new List <TUsuarioVO>(); listaRetorno.Add(TUsuarioBLL.Obter(filtro.IDUsuario)); return(listaRetorno); } else { return(TUsuarioBLL.Listar(filtro).ToList()); } } catch (CABTECException) { throw new CABTECException("Erro ao Listar Usuário."); } catch (Exception) { throw new CABTECException("Erro ao Listar Usuário."); } }
public string AssociarColetorVendedor(string idColetorEscolhido, string idVendedorEscolhido) { try { string mensagem = string.Empty; //Dois IDs Nulos if (string.IsNullOrEmpty(idColetorEscolhido) && string.IsNullOrEmpty(idVendedorEscolhido)) { mensagem = "Não foi realizado a associação."; } if (!string.IsNullOrEmpty(idColetorEscolhido)) { TColetorVO coletorEscolhido = TColetorBLL.Obter(Convert.ToInt32(idColetorEscolhido)); //Limpar Associação if (string.IsNullOrEmpty(idVendedorEscolhido)) { coletorEscolhido.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorEscolhido); mensagem = "O Coletor: " + coletorEscolhido.NumeroSerie + " não está mais associado a nenhum Vendedor!"; } else { //Associar Coletor if (coletorEscolhido != null) { //Limpar Associação Antiga TColetorVO vendedorAntigo = TColetorBLL.ObterPorVendedor(coletorEscolhido.IDUsuarioResponsavel.GetValueOrDefault(0)); if (vendedorAntigo != null) { TUsuarioVO usuarioAntigo = TUsuarioBLL.Obter(vendedorAntigo.IDUsuarioResponsavel.Value); vendedorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(vendedorAntigo); mensagem = "O Vendedor: " + usuarioAntigo.Nome + " não está mais associado a nenhum Coletor!<br/>"; } //Limpar Associação Antiga TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { TUsuarioVO usuarioAntigo = TUsuarioBLL.Obter(coletorAntigo.IDUsuarioResponsavel.Value); coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); mensagem = "O Coletor: " + coletorAntigo.NumeroSerie + " não está mais associado a nenhum Vendedor!<br/>"; } coletorEscolhido.IDUsuarioResponsavel = Convert.ToInt32(idVendedorEscolhido); TColetorBLL.Alterar(coletorEscolhido); TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { mensagem += "O Coletor: " + coletorEscolhido.NumeroSerie + " e o Vendedor: " + usuarioAtual.Nome + " foram associados com sucesso!"; } } else { TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); } mensagem = "O Vendedor: " + usuarioAtual.Nome + " não está mais associado a nenhum Coletor!"; } } } } else { TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { mensagem = "O Vendedor: " + usuarioAtual.Nome + " não está mais associado a nenhum Coletor!"; } } } return(mensagem); } catch (CABTECException) { throw new CABTECException("Erro ao Associar Coletor e Vendedor."); } catch (Exception) { throw new CABTECException("Erro ao Associar Coletor e Vendedor."); } }