Esempio n. 1
0
        public void TestarAgenda(modelAtendimento agenda) //verificar se a agenda está reservada
        {
            MySqlCommand cmd = new MySqlCommand("select * from tbAtendimento where dataAtend = @data and horaAtend = @hora", con.MyConectarBD());

            cmd.Parameters.Add("@data", MySqlDbType.VarChar).Value = agenda.dataAtend;
            cmd.Parameters.Add("@hora", MySqlDbType.VarChar).Value = agenda.horaAtend;

            MySqlDataReader leitor;

            leitor = cmd.ExecuteReader();

            if (leitor.HasRows)
            {
                while (leitor.Read())
                {
                    agenda.confAgendamento = "0";
                }
            }

            else
            {
                agenda.confAgendamento = "1";
            }

            con.MyDesconectarBD();
        }
Esempio n. 2
0
        public void inserirAtendimento(modelAtendimento cm)// Cadastrar o atendimento no BD
        {
            MySqlCommand cmd = new MySqlCommand("insert into tbAtendimento(codAtendimento, dataAtend, horaAtend, codDentista, codPac) values (default, @data, @hora, @codDent, @codPac)", con.MyConectarBD());

            cmd.Parameters.Add("@data", MySqlDbType.VarChar).Value    = cm.dataAtend;
            cmd.Parameters.Add("@hora", MySqlDbType.VarChar).Value    = cm.horaAtend;
            cmd.Parameters.Add("@codDent", MySqlDbType.VarChar).Value = cm.codDentista;
            cmd.Parameters.Add("@codPac", MySqlDbType.VarChar).Value  = cm.codPac;

            cmd.ExecuteNonQuery();
            con.MyDesconectarBD();
        }
Esempio n. 3
0
        public ActionResult cadAtendimento(modelAtendimento at)
        {
            carregaDentistas();
            carregaPacientes();
            at.codPac      = Request["paciente"];
            at.codDentista = Request["dentista"];
            ac.TestarAgenda(at);

            if (at.confAgendamento == "1")
            {
                ac.inserirAtendimento(at);
                ViewBag.msg = "Agendamento Realizado";
                return(View());
            }
            else if (at.confAgendamento == "0")
            {
                ViewBag.msg = "Horário indisponível";
                return(View());
            }

            return(View());
        }