public ActionResult Create([Bind(Include = "Id,IdPaciente,IdUsuario,DataMarcadaExame,NomeExame,LocalExame")] AgendamentoExame agendamentoExame) { TwilioSMS twilioSMS = new TwilioSMS(); Email email = new Email(); var paciente = db.Paciente.Find(agendamentoExame.IdPaciente); var nomeMedico = db.Usuarios.Find(agendamentoExame.IdUsuario); var msgConfirmacaoCel = String.Format(_msgConfirmacaoAgendamentoCel, agendamentoExame.NomeExame, agendamentoExame.DataMarcadaExame, nomeMedico.Nome, agendamentoExame.LocalExame); var msgConfirmacaoEmail = String.Format(_msgConfirmacaoAgendamentoEmail, agendamentoExame.NomeExame, agendamentoExame.DataMarcadaExame, nomeMedico.Nome, agendamentoExame.LocalExame); if (ModelState.IsValid) { db.AgendamentoExame.Add(agendamentoExame); db.SaveChanges(); if (!paciente.Telefone.IsNullOrWhiteSpace()) { twilioSMS.SendTwilioSMS(paciente.Telefone, msgConfirmacaoCel); } if (!paciente.Email.IsNullOrWhiteSpace()) { email.SendEmail(paciente.Email, _subjectConfirmacaoAgendamentoEmail, msgConfirmacaoEmail); } return(RedirectToAction($"Index")); } ViewBag.IdPaciente = new SelectList(db.Paciente, "Id", "NomeCompleto", agendamentoExame.IdPaciente); ViewBag.IdUsuario = new SelectList(db.Usuarios, "Id", "Nome", agendamentoExame.IdUsuario); return(View(agendamentoExame)); }
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()); } }
public ActionResult DeleteConfirmed(int id) { AgendamentoExame agendamentoExame = db.AgendamentoExame.Find(id); Email email = new Email(); TwilioSMS twilioSMS = new TwilioSMS(); var paciente = db.Paciente.Find(agendamentoExame.IdPaciente); var nomeMedico = db.Usuarios.Find(agendamentoExame.IdUsuario); var msgCancelamentoCel = String.Format(_msgCancelAgendamentoCel, agendamentoExame.NomeExame, agendamentoExame.DataMarcadaExame, nomeMedico.Nome, agendamentoExame.LocalExame); var msgCancelamentoEmail = String.Format(_msgCancelAgendamentoEmail, agendamentoExame.NomeExame, agendamentoExame.DataMarcadaExame, nomeMedico.Nome, agendamentoExame.LocalExame); if (!paciente.Telefone.IsNullOrWhiteSpace()) { twilioSMS.SendTwilioSMS(paciente.Telefone, msgCancelamentoCel); } if (!paciente.Email.IsNullOrWhiteSpace()) { email.SendEmail(paciente.Email, _subjectCancelAgendamentoEmail, msgCancelamentoEmail); } db.AgendamentoExame.Remove(agendamentoExame); db.SaveChanges(); return(RedirectToAction($"Index")); }
public ActionResult Edit([Bind(Include = "Id,IdPaciente,IdUsuario,DataMarcadaExame,NomeExame,LocalExame")] AgendamentoExame agendamentoExame) { if (ModelState.IsValid) { db.Entry(agendamentoExame).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction($"Index")); } ViewBag.IdPaciente = new SelectList(db.Paciente, "Id", "NomeCompleto", agendamentoExame.IdPaciente); ViewBag.IdUsuario = new SelectList(db.Usuarios, "Id", "Nome", agendamentoExame.IdUsuario); return(View(agendamentoExame)); }
public void Gravar(AgendamentoExame agendamentoExame) { if (agendamentoExame.Id == 0) { Connection.Execute("insert into exame(nome) values (@nome)", agendamentoExame); agendamentoExame.Id = Convert.ToInt32(Connection.ExecuteScalar("select last_insert_id()")); } else { Connection.Execute("update exame set nome = @nome where id = @id", agendamentoExame); } }
public void Gravar(AgendamentoExame agendamentoExame) { if (agendamentoExame.Id != 0) { Connection.Execute("insert into agendamentoexame(agendamentoid,exameid,qtde,qtdeunidade,total,valorunidade) values (@agendamentoid,@exameid,@qtde,@qtdeunidade,@total,@valorunidade)", new { agendamentoid = agendamentoExame.Id, exameid = agendamentoExame.ExameId, qtde = agendamentoExame.Quantidade, qtdeunidade = agendamentoExame.QuantidadeUnidade, total = agendamentoExame.Total, valorunidade = agendamentoExame.ValorUnidade }); agendamentoExame.Id = Convert.ToInt32(Connection.ExecuteScalar("select last_insert_id()")); } else { Connection.Execute("update exame set exameid = @exameid, qtde = @qtde, qtdeunidade = @qtdeunidade, total = @total, valorunidade = @valorunidade where agendamentoid = @agendamentoid", new { agendamentoid = agendamentoExame.Id, exameid = agendamentoExame.ExameId, qtde = agendamentoExame.Quantidade, qtdeunidade = agendamentoExame.QuantidadeUnidade, total = agendamentoExame.Total, valorunidade = agendamentoExame.ValorUnidade }); } }
// GET: AgendamentoExame/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AgendamentoExame agendamentoExame = db.AgendamentoExame.Find(id); if (agendamentoExame == null) { return(HttpNotFound()); } ViewBag.IdPaciente = new SelectList(db.Paciente, "Id", "NomeCompleto", agendamentoExame.IdPaciente); ViewBag.IdUsuario = new SelectList(db.Usuarios, "Id", "Nome", agendamentoExame.IdUsuario); return(View(agendamentoExame)); }
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()); } }
public void Excluir(AgendamentoExame agendamentoExame) { Connection.Execute("delete from agendamentoexame where agendamentoid = @id", new { id = agendamentoExame.Id }); }
public void Excluir(AgendamentoExame agendamentoExame) { Connection.Execute("delete from exame where id = @id", agendamentoExame); }
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"); } }