/// <summary> /// Acepta una solicitud realizada por un usuario /// </summary> public int AceptarSolicitud() { int iResultado = 1000; cUDGDFSOLICITUDNegocios cSolicitud = new cUDGDFSOLICITUDNegocios(0, "", 0, ""); cUDGDFAPROBACIONNegocios cAprobacion = new cUDGDFAPROBACIONNegocios(0, "", 0, ""); cUDGDFRESERVACIONNegocios cReservacion = new cUDGDFRESERVACIONNegocios(0, "", 0, ""); cUDGDFNTIFICACIONNegocios cNotificacion = new cUDGDFNTIFICACIONNegocios(0, "", 0, ""); String sNotificacionMessage; DataRow drSolicitud = cSolicitud.BuscarConId(_id_Solicitud).Rows[0]; cNotificacion.ID_NOTIFICACION = 1; try { sNotificacionMessage = cNotificacion.SeleccionarUno().Rows[0][1].ToString(); }catch { sNotificacionMessage = "Su solicitud ha sido procesada. Para más informacion del resultado comuniquese con la unidad de deportes del Instituto Tecnológico de Costa Rica."; } //DateTime p_fecinicio, DateTime p_fecfin, DateTime p_hrainicio, DateTime p_hrafin, int p_idInstalacion iResultado = cReservacion.ConsultarDisponibilidad((DateTime)drSolicitud[1], (DateTime)drSolicitud[2], DateTime.Parse(drSolicitud[4].ToString()), DateTime.Parse(drSolicitud[5].ToString()), int.Parse(drSolicitud[18].ToString())); if (iResultado == 1) { // Realiza la reservacion para la solicitud especificada cReservacion.FEC_FECHAFIN = (DateTime)drSolicitud[2]; cReservacion.FEC_FECHAINICIO = (DateTime)drSolicitud[1]; cReservacion.HRA_HORAINICIO = DateTime.Parse(drSolicitud[4].ToString()); cReservacion.HRA_HORAFIN = DateTime.Parse(drSolicitud[5].ToString()); cReservacion.Insertar(); // Ingresa la solicitud como aceptada cAprobacion.FKY_RESEREVACION = cReservacion.ID_RESERVACION; cAprobacion.FKY_SOLICITUD = int.Parse(drSolicitud[0].ToString()); cAprobacion.Insertar(); // Actualiza la solicitud estableciendola como atendida cSolicitud.ActualizarAtendidoConID(int.Parse(drSolicitud[0].ToString())); // Envia un correo al usuario this.EnviarCorreo(drSolicitud[13].ToString(), drSolicitud[6].ToString(), sNotificacionMessage); return 1; } else return -1; }
private int ValidarDiaInstalacion(DateTime p_fecinicio, DateTime p_fecfin, int p_idInstalacion, cUDGDFRESERVACIONNegocios Nueva_Consulta) { int retorno = -1000; while (p_fecinicio <= p_fecfin) { retorno = Nueva_Consulta.ConsultarDisponibilidadDia(p_fecinicio, p_idInstalacion); if (retorno == -1) break; p_fecinicio=p_fecinicio.AddDays(1); } return retorno; }
protected void boton_enviar_solicitud_Click(object sender, EventArgs e) { try { if (Page.IsValid == true) { int fecha = 0; cUDGDFRESERVACIONNegocios Nueva_Consulta = new cUDGDFRESERVACIONNegocios(0, "", 0, ""); int iResultado = -1000; int iResultadoDia = -1000; string tiHRA_HORAINICIO = txt_Inicio.Text + ":00 " + ddlAmPm1.SelectedItem.Value.ToString(); string tiHRA_HORAFIN = txt_Fin.Text + ":00 " + ddlAmPm2.SelectedItem.Value.ToString(); if (ddlAmPm1.SelectedItem.Value.ToString() == "MD") { tiHRA_HORAINICIO = txt_Inicio.Text + ":00 " + "PM"; } if (ddlAmPm2.SelectedItem.Value.ToString() == "MD") { tiHRA_HORAFIN = txt_Fin.Text + ":00 " + "PM"; } fecha = validaFechas(Convert.ToDateTime(txt_FechaInicio.Text.ToString()), Convert.ToDateTime(txt_FechaFin.Text.ToString()), DateTime.Parse(tiHRA_HORAINICIO), DateTime.Parse(tiHRA_HORAFIN)); iResultado = Nueva_Consulta.ConsultarDisponibilidad(Convert.ToDateTime(txt_FechaInicio.Text.ToString()), Convert.ToDateTime(txt_FechaFin.Text.ToString()), DateTime.Parse(tiHRA_HORAINICIO), DateTime.Parse(tiHRA_HORAFIN), iIDInstalacion); iResultadoDia = ValidarDiaInstalacion(Convert.ToDateTime(txt_FechaInicio.Text.ToString()), Convert.ToDateTime(txt_FechaFin.Text.ToString()), iIDInstalacion, Nueva_Consulta); if (iResultado == 1 && iResultadoDia == 1 && fecha == 1) { cUDGDFSOLICITUDNegocios Nueva_Solicitud = new cUDGDFSOLICITUDNegocios(0, "", 0, ""); Nueva_Solicitud.FKY_INSTALACION = iIDInstalacion; Nueva_Solicitud.FEC_INICIO = Convert.ToDateTime(txt_FechaInicio.Text.ToString()); Nueva_Solicitud.FEC_FIN = Convert.ToDateTime(txt_FechaFin.Text.ToString()); Nueva_Solicitud.FEC_SOLICITUD = DateTime.Now; Nueva_Solicitud.HRA_INICIO = DateTime.Parse(tiHRA_HORAINICIO); Nueva_Solicitud.HRA_FIN = DateTime.Parse(tiHRA_HORAFIN); Nueva_Solicitud.NOM_ENCARGADO = TextBox_responsable.Text.ToString(); Nueva_Solicitud.NOM_INSTITUCION = TextBox_Solicitante.Text.ToString(); Nueva_Solicitud.COD_IDENTIFICACION = TextBox_identificacion.Text.ToString(); Nueva_Solicitud.CAN_USUARIOSH = Int32.Parse(TextBox_cantidadh.Text.ToString()); Nueva_Solicitud.CAN_USUARIOSM = Int32.Parse(TextBox_cantidadm.Text.ToString()); cUDGDFTPSOLTNTENegocios Solicitante = new cUDGDFTPSOLTNTENegocios(0, "", 0, ""); Nueva_Solicitud.FKY_TIPOSOLICITANTE = Solicitante.BuscarID(DropDownList1.Text.ToString()); Nueva_Solicitud.TXT_OBSERVACIONES = null; Nueva_Solicitud.DSC_RAZONUSO = txt_razonUso.Value.ToString(); Nueva_Solicitud.COD_TIPOSOLICITUD = DropDownList2.Text.ToString(); Nueva_Solicitud.TXT_CORREO = TextBox_correo.Text.ToString(); Nueva_Solicitud.COD_ATENDIDO = false; Nueva_Solicitud.TXT_USUARIOS = Textarea_involucradas.Value.ToString(); Nueva_Solicitud.Insertar(); Response.Redirect("/frmNotificacion.aspx?op=notCor", true); } if (iResultadoDia == -1) { Response.Redirect("/frmErrorDia.aspx", true); } if (fecha == -1) { Response.Redirect("/frmErrorFechas.aspx", true); } else Response.Redirect("/frmError.aspx", true); } } catch (Exception) { } TimeValidator1.Visible = true; TimeValidator2.Visible = true; DateValidator1.Visible = true; DateValidator2.Visible = true; EmailValidator.Visible = true; NumberValidatorh.Visible = true; NumberValidatorm.Visible = true; InvolucradasValidator.Visible = true; ValidaSolicitante.Visible = true; ValidaResponsable.Visible = true; ValidaIdentificacion.Visible = true; ValidaRazonUso.Visible = true; InvolucradasValidator.Visible = true; }
protected void img_DEL_Click(object sender, ImageClickEventArgs e) { cUDGDFRESERVACIONNegocios cReservacion = new cUDGDFRESERVACIONNegocios(0, "", 0, ""); cUDGDFCURSONegocios cCurso = new cUDGDFCURSONegocios(0, "", 0, ""); try { // Elimina el curso cCurso.ID_CURSO = int.Parse(lbl_ID_CURSO.Text); cCurso.Eliminar(); // Elimina la reservacion cReservacion.ID_RESERVACION = int.Parse(lbl_ID_RESERVACION.Text); cReservacion.Eliminar(); } catch (Exception) { // Redirecciona hacia mensaje de error Response.Redirect("~/frmNotificacion.aspx?sol=0&op=notInc", true); } // Redirecciona a la confirmación Response.Redirect("~/Confirmacion.aspx", true); }
protected void btn_Guardar_Click(object sender, ImageClickEventArgs e) { if (Page.IsValid == true) { int Fechas = validaFechas(Convert.ToDateTime(txt_FEC_INICIO.Text.ToString()), Convert.ToDateTime(txt_FEC_FIN.Text.ToString())); int CheckDias = validaCheck(chk_LUNES.Checked, chk_MARTES.Checked, chk_MIERCOLES.Checked, chk_JUEVES.Checked, chk_VIERNES.Checked, chk_SABADO.Checked, chk_DOMINGO.Checked); if (Fechas == 1 && CheckDias == 1) { lbl_ErrorCalendario.Visible = false; lbl_ErrorNombre.Visible = false; cUDGDFCALENDARIONegocios cCalendario = new cUDGDFCALENDARIONegocios(0, "", 0, ""); cUDGDFRESERVACIONNegocios cReservacion = new cUDGDFRESERVACIONNegocios(0, "", 0, ""); cUDGDFINSTALACIONNegocios cInstalacion = new cUDGDFINSTALACIONNegocios(0, "", 0, ""); cUDGDFCURSONegocios cCurso = new cUDGDFCURSONegocios(0, "", 0, ""); DateTime dFechaInicio, dFechafin, dhorainicio, dhorafin; dFechaInicio = DateTime.Parse(txt_FEC_INICIO.Text); dFechafin = DateTime.Parse(txt_FEC_FIN.Text); dhorainicio = DateTime.Parse(txt_HRA_INICIO.Text + drp_TIME_INIT.Text); dhorafin = DateTime.Parse(txt_HRA_FIN.Text + drp_TIME_FIN.Text); // Obtiene el id del calendario cCalendario.FKY_INSTALACION = cInstalacion.obtener_ID(drp_INSTALACION.Text); int iID_CALENDARIO = (int)cCalendario.SeleccionarTodos_Con_FKY_INSTALACION_FK().Rows[0][0]; //int iDisponibilidad = cReservacion.ConsultarDisponibilidadCalendario(dFechaInicio, dFechafin, dhorainicio, dhorafin, int.Parse(lbl_ID_INSTALACION.Text)); if (lbl_NOM_CURSO.Text.CompareTo(txt_NOMBRE.Text) == 0 || !cCurso.Comprobar_Nombre(txt_NOMBRE.Text)) { try { // Actualiza la reservacion cReservacion.FEC_FECHAINICIO = dFechaInicio; cReservacion.FEC_FECHAFIN = dFechafin; cReservacion.HRA_HORAINICIO = dhorainicio; cReservacion.HRA_HORAFIN = dhorafin; cReservacion.ID_RESERVACION = int.Parse(lbl_ID_RESERVACION.Text); cReservacion.Actualizar(); // Actualiza el evento cCurso.NOM_PROFESOR = txt_PROFESOR.Text; cCurso.NOM_CURSO = txt_NOMBRE.Text; cCurso.COD_LUNES = chk_LUNES.Checked; cCurso.COD_MARTES = chk_MARTES.Checked; cCurso.COD_MIERCOLES = chk_MIERCOLES.Checked; cCurso.COD_JUEVES = chk_JUEVES.Checked; cCurso.COD_VIERNES = chk_VIERNES.Checked; cCurso.COD_SABADO = chk_SABADO.Checked; cCurso.COD_DOMINGO = chk_DOMINGO.Checked; cCurso.FKY_CALENDARIO = iID_CALENDARIO; cCurso.FKY_RESERVACION = int.Parse(lbl_ID_RESERVACION.Text); cCurso.ID_CURSO = int.Parse(lbl_ID_CURSO.Text); cCurso.Actualizar(); } catch (Exception) { Response.Redirect("~/frmNotificacion.aspx?sol=0&op=notInc", true); } // Redirecciona hacia confirmacion Response.Redirect("~/Confirmacion.aspx"); } else lbl_ErrorNombre.Visible = true; } if (Fechas == -1) { Response.Redirect("/frmErrorFechas.aspx", true); } if (CheckDias == -1) { Response.Redirect("/frmErrorCheck.aspx", true); } } }
protected void img_DEL_Click(object sender, ImageClickEventArgs e) { cUDGDFRESERVACIONNegocios cReservacion = new cUDGDFRESERVACIONNegocios(0, "", 0, ""); cUDGDFEVENTONegocios cEvento = new cUDGDFEVENTONegocios(0, "", 0, ""); try { // Elimina el evento cEvento.ID_EVENTO = int.Parse(lbl_ID_EVENTO.Text); cEvento.Eliminar(); // Elimina la reservacion cReservacion.ID_RESERVACION = int.Parse(lbl_ID_RESERVACION.Text); cReservacion.Eliminar(); } catch (Exception) { Response.Redirect("~/frmNotificacion.aspx?sol=0&op=notInc", true); } Response.Redirect("~/Confirmacion.aspx", true); }