protected void gvwDatos_RowCommand(object sender, GridViewCommandEventArgs e) { try { int inIndice = Convert.ToInt16(e.CommandArgument); if (e.CommandName.Equals("Editar")) { lblOpcion.Text = "2"; txtCodigo.Text = ((Label)gvwDatos.Rows[inIndice].FindControl("lblCodigo")).Text; txtPregunta.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[1].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[1].Text; txtRespuestaCorrecta.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[2].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[2].Text; txtRespuestaIncorrectaUno.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[3].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[3].Text; txtRespuestaIncorrectaDos.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[4].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[4].Text; txtRespuestaIncorrectaTres.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[5].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[5].Text; txtRespuestaIncorrectaCuatro.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[6].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[6].Text; txtRespuestaIncorrectaCinco.Text = String.IsNullOrEmpty(gvwDatos.Rows[inIndice].Cells[7].Text) ? String.Empty : gvwDatos.Rows[inIndice].Cells[7].Text; } else if (e.CommandName.Equals("Eliminar")) { logica.Models.clsPreguntasJuego obclsPreguntasJuego = new logica.Models.clsPreguntasJuego { lgCodigo = Convert.ToInt32(((Label)gvwDatos.Rows[inIndice].FindControl("lblCodigo")).Text), stPregunta = String.Empty, stRespuestaCorrecta = String.Empty, stRespuestaIncorrectaUno = String.Empty, stRespuestaIncorrectaDos = String.Empty, stRespuestaIncorrectaTres = String.Empty, stRespuestaIncorrectaCuatro = String.Empty, stRespuestaIncorrectaCinco = String.Empty, obclsTematicasJuego = new logica.Models.clsTematicasJuego { lgCodigo = 0 }, obclsTipoJuego = new logica.Models.clsTipoJuego { lgCodigo = 0 }, obclsDicultadJuego = new logica.Models.clsDicultadJuego { lgCodigo = 0 } }; Controllers.PreguntasJuegoControllers obPreguntasJuegoControllers = new Controllers.PreguntasJuegoControllers(); ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('MENSAJE!', '" + obPreguntasJuegoControllers.deletePreguntasJuego(obclsPreguntasJuego) + "!','success')</Script>"); lblOpcion.Text = txtCodigo.Text = txtPregunta.Text = txtRespuestaCorrecta.Text = txtRespuestaIncorrectaUno.Text = txtRespuestaIncorrectaDos.Text = txtRespuestaIncorrectaTres.Text = txtRespuestaIncorrectaCuatro.Text = txtRespuestaIncorrectaCinco.Text = String.Empty; getPreguntasJuego(); } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'ERROR')</Script>"); } }
public String deletePreguntasJuego(logica.Models.clsPreguntasJuego obclsPreguntasJuegoModels) { try { logica.BL.clsPreguntasJuego obclsPreguntasJuego = new logica.BL.clsPreguntasJuego(); return(obclsPreguntasJuego.deletePreguntasJuego(obclsPreguntasJuegoModels)); } catch (Exception ex) { throw ex; } }
public logica.Models.clsPreguntasJuego getPregunta(List <logica.Models.clsPreguntasJuego> lstPreguntasJuego, List <int> Codigos) { try { logica.BL.clsPreguntasJuego obclsPreguntasJuego = new logica.BL.clsPreguntasJuego(); logica.Models.clsPreguntasJuego obPregunta = obclsPreguntasJuego.getPreguntaRamdon(lstPreguntasJuego, Codigos); return(obPregunta); } catch (Exception ew) { throw ew; } }
public void updateEstadoPregunta(logica.Models.clsPreguntasJuego obclsPreguntasJuegoModels) { logica.BL.clsPreguntasJuego obclsPreguntasJuego = new logica.BL.clsPreguntasJuego(); obclsPreguntasJuego.updateEstadoPregunta(obclsPreguntasJuegoModels); }
public void getPregunta() { Random rnd = new Random(); int numero = rnd.Next(1, 4); Controllers.JuegoControllers obJuegoControllers = new Controllers.JuegoControllers(); logica.Models.clsPreguntasJuego clsPreguntasJuego = obJuegoControllers.getPregunta(obJuegoControllers.getPreguntas(), lstCodigos); if (clsPreguntasJuego.stPregunta.Equals("Ya se acabaron las preguntas")) { lblPuntaje.Text = (Convert.ToInt32(lblPuntaje.Text) + 1).ToString(); Session["Puntaje"] = lblPuntaje.Text; lblPuntaje.Text = "0"; lstCodigos.Clear(); Response.Redirect("../Puntajes/Puntajes.aspx"); } else { lblPregunta.Text = clsPreguntasJuego.stPregunta; lstCodigos.Add((int)clsPreguntasJuego.lgCodigo); clsPreguntasJuego.stSalio = "Salio"; lblRespuestaCorrecta.Text = clsPreguntasJuego.stRespuestaCorrecta; if (clsPreguntasJuego.obclsTipoJuego.stDescripcion.Equals("Preguntas y Respuestas")) { string[] preguntasmalas = { clsPreguntasJuego.stRespuestaIncorrectaUno, clsPreguntasJuego.stRespuestaIncorrectaDos, clsPreguntasJuego.stRespuestaIncorrectaTres, clsPreguntasJuego.stRespuestaIncorrectaCuatro, clsPreguntasJuego.stRespuestaIncorrectaCinco }; int valor = 1; while (valor == 1) { if (numero == 1) { btnRespuestaUno.Text = clsPreguntasJuego.stRespuestaCorrecta; valor = 0; } else if (numero == 2) { btnRespuestaDos.Text = clsPreguntasJuego.stRespuestaCorrecta; valor = 0; } else if (numero == 3) { btnRespuestaTres.Text = clsPreguntasJuego.stRespuestaCorrecta; valor = 0; } else if (numero == 4) { btnRespuestaCuatro.Text = clsPreguntasJuego.stRespuestaCorrecta; valor = 0; } } int valor2 = 1; while (valor2 == 1) { int seleccion = rnd.Next(0, 4); if (btnRespuestaUno.Text.Equals("") && btnRespuestaDos.Text != preguntasmalas[seleccion] && btnRespuestaTres.Text != preguntasmalas[seleccion] && btnRespuestaCuatro.Text != preguntasmalas[seleccion]) { btnRespuestaUno.Text = preguntasmalas[seleccion]; } else if (btnRespuestaDos.Text.Equals("") && btnRespuestaUno.Text != preguntasmalas[seleccion] && btnRespuestaTres.Text != preguntasmalas[seleccion] && btnRespuestaCuatro.Text != preguntasmalas[seleccion]) { btnRespuestaDos.Text = preguntasmalas[seleccion]; } else if (btnRespuestaTres.Text.Equals("") && btnRespuestaDos.Text != preguntasmalas[seleccion] && btnRespuestaUno.Text != preguntasmalas[seleccion] && btnRespuestaCuatro.Text != preguntasmalas[seleccion]) { btnRespuestaTres.Text = preguntasmalas[seleccion]; } else if (btnRespuestaCuatro.Text.Equals("") && btnRespuestaDos.Text != preguntasmalas[seleccion] && btnRespuestaTres.Text != preguntasmalas[seleccion] && btnRespuestaUno.Text != preguntasmalas[seleccion]) { btnRespuestaCuatro.Text = preguntasmalas[seleccion]; } if (!btnRespuestaUno.Text.Equals("") && !btnRespuestaDos.Text.Equals("") && !btnRespuestaTres.Text.Equals("") && !btnRespuestaCuatro.Text.Equals("")) { valor2 = 0; } } } } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { String stMensaje = String.Empty; if (String.IsNullOrEmpty(txtCodigo.Text)) { stMensaje += "Ingrese Codigo, "; } if (String.IsNullOrEmpty(txtPregunta.Text)) { stMensaje += "Ingrese Pregunta, "; } if (String.IsNullOrEmpty(txtRespuestaCorrecta.Text)) { stMensaje += "Ingrese Respuesta Correcta, "; } if (String.IsNullOrEmpty(txtRespuestaIncorrectaUno.Text)) { stMensaje += "Ingrese Respuesta incorrecta Uno, "; } if (String.IsNullOrEmpty(txtRespuestaIncorrectaDos.Text)) { stMensaje += "Ingrese Respuesta Incorrecta Dos, "; } if (String.IsNullOrEmpty(txtRespuestaIncorrectaTres.Text)) { stMensaje += "Ingrese Respuesta Incorrecta Tres, "; } if (String.IsNullOrEmpty(txtRespuestaIncorrectaCuatro.Text)) { stMensaje += "Ingrese Respuesta Incorrecta Cuatro, "; } if (String.IsNullOrEmpty(txtRespuestaIncorrectaCinco.Text)) { stMensaje += "Ingrese Respuesta Incorrecta Cinco, "; } if (!String.IsNullOrEmpty(stMensaje)) { throw new Exception(stMensaje.TrimEnd(',')); } logica.Models.clsPreguntasJuego clsPreguntasJuego = new logica.Models.clsPreguntasJuego { lgCodigo = Convert.ToInt64(txtCodigo.Text), stPregunta = txtPregunta.Text, stRespuestaCorrecta = txtRespuestaCorrecta.Text, stRespuestaIncorrectaUno = txtRespuestaIncorrectaUno.Text, stRespuestaIncorrectaDos = txtRespuestaIncorrectaDos.Text, stRespuestaIncorrectaTres = txtRespuestaIncorrectaTres.Text, stRespuestaIncorrectaCuatro = txtRespuestaIncorrectaCuatro.Text, stRespuestaIncorrectaCinco = txtRespuestaIncorrectaCinco.Text, obclsTematicasJuego = new logica.Models.clsTematicasJuego { lgCodigo = Convert.ToInt64(ddlTematicasJuego.SelectedValue) }, obclsTipoJuego = new logica.Models.clsTipoJuego { lgCodigo = Convert.ToInt64(ddlTipoJuego.SelectedValue) }, obclsDicultadJuego = new logica.Models.clsDicultadJuego { lgCodigo = Convert.ToInt64(ddlDicultadJuego.SelectedValue) } }; Controllers.PreguntasJuegoControllers obPreguntasJuegoControllers = new Controllers.PreguntasJuegoControllers(); if (String.IsNullOrEmpty(lblOpcion.Text)) { lblOpcion.Text = "1"; } if (lblOpcion.Text.Equals("1")) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('Mensaje!,'" + obPreguntasJuegoControllers.insertarPreguntasJuego(clsPreguntasJuego) + "!','success')</Script>"); lblOpcion.Text = txtCodigo.Text = txtPregunta.Text = txtRespuestaCorrecta.Text = txtRespuestaIncorrectaUno.Text = txtRespuestaIncorrectaDos.Text = txtRespuestaIncorrectaTres.Text = txtRespuestaIncorrectaCuatro.Text = txtRespuestaIncorrectaCinco.Text = String.Empty; getPreguntasJuego(); } else if (lblOpcion.Text.Equals("2")) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('Mensaje!,'" + obPreguntasJuegoControllers.updatePreguntasJuego(clsPreguntasJuego) + "!','success')</Script>"); lblOpcion.Text = txtCodigo.Text = txtPregunta.Text = txtRespuestaCorrecta.Text = txtRespuestaIncorrectaUno.Text = txtRespuestaIncorrectaDos.Text = txtRespuestaIncorrectaTres.Text = txtRespuestaIncorrectaCuatro.Text = txtRespuestaIncorrectaCinco.Text = String.Empty; getPreguntasJuego(); } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> Swal('MENSAJE!', '" + ex.Message + "!','success')</Script>"); } }