private void BtnExcluir_Click(object sender, EventArgs e) { try { Medico medico = new Medico(); int id = Convert.ToInt32(ID_medico.Text); medico.Id = id; Agendamento agendamento = new Agendamento(); agendamento.Medico = medico; MySqlMedicoConvenioRepository.Excluir(Convert.ToInt32(ID_medico.Text)); MySqlMedicoHorarioRepository.ExcluirpeloMedico(Convert.ToInt32(ID_medico.Text)); AgendamentoExame ae = new AgendamentoExame(); List <Agendamento> agendamentos = MySqlAgendamentoRepository.GetByMedico(Convert.ToInt32(ID_medico.Text)).ToList(); if (agendamentos != null) { for (int i = 0; i < agendamentos.Count; i++) { ae.Id = agendamentos.ElementAt(i).Id; MySqlAgendamentoExameRepository.Excluir(ae); } } MySqlAgendamentoRepository.ExcluirByMedico(agendamento); MySqlAgendamentoRepository.Excluir(agendamento); ///MySqlAgendamentoRepository. tirar do agendamento e do agendamentoexame se der tempo MySqlMedicoRepository.Excluir(medico); MessageBox.Show("Excluido com Sucesso."); } catch (Exception ex) { MessageBox.Show("Erro ao excluir médico: " + ex.ToString()); } }
private void BtnPesquisar_Click(object sender, EventArgs e) { List <Agendamento> lista = new List <Agendamento>(); Agendamento ag = new Agendamento(); ag.dataagenda = DtpDataAgendamento.Value; lista = MySqlAgendamentoRepository.GetByData(ag.dataagenda).ToList(); DgvAgendamentos.DataSource = lista; if (lista.Count == 0) { MessageBox.Show("Nome não encontrada.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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()); } }
private void BtnPesquisar_Click(object sender, EventArgs e) { Medico med = new Medico(); med = CbbMedico.SelectedItem as Medico; DateTime data = dtpData.Value; Agendamento agendamento = new Agendamento(); agendamento.dataagenda = data.Date; agendamento.Medico = med; List <Agendamento> lista = new List <Agendamento>(); lista = MySqlAgendamentoRepository.GetAgendamento(agendamento).ToList(); DgvAgendamento.DataSource = lista; if (lista.Count == 0) { MessageBox.Show("Nome não encontrada.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void agendamento_Click(object sender, EventArgs e) { Medico med = new Medico(); med = CbbMedico.SelectedItem as Medico; DateTime data = dtpData.Value; Agendamento agendamento = new Agendamento(); agendamento.dataagenda = data.Date; agendamento.Medico = med; List <Agendamento> lista = new List <Agendamento>(); lista = MySqlAgendamentoRepository.GetAgendamento(agendamento).ToList(); //DgvAgendamento.DataSource = lista; var agendamen = lista; var f = new FrmVisualizadorDeRelatorio("Trabalho.Report.RelAgendamento.rdlc", LocalRelatorio.EmbeddedResource); f.AddDataSource(lista, "DSAgendamento"); f.Show(); }
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"); } }