public void ObterTodosUsuariosTest()
        {
            // given
            var endereco1 = new Endereco(new Guid("1EF2F5CB-A04B-4761-3C44-08D78CC135ED"), "29500-000", "Rua nova", "123", "Casa", "Centro", "Alegre", "ES");
            var endereco2 = new Endereco(new Guid("C15854DB-F4D9-465F-F66E-08D78D5509A2"), "29500-000", "Rua velha", "123", "Casa", "Centro", "Alegre", "ES");

            var medico    = new Medico(new Guid("16E16A8D-469F-4286-A470-08D78CC0F920"), "Marcos", "123.456.789-12", "12.345.678-1", 1234567, new DateTime(1980, 2, 5), "M", "(34)98543-3241", "*****@*****.**", endereco1.IdEndereco);
            var atendente = new Atendente(new Guid("FB30E734-7278-44B0-CA72-08D79091CA61"), "Joana", new DateTime(1988, 7, 15), "F", "125.453.345-32", "15.654.342-1", "*****@*****.**", "(31)32434-3242", endereco2.IdEndereco);

            var usuarioMedico    = new Usuario(new Guid("1A7C25A0-896F-49DF-A75E-EE7DD53AECB9"), "*****@*****.**", "25d55ad283aa400af464c76d713c07ad", "Médico", medico, null);
            var usuarioAdmin     = new Usuario(new Guid("418A3CF2-A78F-4AD2-84C6-712638AD048B"), "*****@*****.**", "25d55ad283aa400af464c76d713c07ad", "Administrador", null, null);
            var usuarioAtendente = new Usuario(new Guid("3EE42C97-77B5-43B3-F5E1-08D79091CA56"), "*****@*****.**", "25d55ad283aa400af464c76d713c07ad", "Atendente", null, atendente);

            var listaUsuarios = new List <Usuario>();

            listaUsuarios.Add(usuarioMedico);
            listaUsuarios.Add(usuarioAdmin);
            listaUsuarios.Add(usuarioAtendente);

            this.usuarioRepositoryMock.Setup(u => u.ObterTodosUsuarios()).Returns(listaUsuarios);

            var usuarioService = new UsuarioService(usuarioRepositoryMock.Object, atendenteRepositoryMock.Object, medicoRepositoryMock.Object, agendamentoRepositoryMock.Object);

            // when
            var listaEncontrados = new List <UsuarioListarViewModel>(usuarioService.ObterTodosUsuarios());

            // then
            Assert.NotNull(listaEncontrados);
            Assert.True(listaEncontrados.Count == (listaUsuarios.Count - 1));
        }
Esempio n. 2
0
        // PUT api/<controller>/5
        public HttpResponseMessage Put(int id, Atendente atendente)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != atendente.Id)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(atendente).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 3
0
        internal List <Atendente> buscarAtendentesDaFilial(Filial filial)
        {
            List <Atendente> atendentes = new List <Atendente>();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM atendente ");
            sql.Append("INNER JOIN atendente_filial ON atendente.Id = atendente_filial.id_atendente ");
            sql.Append("WHERE atendente_filial.id_filial = @id");
            command.Parameters.AddWithValue("@id", filial.Id);

            command.CommandText = sql.ToString();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Atendente atendente = new Atendente();
                atendente.Id         = (Int32)reader["Id"];
                atendente.Cpf        = (String)reader["cpf"];
                atendente.Nome       = (String)reader["nome"];
                atendente.Nascimento = (DateTime)reader["nascimento"];

                atendentes.Add(atendente);
            }

            FabricaConexao.CloseConnection(conexao);

            return(atendentes);
        }
Esempio n. 4
0
        public List <Atendente> buscarAtendentesLike(string filtro)
        {
            List <Atendente> atendentes = new List <Atendente>();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM atendente WHERE nome like @filtro";
            command.Parameters.AddWithValue("filtro", "%" + filtro + "%");
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Atendente atendente = new Atendente();
                atendente.Id         = (Int32)reader["Id"];
                atendente.Cpf        = (String)reader["cpf"];
                atendente.Nome       = (String)reader["nome"];
                atendente.Nascimento = (DateTime)reader["nascimento"];

                atendentes.Add(atendente);
            }

            FabricaConexao.CloseConnection(conexao);

            return(atendentes);
        }
Esempio n. 5
0
        public void salvarAtendente(Atendente atendente)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.Connection  = this.conexao;
            if (tx != null)
            {
                command.Transaction = tx;
            }

            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO atendente(nome, cpf, nascimento)");
            sql.Append("VALUES (@nome, @cpf, @nascimento)");
            sql.Append("SELECT @@identity from atendente");
            command.CommandText = sql.ToString();
            command.Parameters.AddWithValue("@nome", atendente.Nome);
            command.Parameters.AddWithValue("@cpf", atendente.Cpf);
            command.Parameters.AddWithValue("@nascimento", atendente.Nascimento);

            decimal id = (decimal)command.ExecuteScalar();

            atendente.Id = Convert.ToInt32(id);
        }
Esempio n. 6
0
 /// <summary>
 /// Saindo atendente
 /// </summary>
 public void leaveAtendente()
 {
     temAtendente = false;
     atendente    = null;
     //GetComponent<Image>().enabled = false;
     //GetComponent<Image>().color = Color.red;
 }
Esempio n. 7
0
        public async Task AlterarAtendente()
        {
            //Arrange
            var atendente = new Atendente
            {
                Nome     = "Rodrigo",
                Email    = "*****@*****.**",
                Telefone = new Telefone
                {
                    Ddd          = 19,
                    Numero       = 998861788,
                    TipoTelefone = ETipoTelefone.Celular
                }
            };

            _atendenteRepository.Setup(r => r.Atualizar(atendente)).Returns(Task.FromResult(1));
            var atendenteService = new AtendenteService(_atendenteRepository.Object, _notificador.Object);

            //Act
            var retorno = await atendenteService.Atualizar(atendente);

            //Assert
            Assert.True(retorno);
            Assert.False(_notificador.Object.TemNotificacao());
            _atendenteRepository.Verify(r => r.Atualizar(atendente), Times.Once);
        }
Esempio n. 8
0
        internal Atendente buscarAtendenteCPF(String cpf)
        {
            Atendente atendente = new Atendente();

            SqlCommand command = new SqlCommand();

            command.Connection = this.conexao;
            if (tx != null)
            {
                command.Transaction = this.tx;
            }
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM atendente WHERE cpf = @cpf";
            command.Parameters.AddWithValue("cpf", cpf);
            SqlDataReader reader = command.ExecuteReader();

            reader.Read();

            atendente.Id         = (Int32)reader["Id"];
            atendente.Cpf        = (String)reader["cpf"];
            atendente.Nome       = (String)reader["nome"];
            atendente.Nascimento = (DateTime)reader["nascimento"];

            FabricaConexao.CloseConnection(this.conexao);

            return(atendente);
        }
Esempio n. 9
0
        internal Filial buscarFilialDoAtendente(Atendente atendente)
        {
            Filial filial = new Filial();


            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM filial ");
            sql.Append("INNER JOIN atendente_filial ON filial.Id = atendente_filial.id_filial ");
            sql.Append("WHERE id_atendente = @id");
            command.Parameters.AddWithValue("id", atendente.Id);

            command.CommandText = sql.ToString();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                filial.Id       = (Int32)reader["Id"];
                filial.Nome     = (String)reader["nome"];
                filial.Endereco = (String)reader["endereco"];
                filial.Cnpj     = (String)reader["cnpj"];

                return(filial);
            }

            return(null);
        }
        public IHttpActionResult PutAtendente(int id, Atendente atendente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != atendente.Id)
            {
                return(BadRequest());
            }

            db.Entry(atendente).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AtendenteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 11
0
        public static void CadastrarAtendente()
        {
            Atendente        atendente        = new Atendente();
            AtendenteNegocio atendenteNegocio = new AtendenteNegocio();

            //Vamos obter o ultimo codigo cadastrado e adicionar 1, já que deixar isso pro usuario é propenso a erros

            //Verificamos se existe algum atendente cadastrado, caso nao aja o FirstOrDefault ira retornar null
            if (atendenteNegocio.Listar().OrderBy(r => r.Codigo).LastOrDefault() != null)
            {
                //Vamos obter o ultimo codigo cadastrado, já que deixar isso pro usuario é propenso a erros
                atendente.Codigo = atendenteNegocio.Listar().OrderBy(r => r.Codigo).LastOrDefault().Codigo + 1;
            }
            else
            {
                //Caso seja null vamos iniciar o codigo em 1
                atendente.Codigo = 1;
            }

            //Criando um novo Atendente
            Console.Write("Digite o nome do Atendente: ");
            atendente.Nome = Console.ReadLine();

            //Adicionar o Atendente a lista de Atendentees
            atendenteNegocio.Adicionar(atendente);
        }
Esempio n. 12
0
        public Atendente Autenticar(string email, string senha)
        {
            string sql = "SELECT * FROM atendente WHERE email='" + email + "' AND senha='" + senha + "'";

            _bd.AbrirConexao();
            DataTable dt = _bd.ExecutarSelect(sql);

            _bd.FecharConexao();
            Atendente at = null;

            if (dt.Rows.Count > 0)
            {
                at = new Atendente()
                {
                    Id       = Convert.ToInt32(dt.Rows[0]["idAtendente"]),
                    Nome     = dt.Rows[0]["Nome"].ToString(),
                    Cpf      = dt.Rows[0]["CPF"].ToString(),
                    Endereco = dt.Rows[0]["Endereco"].ToString(),
                    Telefone = dt.Rows[0]["Telefone"].ToString(),
                    Status   = dt.Rows[0]["Status"].ToString(),
                    Senha    = dt.Rows[0]["Senha"].ToString(),
                    Email    = dt.Rows[0]["Email"].ToString()
                };
            }
            return(at);
        }
Esempio n. 13
0
        public List <Atendente> buscarTodosAtendentes()
        {
            List <Atendente> atendentes = new List <Atendente>();

            SqlCommand command = new SqlCommand();

            command.Connection  = conexao;
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM atendente";
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Atendente atendente = new Atendente();
                atendente.Id         = (Int32)reader["Id"];
                atendente.Cpf        = (String)reader["cpf"];
                atendente.Nome       = (String)reader["nome"];
                atendente.Nascimento = (DateTime)reader["nascimento"];

                atendentes.Add(atendente);
            }

            FabricaConexao.CloseConnection(conexao);

            return(atendentes);
        }
Esempio n. 14
0
        public ActionResult CadastrarAtendenteAR(string txtNomeAtendente, string txtEmailAtendente, string txtSenhaAtendente, string selSituacaoAtendente)
        {
            if (ValidarAdmin.UsuarioValido())
            {
                AtendenteDAL atendenteDAL = new AtendenteDAL();
                UsuarioDAL   usuarioDAL   = new UsuarioDAL();

                Atendente atendente = atendenteDAL.SelecionarAtendenteEmail(txtEmailAtendente);
                Usuario   usuario   = usuarioDAL.SelecionarUsuarioEmail(txtEmailAtendente);

                if ((usuario.EmailUsuario != null) || (atendente.EmailAtendente != null))
                {
                    TempData[Constantes.MensagemAlerta] = "Já existe atendente vinculado a este e-mail!";
                    return(View("CadastrarAtendenteUI"));
                }
                else
                {
                    usuario   = new Usuario(txtEmailAtendente, txtSenhaAtendente, atendente.TipoUsuarioAtendente, Convert.ToChar(selSituacaoAtendente));
                    atendente = new Atendente(txtNomeAtendente, txtEmailAtendente, Convert.ToChar(selSituacaoAtendente));

                    usuarioDAL.CadastrarUsuario(usuario);
                    atendenteDAL.CadastrarAtendente(atendente);

                    TempData[Constantes.MensagemAlerta] = "Atendente cadastrado com sucesso!";
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "AreaRestrita"));
            }
        }
Esempio n. 15
0
 //MÉTODOS\\
 private async void FazerLogin()
 {
     try
     {
         Atendente = await new AtendenteRepository().GetAtendenteByUserNameAsync(txtUsuario.Text, txtSenha.Text);
         if (Atendente != null)
         {
             Dispose();
         }
         else
         {
             MessageBox.Show("Nome de usuário ou senha inválidos!", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (AtendenteException e)
     {
         MessageBox.Show(e.Message, "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         throw;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Esempio n. 16
0
        private void btnFinalizar_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Deseja finalizar compra?", "Aviso!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Barbearia barbearia = (Barbearia)cbBarbearias.SelectedValue;
                Filial    filial    = (Filial)cbFiliais.SelectedValue;
                Atendente atendente = (Atendente)cbAtendente.SelectedValue;
                Cliente   cliente   = (Cliente)cbClientes.SelectedValue;

                this.pedidoAtual.Barbearia  = barbearia;
                this.pedidoAtual.Filial     = filial;
                this.pedidoAtual.Atendente  = atendente;
                this.pedidoAtual.Cliente    = cliente;
                this.pedidoAtual.DataPedido = DateTime.Now;

                try
                {
                    PedidoService.SalvarPedido(this.pedidoAtual);

                    MessageBox.Show("Salvo com sucesso!");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 17
0
        public ActionResult ExcluirAtendenteAR(string txtCodigoAtendente)
        {
            if (ValidarAdmin.UsuarioValido())
            {
                AtendenteDAL atendenteDAL = new AtendenteDAL();
                Atendente    atendente    = atendenteDAL.SelecionarAtendenteId(Convert.ToInt32(txtCodigoAtendente));

                if (atendente.CodigoAtendente == 0)
                {
                    TempData[Constantes.MensagemAlerta] = "Não existe Atendente para o código digitado.";
                    AtendenteControllerModel atendenteControllerModel = ConvertToModel(atendenteDAL.ListarAtendente());
                    return(View("ExcluirAtendenteUI", atendenteControllerModel));
                }
                else
                {
                    atendente.CodigoAtendente = Convert.ToInt32(txtCodigoAtendente);
                    atendenteDAL.ExcluirAtendente(atendente);
                    TempData[Constantes.MensagemAlerta] = "Atendente Excluído com Sucesso!";
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "AreaRestrita"));
            }
        }
Esempio n. 18
0
        public static void SalvarAtendente(Atendente atendente)
        {
            SqlConnection  conexao = null;
            SqlTransaction tx      = null;

            try
            {
                conexao = FabricaConexao.GetConnection();
                tx      = conexao.BeginTransaction();

                AtendenteDAO atendenteDAO = new AtendenteDAO(conexao, tx);
                atendenteDAO.salvarAtendente(atendente);
                atendenteDAO.salvarAtendenteFilial(atendente);

                TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx);
                telefoneDAO.salvarTelefone(atendente.Telefone);
                atendenteDAO.salvarAtendenteTelefone(atendente);
                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
            finally
            {
                FabricaConexao.CloseConnection(conexao);
            }
        }
Esempio n. 19
0
        internal Telefone buscarTelefoneDoAtendente(Atendente atendente)
        {
            Telefone telefone = new Telefone();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM telefone ");
            sql.Append("INNER JOIN telefone_atendente ON telefone.Id = telefone_atendente.id_telefone ");
            sql.Append("WHERE id_atendente = @id");
            command.Parameters.AddWithValue("id", atendente.Id);

            command.CommandText = sql.ToString();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                telefone.Id     = (Int32)reader["Id"];
                telefone.Numero = (String)reader["numero"];
                return(telefone);
            }

            return(null);
        }
Esempio n. 20
0
        public static Telefone BuscarTelefoneDoAtendente(Atendente atendente)
        {
            SqlConnection conexao     = FabricaConexao.GetConnection();
            TelefoneDAO   telefoneDAO = new TelefoneDAO(conexao);

            return(telefoneDAO.buscarTelefoneDoAtendente(atendente));
        }
Esempio n. 21
0
        public void CadastrarAtendenteComCpfSemMascaraTest()
        {
            // given
            var usuarioCadastro   = new UsuarioCadastroViewModel("*****@*****.**", "25d55ad283aa400af464c76d713c07ad", "Atendente");
            var enderecoCadastro  = new EnderecoViewModel("29500-000", "Rua nova", "123", "Casa", "Centro", "Alegre", "ES");
            var atendenteCadastro = new AtendenteCadastroViewModel("Joana", new DateTime(1980, 2, 5), "F", "12245778912", "12.345.678-1", "*****@*****.**", "(34)98543-3241", enderecoCadastro, usuarioCadastro);

            var endereco         = new Endereco(new Guid("1EF2F5CB-A04B-4761-3C44-08D78CC135ED"), "29500-000", "Rua nova", "123", "Casa", "Centro", "Alegre", "ES");
            var atendente        = new Atendente(new Guid("16E16A8D-469F-4286-A470-08D78CC0F920"), "Joana", new DateTime(1980, 2, 5), "F", "12245778912", "12.345.678-1", "*****@*****.**", "(34)98543-3241", endereco.IdEndereco);
            var usuarioAtendente = new Usuario(new Guid("1A7C25A0-896F-49DF-A75E-EE7DD53AECB9"), "*****@*****.**", "25d55ad283aa400af464c76d713c07ad", "Atendente", null, atendente);

            this.atendenteRepositoryMock.SetupSequence(a => a.BuscarAtendentePorCpf("122.457.789-12")).Returns((Atendente)null).Returns(atendente);
            this.atendenteRepositoryMock.Setup(a => a.BuscarAtendentePorRg(atendenteCadastro.Rg)).Returns((Atendente)null);
            this.usuarioRepositoryMock.Setup(u => u.ObterUsuarioPorEmail(atendenteCadastro.Usuario.Email)).Returns((Usuario)null);
            this.enderecoRepositoryMock.Setup(e => e.BuscaIdEndereco(It.IsAny <Endereco>())).Returns(Guid.NewGuid());
            this.enderecoRepositoryMock.Setup(e => e.CadastrarEndereco(It.IsAny <Endereco>())).Returns(true);
            this.atendenteRepositoryMock.Setup(a => a.CadastrarAtendente(It.IsAny <Atendente>())).Returns(true);
            this.usuarioRepositoryMock.Setup(u => u.CadastrarUsuario(It.IsAny <Usuario>())).Returns(true);

            var atendenteService = new AtendenteService(this.atendenteRepositoryMock.Object, this.enderecoRepositoryMock.Object, this.usuarioRepositoryMock.Object);

            // when
            var resultado = atendenteService.CadastrarAtendente(atendenteCadastro);

            // then
            Assert.NotNull(resultado);
            Assert.True(resultado.Id == 1);
        }
        public async Task <IActionResult> Edit(int id, [Bind("AteId,AtePessoaid")] Atendente atendente)
        {
            if (id != atendente.AteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(atendente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AtendenteExists(atendente.AteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AtePessoaid"] = new SelectList(_context.Pessoa, "PesId", "PesEmail", atendente.AtePessoaid);
            return(View(atendente));
        }
Esempio n. 23
0
        public async Task <IActionResult> Edit(int id, [Bind("AtendenteID,Nome,Telefone,Email")] Atendente atendente)
        {
            if (id != atendente.AtendenteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(atendente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AtendenteExists(atendente.AtendenteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(atendente));
        }
Esempio n. 24
0
        public static Filial BuscarFilialDoAtendente(Atendente atendente)
        {
            SqlConnection conexao   = FabricaConexao.GetConnection();
            FilialDAO     filialDAO = new FilialDAO(conexao);

            return(filialDAO.buscarFilialDoAtendente(atendente));
        }
Esempio n. 25
0
 public void Cadastrar(Atendente atendente)
 {
     using (var contexto = new ConecaoContext())
     {
         contexto.Atendente.Add(atendente);
         contexto.SaveChanges();
     }
 }
Esempio n. 26
0
 public void OnReset()
 {
     temAtendente         = false;
     atendente            = null;
     _userSendoAtendido   = null;
     _atendimentoRestante = 0;
     _atendenteVindo      = null;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Atendente atendente = db.Atendentes.Find(id);

            db.Atendentes.Remove(atendente);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 28
0
        public Agendamento(int numero, Paciente paciente, Atendente atendente)
        {
            Numero    = numero;
            Paciente  = paciente;
            Atendente = atendente;

            Exames = new List <Exame>();
        }
        private void cbAtendente_SelectedIndexChanged(object sender, EventArgs e)
        {
            Atendente           atendenteSelecionado = (Atendente)cbAtendente.SelectedValue;
            List <PedidoReport> pedidoReports        = ReportService.BuscarPedidosDoAtendente(atendenteSelecionado);

            PedidoReportBindingSource.DataSource = pedidoReports;
            this.reportViewer1.RefreshReport();
        }
Esempio n. 30
0
        private void btn_entrar_login_Click(object sender, EventArgs e)
        {
            try
            {
                Atendente atendente = new Atendente();
                atendente.Level = new Nivel();
                if (atendente.EfetuarLogin(txt_usuario_login.Text, txt_senha_login.Text) == true)
                {
                    if (atendente.Level.Cod == 1 || atendente.Level.Cod == 2)
                    {
                        if (atendente.Acesso == true)
                        {
                            this.Hide();
                            Form formD = new frm_pri_adm();
                            formD.Closed += (s, args) => this.Close();
                            formD.Show();
                        }

                        else if (atendente.Acesso == false)
                        {
                            this.Hide();
                            Form formD = new frm_pri_adm();
                            formD.Closed += (s, args) => this.Close();
                            formD.Show();
                        }
                    }
                    if (atendente.Level.Cod == 3)
                    {
                        if (atendente.Acesso == true)
                        {
                            this.Hide();
                            Form formA = new frm_pri_ate();
                            formA.Closed += (s, args) => this.Close();
                            formA.Show();
                        }

                        else if (atendente.Acesso == false)
                        {
                            this.Hide();
                            Form formA = new frm_pri_ate();
                            formA.Closed += (s, args) => this.Close();
                            formA.Show();
                        }
                    }
                }
                else if (atendente.EfetuarLogin(txt_usuario_login.Text, txt_senha_login.Text) == false)
                {
                    MessageBox.Show("Login e/ou senha inexistente", "PosiChange",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                //throw ex;
                MessageBox.Show("Sem conexão com a rede, por favor verifique!", "PosiChange",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static void AtualizarAtendente(Atendente Atendente)
        {
            String comandoSql =
                @"UPDATE ATENDENTE SET TELEFONE = :TELEFONE, EMAIL = :EMAIL, DTINATIVACAO = :DTINATIVACAO, ORDEM = :ORDEM WHERE CODIGO = :CODIGO";

            OracleConnection conexao = PersistenciaOracle.ObterConexao();
            conexao.Open();

            OracleCommand comando = new OracleCommand(comandoSql);
            comando.Connection = conexao;

            comando.Parameters.Add("TELEFONE", Atendente.Telefone);
            comando.Parameters.Add("EMAIL", Atendente.Email);
            comando.Parameters.Add("DTINATIVACAO", Atendente.DtInativacao);
            comando.Parameters.Add("ORDEM", Atendente.Ordem);

            comando.Parameters.Add("CODIGO", Atendente.Codigo);

            comando.Prepare();
            comando.ExecuteNonQuery();
            conexao.Close();
        }
        public static List<Atendente> ConsultarAtendentes(Atendente Atendente, bool ApenasAtivos)
        {
            String comandoSql = "SELECT CODIGO,NOME,TELEFONE,EMAIL,DTINATIVACAO,DTINCLUSAO,ORDEM FROM ATENDENTE WHERE 1 = 1 ";

            if (!string.IsNullOrEmpty(Atendente.Nome))
            {
                comandoSql += string.Format(" AND UPPER(NOME) LIKE '{0}%' ", Atendente.Nome.ToUpper());
            }

            if (ApenasAtivos)
            {
                comandoSql += " AND DTINATIVACAO IS NULL ";
            }

            OracleConnection conexao = PersistenciaOracle.ObterConexao();
            conexao.Open();
            OracleCommand comando = new OracleCommand(comandoSql);
            comando.Connection = conexao;

            List<Atendente> atendentes = new List<Atendente>();
            OracleDataReader leitor = comando.ExecuteReader();
            while (leitor.Read())
            {
                Atendente atd = new Atendente();
                atd.Codigo = UtilidadePersistencia.ObterValorTratado<int>(leitor[0]);
                atd.Nome = UtilidadePersistencia.ObterValorTratado<String>(leitor[1]);
                atd.Telefone = UtilidadePersistencia.ObterValorTratado<String>(leitor[2]);
                atd.Email = UtilidadePersistencia.ObterValorTratado<String>(leitor[3]);
                atd.DtInativacao = UtilidadePersistencia.ObterValorDateTimeTratado<DateTime?>(leitor[4]);
                atd.DtInclusao = UtilidadePersistencia.ObterValorDateTimeTratado<DateTime?>(leitor[5]);
                atd.Ordem = UtilidadePersistencia.ObterValorTratado<int>(leitor[6]);

                atendentes.Add(atd);
            }
            conexao.Close();

            return atendentes;
        }
Esempio n. 33
0
        public void Main(string[] args)
        {
            Pessoa pessoa = new Atendente();


        }
        public static int GravarRecursoAtendente(Atendente Atendente)
        {
            int codigo = PersistenciaOracle.ObterProximoCodigo("ATENDENTE");
            int ordem = PersistenciaOracle.ObterProximoMaximoValor("ATENDENTE", "ORDEM");

            OracleConnection conexao = PersistenciaOracle.ObterConexao();
            conexao.Open();
            OracleCommand comando = new OracleCommand("INSERT INTO ATENDENTE(CODIGO,NOME,TELEFONE,EMAIL,DTINCLUSAO,ORDEM) VALUES(:CODIGO,:NOME,:TELEFONE,:EMAIL,SYSDATE,:ORDEM)");
            comando.Connection = conexao;
            comando.Parameters.Add("CODIGO", codigo);
            comando.Parameters.Add("NOME", Atendente.Nome);
            comando.Parameters.Add("TELEFONE", Atendente.Telefone);
            comando.Parameters.Add("EMAIL", Atendente.Email);
            comando.Parameters.Add("ORDEM", ordem);

            comando.Prepare();
            comando.ExecuteNonQuery();
            conexao.Close();

            return codigo;
        }
Esempio n. 35
0
 public AgendamentoPlus(int numero, Paciente paciente, Atendente atendente)
     : base(numero, paciente, atendente)
 {
 }
Esempio n. 36
0
        public Agendamento(int numero, Paciente paciente, Atendente atendente)
        {
            Numero = numero;
            Paciente = paciente;
            Atendente = atendente;

            Exames = new List<Exame>();
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if(string.IsNullOrEmpty(txtNome.Text))
            {
                Mensagens.ExibirMensagemAlerta(this,"É obrigatório preencher o nome.", txtNome);
                return;
            }

            Atendente atd = new Atendente();
            atd.Nome = this.txtNome.Text;
            atd.Email = this.txtEmail.Text;
            atd.Telefone = this.maskedTextBox.Text;

            if(this.checkBox.IsChecked.GetValueOrDefault())
            {
                atd.DtInativacao = DateTime.Now;
            }

            if(!this.EstadoDeAlteracao)
            {

                if(Persistencia.PersistenciaAtendente.ConsultarAtendentes(new Atendente() {  Nome = atd.Nome},false).Count() > 0)
                {
                    Mensagens.ExibirMensagemAlerta(this, "Já existe atendente cadastrado com este nome!");
                    return;
                }

                Persistencia.PersistenciaAtendente.GravarRecursoAtendente(atd);
                Log.RegistrarMensagemLog("Atendente " + atd.Nome + " foi cadastrado!");
            }
            else
            {
                atd.Codigo = this.CodigoEmAlteracao;
                atd.Ordem = this.OrdemEmAlteracao;
                Persistencia.PersistenciaAtendente.AtualizarAtendente(atd);
                Log.RegistrarMensagemLog("Atendente " + atd.Nome + " foi atualizado!");
            }

            Mensagens.ExibirMensagemAlerta(this,"Ação realizada com sucesso.");

            this.LimparTela();
        }
 private void btnPesquisa_Click(object sender, RoutedEventArgs e)
 {
     Atendente atd = new Atendente() { Nome = this.txtNomePesquisa.Text };
     List<Atendente> atendentes = Persistencia.PersistenciaAtendente.ConsultarAtendentes(atd, false);
     this.dataGrid.DataContext = atendentes;
 }
        private void PreencherDadosNaTela(Atendente atd)
        {
            this.txtNome.Text = atd.Nome;
            this.txtEmail.Text = atd.Email;
            this.maskedTextBox.Text = atd.Telefone;

            if(atd.DtInativacao != null && atd.DtInativacao != default(DateTime?))
            {
                this.checkBox.IsChecked = true;
            }
        }
        private void ColocarTelaEmEstadoAlteracao(Atendente atd)
        {
            this.CodigoEmAlteracao = atd.Codigo;
            this.OrdemEmAlteracao = atd.Ordem;
            PreencherDadosNaTela(atd);

            this.EstadoDeAlteracao = true;
            this.txtNome.IsEnabled = false;
            this.checkBox.IsEnabled = true;
            this.maskedTextBox.Focus();
            tabControl.SelectedIndex = 1;
        }
        private List<Agendamento> ObterAgendamentosDaTela()
        {
            List<Agendamento> agendamentos = new List<Agendamento>();
            List<Servico> servicos = this.ObterServicosSelecionadosNaTela();

            DateTime dataagd = DateTime.Parse(this.DataAtendimento.ToShortDateString() + " " + this.HorarioInicioPrimeiroAtendimento);

            Atendente atdnt = new Atendente() { Nome = NomeAtendente };
            atdnt = Persistencia.PersistenciaAtendente.ConsultarAtendentes(atdnt, false).FirstOrDefault();

            int tempoMax = this.TempoMaximoAtendimentoEncaixe;
            foreach (Servico servico in servicos)
            {
                Agendamento agd = new Agendamento()
                {
                    ServicoAgendado = servico,
                    DataHoraAgendamento = dataagd
                };

                if (this.Atendimento != null)
                {
                    foreach (Agendamento agdexistente in this.Atendimento.Agendamentos)
                    {
                        if (agd.ServicoAgendado.Codigo == agdexistente.ServicoAgendado.Codigo)
                        {
                            agd.TempoAtendimento = agdexistente.TempoAtendimento;
                        }
                    }
                }

                if (tempoMax != -1)
                {
                    if (agd.TempoAtendimento <= tempoMax)
                    {
                        tempoMax -= agd.TempoAtendimento;
                    }
                    else
                    {
                        agd.TempoAtendimento = tempoMax;
                    }
                }

                //if (this.TempoMaximoAtendimentoEncaixe > 0)
                //{
                //    agd.TempoAtendimento = this.TempoMaximoAtendimentoEncaixe;
                //}

                agendamentos.Add(agd);
                dataagd = dataagd.AddMinutes(agd.TempoAtendimento);
            }


            return agendamentos;
        }