Esempio n. 1
0
        private void tbInserir_Click(object sender, System.EventArgs e)
        {
            try
            {
                var Agendamento = new Agendamento();
                validationInsertUpdate(Agendamento);

                if (AgendamentoDao.Select(new List <Tuple <string, object, string> >()
                {
                    new Tuple <string, object, string>("IDMedico", Agendamento.IDMedico, "="),
                    new Tuple <string, object, string>("DataConsulta", Agendamento.DataConsulta, "=")
                }).Count > 0)
                {
                    throw new Exception("Já existe Agendamento no horario informado com o Medico selecionado");
                }

                AgendamentoDao.Insert(Agendamento);

                MessageBox.Show(this, "Agendamento incluido com sucesso", "Agendamento");

                Util.lstAgendamentos   = AgendamentoDao.Select(null);
                dgResultado.DataSource = null;
                dgResultado.DataSource = Util.lstAgendamentos;
                formOnEndTask();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ActionResult Index()
        {
            MedicoDao           me             = new MedicoDao();
            AgendamentoDao      ag             = new AgendamentoDao();
            IList <Agendamento> lista          = ag.Select();
            PacienteDao         dao            = new PacienteDao();
            IList <Paciente>    listaPacientes = new List <Paciente>();
            IList <Paciente>    pacientes      = dao.Select();


            foreach (var agenda in lista)
            {
                int      id       = agenda.PacienteId;
                Paciente paciente = dao.BuscaPorId(id);
                listaPacientes.Add(paciente);
            }

            listaPacientes.Count();
            ViewBag.Paciente    = listaPacientes;
            ViewBag.Pacientes   = pacientes;
            ViewBag.Agendamento = lista;
            ViewBag.Medicos     = me.Select();

            return(View());
        }