Beispiel #1
0
        private void btnCancelarTurno_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != string.Empty && textBox1.Text != string.Empty)
            {
                if (dtpFecha.Value > ConfigTime.getFechaSinHora())
                {
                    if (dataGridView1.SelectedRows.Count == 1)
                    {
                        DataGridViewRow r = new DataGridViewRow();
                        r = dataGridView1.SelectedRows[0];
                        Turno turno = (Turno)r.DataBoundItem;
                        Dictionary <string, object> parametros = new Dictionary <string, object>()
                        {
                            { "@nroturno", turno.Id },
                            { "@nroafiliado", afiliado.NroAfiliado },
                            { "@fecha", dtpFecha.Value.Date },
                            { "@motivo", textBox1.Text },
                            { "@tipo", comboBox1.Text }
                        };
                        List <Turno> t = new List <Turno>();
                        try
                        {
                            t = ConexionesDB.ExecuteReader("Cancelar_Turno_Afiliado", parametros).ToTurno();
                            //dataGridView1.DataSource = t;
                        }
                        catch {
                            MessageBox.Show("Error al cancelar el turno, intente nuevamente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe seleccionar 1 fila", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Debe ingresar una fecha mayor a la de hoy", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Debe completar todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            MessageBox.Show("Se cancelo el turno con exito", "Cancelado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Hide();
            Main           amostrar = null;
            FormCollection fc       = Application.OpenForms;

            foreach (Form frm in fc)
            {
                if (frm.Name == "Main")
                {
                    amostrar = (Main)frm;
                }
            }
            if (amostrar != null)
            {
                amostrar.Show();
            }
        }
 public void actualizarTurnos()
 {
     dgv_turno.DataSource = null;
     turnos = Turno.traerTurnosCancelablesAfiliado(id_afiliado, ClinicaFrba.Utils.Fechas.getCurrentDateTime());
     dgv_turno.DataSource = turnos;
 }