private void mbtnAgendar_Click(object sender, EventArgs e) { /**try {*/ //se obtiene el ID del Servicio con el reglon seleccionado/// DataGridViewRow reglonServicio = dgvServicios.SelectedRows[0]; int servicioID = (int)reglonServicio.Cells[0].Value; //se obtiene el ID del Empleado con el reglon seleccionado/// DataGridViewRow reglonEmpleado = dgvEmpleado.SelectedRows[0]; int empleadoID = (int)reglonEmpleado.Cells[0].Value; TACitas taCitas = new TACitas(); TAVistaCitas taVistaCitas = new TAVistaCitas(); string fechaHora = ((dtpFechaCita.Value.ToString("MM/dd/yyyy hh:mm:ss tt")).Replace("a.m.","am")).Replace("p.m.", "pm"); int cuartoID = (int)cbCuartos.SelectedValue; //string fechaHora = dtpFechaCita.Value.ToString(); //Se busca si hay citas que hacen conflicto con la que se esta agendando VistaCitas vistaCitasConflictivas = taVistaCitas.GetDataByCitasConflictivas(clienteID, fechaHora, empleadoID, servicioID,cuartoID); //VistaCitas vistaCitasConflictivas = taVistaCitas.GetDataByCitasConflictivas2(clienteID, dtpFechaCita.Value, empleadoID, servicioID, cuartoID); if (vistaCitasConflictivas.Rows.Count == 0) {//Si no hay citas conflictivas if (ModooVentana == "Modificar") { taCitas.UpdateQueryCitaID(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, citaID); MessageBox.Show("Cita modificada satisfactoriamente.", "Modificado", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { //Se insertan los datos de la cita a la base de datos// taCitas.Insert(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, (int)cbCuartos.SelectedValue, false); MessageBox.Show("Guardado satisfactoriamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } //Se actualiza la lista de registro de citas// inicioActuaCita.actualizarRegistroCita(); } else { if (chbDosPersonas.Checked==false) { //Hay citas conflictivas, asi que se le muestran al usuario en una leyenda. FrmMostrarCitasConflictivas frmCitasConflictivas = new FrmMostrarCitasConflictivas(vistaCitasConflictivas); frmCitasConflictivas.ShowDialog(); } else { DialogResult dr = MessageBox.Show("¿Esta seguro que desea agendar dos citas en el mismo cuarto al mismo tiempo?", "Agendar citas", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { taCitas.Insert(clienteID, empleadoID, servicioID, dtpFechaCita.Value, null, null, false, (int)cbCuartos.SelectedValue, false); MessageBox.Show("Guardado satisfactoriamente.", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } //} /*catch { MessageBox.Show("Error al realizar la cita. No hay un Servicio o Empleado selecionado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); }*/ }