/// <summary> /// Metodo que guarda una cita /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_guardarCita_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txt_CedulaUsuario.Text) || string.IsNullOrWhiteSpace(txt_nombreUsuario.Text) || string.IsNullOrWhiteSpace(txt_telefonoUsuario.Text) || string.IsNullOrWhiteSpace(txt_detalleCita.Text)) { MessageBox.Show("Hay Uno o mas Campos Vacios!", "Campos Vacios!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { using (GestorCita Cita = new GestorCita()) { string cedula = txt_CedulaUsuario.Text; this.dsCitas = Cita.ConsultarCitaCedula(cedula); this.dtCitas = this.dsCitas.Tables[0]; if (dtCitas.Rows.Count > 0) { MessageBox.Show("Ya existe un usuario con esa cedula, intente de nuevo", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); limpiarCedula(); } else { if (dtpFechaCita.Value < DateTime.Now) { MessageBox.Show("La fecha debe ser una posterior a la fecha actual", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Cita.InsertarCita(txt_CedulaUsuario.Text, txt_nombreUsuario.Text, txt_telefonoUsuario.Text, txt_detalleCita.Text, dtpFechaCita.Value, "A"); bloquearCamposCita(); MessageBox.Show("Datos Registrados satisfactoriamente", "EXITO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); gbx_datosCita.Visible = false; limpiarCamposCita(); cargarGridCitas(); cargarGridCitasRecientes(); grb_menuCita.Visible = true; } } } } catch (Exception x) { MessageBox.Show("Error de SQL: " + x.Message); } } }
private void buttonInsert_Click(object sender, EventArgs e) { if ((textHoraFin.Text != string.Empty) && (textHoraIn.Text != string.Empty) && (textFecha.Text != string.Empty) && textConsultorio.Text != string.Empty) { try { cita.InsertarCita(nombreCentro, Convert.ToDateTime(textHoraIn.Text), Convert.ToDateTime(textHoraFin.Text), Convert.ToDateTime(textFecha.Text), textConsultorio.Text); MessageBox.Show("Registrado Correctamente"); textConsultorio.Text = string.Empty; textHoraIn.Text = string.Empty; textFecha.Text = string.Empty; textHoraFin.Text = string.Empty; } catch (Exception l) { MessageBox.Show("Se presento un error al insertar los datos: " + l.Message); } } else { MessageBox.Show("Ingrese todos los datos"); } }