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 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()); } }