Ejemplo n.º 1
0
 private void BtnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         Agendamento      Agendamento      = new Agendamento();
         AgendamentoExame agendamentoExame = new AgendamentoExame();
         Agendamento.Id      = Convert.ToInt32(ID_Agendamento.Text);
         agendamentoExame.Id = Agendamento.Id;
         MySqlAgendamentoExameRepository.Excluir(agendamentoExame);
         MySqlAgendamentoRepository.Excluir(Agendamento);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro ao excluir cidade: " + ex.ToString());
     }
 }
Ejemplo n.º 2
0
        private void BtnConsultar_Click(object sender, EventArgs e)
        {
            var f = new FrmConsAgendamento(MySqlAgendamentoRepository);

            if (f.ShowDialog() == DialogResult.OK)
            {
                //colocar campos
                List <Exame>            listaexam             = new List <Exame>();
                List <AgendamentoExame> listaagendamentoexame = new List <AgendamentoExame>();
                ID_Agendamento.Text = f.Agendamento.Id.ToString();
                int teste = f.Agendamento.Id;
                listaagendamentoexame = MySqlAgendamentoExameRepository.GetByAgendamentoExame(f.Agendamento.Id).ToList();
                for (int i = 0; i < listaagendamentoexame.Count; i++)
                {
                    listaexam.Add(listaagendamentoexame[i].Exame);
                }
                DgvExames.DataSource = listaexam;
            }
        }
Ejemplo n.º 3
0
        private void BtnGravar_Click(object sender, EventArgs e)
        {
            if (listaex.Count > 0)
            {
                List <MedicoHorario> horarios = new List <MedicoHorario>();

                Agendamento agenda = new Agendamento();

                agenda.Medico     = CbbMedico.SelectedItem as Medico;
                agenda.dataagenda = data_agendamento.Value;
                int veri = 0;

                horarios = MySqlMedicoHorarioRepository.GetByMedico((int)agenda.MedicoId).ToList();
                DateTime inicio     = horarios[0].datainicial.Date;
                DateTime agendadata = agenda.dataagenda.Date;
                DateTime fim        = horarios[0].datafinal.Date;
                if (inicio <= agendadata)
                {
                    MessageBox.Show("TESTE");
                }

                for (int i = 0; i < horarios.Count && veri == 0; i++)
                {
                    if (horarios[i].datainicial.Date <= agenda.dataagenda.Date && horarios[i].datafinal.Date >= agenda.dataagenda.Date && horarios[i].atende == true)
                    {
                        veri = 1;
                    }
                }
                if (veri == 1)
                {
                    int id;
                    int.TryParse(ID_Agendamento.Text, out id);
                    agenda.Id       = id;
                    agenda.Convenio = CbbConvenio.SelectedItem as Convenio;

                    agenda.data       = DateTime.Now;
                    agenda.Medico     = CbbMedico.SelectedItem as Medico;
                    agenda.observacao = Observacao.Text;
                    agenda.Paciente   = CbbPaciente.SelectedItem as Paciente;
                    agenda.Situacao   = CbbSituacao.SelectedItem as Situacao;
                    agenda.total      = 0;//Convert.ToDecimal(Total.Text);
                    int   cod   = MySqlAgendamentoRepository.Gravar(agenda);
                    Exame Exame = new Exame();
                    for (int i = 0; i < listaex.Count; i++)
                    {
                        AgendamentoExame agendamentoexame = new AgendamentoExame();
                        agendamentoexame.Id                = cod;
                        Exame.Id                           = listaex[i].Id;
                        agendamentoexame.Exame             = Exame;
                        agendamentoexame.Quantidade        = listaex[i].QtdeUnidade;
                        agendamentoexame.QuantidadeUnidade = MySqlExameRepository.Get(listaex[i].Id).QtdeUnidade;
                        agendamentoexame.Total             = 0;
                        agendamentoexame.ValorUnidade      = agenda.Convenio.ValorUnidade;
                        MySqlAgendamentoExameRepository.Gravar(agendamentoexame);
                    }
                    MessageBox.Show("gravado com sucesso");
                }
                else
                {
                    MessageBox.Show("Horário já ocupado");
                }
            }
            else
            {
                MessageBox.Show("Adicione ao menos um exame");
            }
        }