private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtMotivo.Text.Trim()) && txtMotivo.Text.Trim().Length < 255) { MessageBox.Show("Por favor, indique el motivo de la cancelacion"); return; } switch (this.dataGridView1.SelectedRows.Count) { case 0: MessageBox.Show("Seleccione un turno a cancelar"); break; case 1: if (cancelarTurnoDelDiaCorriente(Convert.ToDateTime(dataGridView1.CurrentRow.Cells[4].Value))) { MessageBox.Show("Error, no puede cancelar un turno de hoy"); return; } else { try { CancelacionManager.cancelarTurno(Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value), Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value), txtMotivo.Text.Trim()); } catch (Exception a) { MessageBox.Show("La cancelacion no pudo realizarse"); return; } MessageBox.Show("El turno fue cancelado"); this.dataGridView1.DataSource = CancelacionManager.mostrarTurnosAfiliado(Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value)); } break; default: MessageBox.Show("Seleccione de a un turno"); break; } }
public CancelacionMedico(int id, String especialidad) { InitializeComponent(); especialidadMedico = especialidad; matricula = id; agenda = CancelacionManager.mostrarAgendaProfesional(matricula);//, especialidadMedico); if (agenda == null) { MessageBox.Show("El profesional no tiene turnos recientes"); btnDia.Hide(); btnPeriodo.Hide(); label6.Hide(); txtDesde.Enabled = false; txtDia.Enabled = false; txtHasta.Enabled = false; txtMotivo.Enabled = false; } else { this.dataAgenda.DataSource = agenda; } }
private void button1_Click(object sender, EventArgs e) { if (!txtDia.MaskCompleted) { MessageBox.Show("Por favor, ingrese un día a cancelar"); return; } if (dataAgenda.SelectedRows.Count != 1) { MessageBox.Show("Por favor seleccione la agenda de la especialidad asociada a la cancelacion"); return; } if (String.IsNullOrEmpty(txtMotivo.Text)) { MessageBox.Show("Debe especificar un motivo"); return; } DateTime horaDelSistema = DateTime.ParseExact(Program.horarioSistema, "yyyy-dd-MM HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture); try { Convert.ToDateTime(txtDia.Text.Trim()); } catch (Exception a) { MessageBox.Show("Error, ha ingresado una fecha invalida"); return; } if (horaDelSistema.CompareTo(Convert.ToDateTime(txtDia.Text.Trim())) > 0) { MessageBox.Show("La fecha inicio del periodo es mayor al dia del sistema"); txtDesde.Clear(); txtHasta.Clear(); return; } if (horaDelSistema.CompareTo(Convert.ToDateTime(txtDia.Text.Trim())) == 0) { MessageBox.Show("La cancelacion debe ser con 24 hs de antelación"); txtDesde.Clear(); txtHasta.Clear(); return; } try { especialidadMedico = dataAgenda.CurrentRow.Cells["especialidad"].Value.ToString(); DateTime variableLoca = DateTime.Now; variableLoca = Convert.ToDateTime(txtDia.Text.Trim()); CancelacionManager.cancelarDiaProfesional(matricula, variableLoca, txtMotivo.Text.Trim(), especialidadMedico); } catch (Exception b) { MessageBox.Show(b.StackTrace); return; } MessageBox.Show("Dia cancelado correctamente"); this.dataAgenda.DataSource = CancelacionManager.mostrarAgendaProfesional(matricula);//, especialidadMedico); }
private void btnPeriodo_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtMotivo.Text)) { MessageBox.Show("Debe especificar un motivo"); return; } if (!txtDesde.MaskCompleted || !txtHasta.MaskCompleted) { MessageBox.Show("Ingrese ambas fechas del período"); return; } if (dataAgenda.SelectedRows.Count != 1) { MessageBox.Show("Por favor seleccione la agenda de la especialidad asociada a la cancelacion"); return; } try { Convert.ToDateTime(txtDesde.Text.Trim()); Convert.ToDateTime(txtHasta.Text.Trim()); } catch (Exception z) { MessageBox.Show("Las fechas insertadas son invalidas"); return; } if (DateTime.Compare(Convert.ToDateTime(txtDesde.Text), Convert.ToDateTime(txtHasta.Text)) > 0) { MessageBox.Show("La fecha inicio del periodo es mayor a la final"); txtDesde.Clear(); txtHasta.Clear(); return; } DateTime horaDelSistema = DateTime.ParseExact(Program.horarioSistema, "yyyy-dd-MM HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture); if (horaDelSistema.CompareTo(Convert.ToDateTime(txtDesde.Text.Trim())) > 0) { MessageBox.Show("La fecha inicio del periodo es mayor al dia del sistema"); txtDesde.Clear(); txtHasta.Clear(); return; } if (horaDelSistema.CompareTo(Convert.ToDateTime(txtDesde.Text.Trim())) == 0) { MessageBox.Show("La cancelación debe ser con 24 hs de antelacion"); txtDesde.Clear(); txtHasta.Clear(); return; } try { DateTime fechaInicio = DateTime.Now; DateTime fechaFinal = DateTime.Now; fechaInicio = Convert.ToDateTime(txtDesde.Text.Trim()); fechaFinal = Convert.ToDateTime(txtHasta.Text.Trim()); especialidadMedico = dataAgenda.CurrentRow.Cells["especialidad"].Value.ToString(); CancelacionManager.cancelarPeriodoProfesional(matricula, fechaInicio, fechaFinal, txtMotivo.Text.Trim(), especialidadMedico); } catch (Exception b) { MessageBox.Show(b.Message); return; } MessageBox.Show("Periodo cancelado correctamente"); this.dataAgenda.DataSource = CancelacionManager.mostrarAgendaProfesional(matricula); }
public CancelacionAfiliado(int id) { InitializeComponent(); this.dataGridView1.DataSource = CancelacionManager.mostrarTurnosAfiliado(id); }