Ejemplo n.º 1
0
 public void Salvar(Profissional usr)
 {
     if (usr.ID_PROFISSIONAL > 0)
         Alterar(usr);
     else
         Inserir(usr);
 }
Ejemplo n.º 2
0
        public List<Profissional_TratamentoViewModel> ListarPorId(int id)
        {
            using (conexao = new Conexao())
            {
                List<Profissional_TratamentoViewModel> ListaTratamentos = new List<Profissional_TratamentoViewModel>();

                SqlConnection Con = Conexao.Con;
                SqlCommand Cmd = new SqlCommand("PR_SEL-ID_PROFISSIONAL_TRATAMENTO", Con);
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.AddWithValue("@ID_TRATAMENTO", id);
                Cmd.ExecuteNonQuery();

                SqlDataAdapter ada = new SqlDataAdapter(Cmd);
                DataSet ds = new DataSet();
                ada.Fill(ds);

                DataRowCollection linhas = ds.Tables[0].Rows;

                foreach (DataRow linha in linhas)
                {
                    Profissional_TratamentoViewModel tratamento = new Profissional_TratamentoViewModel();
                    Profissional p = new Profissional();

                    tratamento.ID_TRATAMENTO = int.Parse(linha["ID_TRATAMENTO"].ToString());
                    tratamento.DESCRICAO = linha["TRATAMENTO"].ToString();

                    p.NOME = linha["PROFISSIONAL"].ToString();
                    tratamento.PROFISSIONAL = p;

                    ListaTratamentos.Add(tratamento);
                }

                return ListaTratamentos;
            }
        }
Ejemplo n.º 3
0
 public ActionResult Editar(Profissional usr)
 {
     if (ModelState.IsValid)
     {
         var appProfissional = new ProfissionalAplicacao();
         appProfissional.Salvar(usr);
         return RedirectToAction("Index");
     }
     return View(usr);
 }
Ejemplo n.º 4
0
        private void Alterar(Profissional usr)
        {
            var strQuery = "";
            strQuery += "UPDATE PROFISSIONAL SET ";
            strQuery += string.Format(" NOME = '{0}', ", usr.NOME);
            strQuery += string.Format(" TELEFONE = '{0}', ", usr.TELEFONE);
            strQuery += string.Format(" EMAIL = '{0}', ", usr.EMAIL);
            strQuery += string.Format(" SENHA = '{0}', ", usr.SENHA);
            strQuery += string.Format(" ATIVO = '{0}' ", 1);
            strQuery += string.Format(" WHERE ID_PROFISSIONAL = {0} ", usr.ID_PROFISSIONAL);

            using (conexao = new Conexao())
            {
                conexao.ExecutaComando(strQuery);
            }
        }
Ejemplo n.º 5
0
        private List<Profissional> transformaReaderEmLista(SqlDataReader reader)
        {
            var ListaProfissional = new List<Profissional>();

            while (reader.Read())
            {
                var objeto = new Profissional()
                {
                    ID_PROFISSIONAL = int.Parse(reader["ID_PROFISSIONAL"].ToString()),
                    NOME = reader["NOME"].ToString(),
                    TELEFONE = reader["TELEFONE"].ToString(),
                    EMAIL = reader["EMAIL"].ToString(),
                    SENHA = reader["SENHA"].ToString()
                };
                ListaProfissional.Add(objeto);
            }
            reader.Close();
            return ListaProfissional;
        }
Ejemplo n.º 6
0
        private void Inserir(Profissional usr)
        {
            var strQuery = "";
            strQuery += " INSERT INTO PROFISSIONAL (NOME, TELEFONE, EMAIL, SENHA, ATIVO) ";
            strQuery += string.Format(" VALUES('{0}', '{1}', '{2}', '{3}', '{4}')",
                usr.NOME, usr.TELEFONE, usr.EMAIL, usr.SENHA, 1);

            using (conexao = new Conexao())
            {
                conexao.ExecutaComando(strQuery);
            }
        }
Ejemplo n.º 7
0
        //private void Inserir(Profissional_TratamentoViewModel tto)
        //{
        //    using (conexao = new Conexao())
        //    {
        //        SqlConnection Con = Conexao.Con;
        //        SqlCommand Cmd = new SqlCommand("PR_IN_PROFISSIONAL_TRATAMENTO", Con);
        //        Cmd.CommandType = CommandType.StoredProcedure;
        //        Cmd.Parameters.AddWithValue("@ID_PROFISSIONAL", tto.PROFISSIONAL.ID_PROFISSIONAL);
        //        Cmd.Parameters.AddWithValue("@DESCRICAO", tto.DESCRICAO);
        //        Cmd.ExecuteNonQuery();
        //    }
        //}
        //private void Alterar(Profissional_TratamentoViewModel tto)
        //{
        //    var strQuery = "";
        //    strQuery += "UPDATE TRATAMENTO SET ";
        //    strQuery += string.Format("DESCRICAO = '{0}' ", tto.DESCRICAO);
        //    strQuery += string.Format(" WHERE ID_TRATAMENTO = {0} ", tto.ID_TRATAMENTO);
        //    using (conexao = new Conexao())
        //    {
        //        conexao.ExecutaComando(strQuery);
        //    }
        //}
        //public void Salvar(Profissional_TratamentoViewModel tto)
        //{
        //    if (tto.ID_TRATAMENTO > 0)
        //        Alterar(tto);
        //    else
        //        Inserir(tto);
        //}
        //public void Excluir(int id)
        //{
        //    using (conexao = new Conexao())
        //    {
        //        SqlConnection Con = Conexao.Con;
        //        SqlCommand Cmd = new SqlCommand("PR_DEL_PROFISSIONAL_TRATAMENTO", Con);
        //        Cmd.CommandType = CommandType.StoredProcedure;
        //        Cmd.Parameters.AddWithValue("@ID_TRATAMENTO", id);
        //        Cmd.ExecuteNonQuery();
        //    }
        //}
        public List<Consulta> listarConsulta(Consulta cons)
        {
            using (conexao = new Conexao())
            {
                List<Consulta> ListaConsultas = new List<Consulta>();

                SqlConnection Con = Conexao.Con;
                SqlCommand Cmd = new SqlCommand("PR_SEL_CONSULTA", Con);
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.AddWithValue("@DATA_CONSULTA", cons.DATA_CONSULTA);
                Cmd.Parameters.AddWithValue("@NOME", cons.PROFISSIONAL.NOME);
                Cmd.ExecuteNonQuery();

                SqlDataAdapter ada = new SqlDataAdapter(Cmd);
                DataSet ds = new DataSet();
                ada.Fill(ds);

                DataRowCollection linhas = ds.Tables[0].Rows;

                foreach (DataRow linha in linhas)
                {
                    Consulta consulta = new Consulta();
                    Profissional prof = new Profissional();
                    Tratamento tto = new Tratamento();
                    Cliente cli = new Cliente();

                    consulta.ID_CONSULTA = int.Parse(linha["ID_CONSULTA"].ToString());
                    consulta.DATA_CONSULTA = DateTime.Parse(linha["DATA_CONSULTA"].ToString());
                    consulta.HORARIO_CONSULTA = linha["HORARIO_CONSULTA"].ToString();

                    prof.NOME = linha["PROFISSIONAL"].ToString();
                    consulta.PROFISSIONAL = prof;

                    tto.DESCRICAO = linha["DESCRICAO"].ToString();
                    consulta.TRATAMENTO = tto;

                    cli.NOME = linha["CLIENTE"].ToString();
                    consulta.CLIENTE = cli;

                    cli.TELEFONE = linha["TELEFONE"].ToString();
                    consulta.CLIENTE = cli;

                    ListaConsultas.Add(consulta);
                }

                return ListaConsultas;
            }
        }