private void modificarSolucion(clsNSolucionCuestionario modificacion) { nuevasolucion = modificacion; nuevasolucion.FECHAMODIFICACIONCUESTIONARIO = DateTime.Now; nuevasolucion.USUARIOMODIFICA = (int)ViewState["usuarioModifica"]; listaRespuestasAModificar.Add(nuevasolucion); }
public bool D_guardarRespuestaCuestionario(clsNSolucionCuestionario nuevaSolucion) { try { using (MERSembrarDataContext db = new MERSembrarDataContext()) { SOLUCIONCUESTIONARIO solucioncuestionario = new SOLUCIONCUESTIONARIO(); solucioncuestionario.IDPROCESO = nuevaSolucion.IDPROCESO; solucioncuestionario.IDOBJETIVO = nuevaSolucion.IDOBJETIVO; solucioncuestionario.IDINDICADOR = nuevaSolucion.IDINDICADOR; solucioncuestionario.IDPREGUNTA = nuevaSolucion.IDPREGUNTA; solucioncuestionario.IDPERSONA = nuevaSolucion.IDPERSONA; solucioncuestionario.IDPERIODO = nuevaSolucion.IDPERIODO; solucioncuestionario.FECHASOLUCIONCUESTIONARIO = nuevaSolucion.FECHASOLUCIONCUESTIONARIO.Date; solucioncuestionario.TEXTOSOLUCIONCUESTIONARIO = nuevaSolucion.TEXTOSOLUCIONCUESTIONARIO; db.SOLUCIONCUESTIONARIO.InsertOnSubmit(solucioncuestionario); db.SubmitChanges(); return(true); } } catch { return(false); } }
static clsNSolucionCuestionario transformar(SOLUCIONCUESTIONARIO newSolucion) { clsNSolucionCuestionario solucion = new clsNSolucionCuestionario(); solucion.FECHAMODIFICACIONCUESTIONARIO = DateTime.Parse(newSolucion.FECHAMODIFICACIONCUESTIONARIO.ToString()); solucion.FECHASOLUCIONCUESTIONARIO = newSolucion.FECHASOLUCIONCUESTIONARIO; solucion.IDINDICADOR = newSolucion.IDINDICADOR; solucion.IDOBJETIVO = newSolucion.IDOBJETIVO; solucion.IDPERIODO = newSolucion.IDPERIODO; solucion.IDPERSONA = newSolucion.IDPERSONA; solucion.IDPREGUNTA = newSolucion.IDPREGUNTA; solucion.IDPROCESO = newSolucion.IDPROCESO; solucion.IDSOLUCION = newSolucion.IDSOLUCIONCUESTIONARIO; solucion.TEXTOSOLUCIONCUESTIONARIO = newSolucion.TEXTOSOLUCIONCUESTIONARIO; return(solucion); }
private void solucionar2() { listaRespuestasAGuardar = new List <clsNSolucionCuestionario>(); listaRespuestasAModificar = new List <clsNSolucionCuestionario>(); using (TransactionScope trans = new TransactionScope()) { Cuestionario = (Table)pnlCuestionario.Controls[0]; respuestas = (List <clsNSolucionCuestionario>)Session["respuestas"]; if (!objDSolucionCuestionario.D_eliminarRespuestaMultiplesCuestionario(respuestas)) { Response.Write("<script>window.alert('Ha ocurrido un error al eliminar las respuestas anteriores');</script>"); return; } foreach (TableRow filaTabla in Cuestionario.Rows) { foreach (TableCell celdaTabla in filaTabla.Cells) { if (celdaTabla.ID != null && celdaTabla.ID.StartsWith("idObjetivo")) { string id = celdaTabla.ID.Remove(0, 10); idObjetivo = int.Parse(id.Substring(0, id.LastIndexOf("-"))); } else if (celdaTabla.ID != null && celdaTabla.ID.StartsWith("idIndicador")) { string id = celdaTabla.ID.Remove(0, 11); idIndicador = int.Parse(id.Substring(0, id.LastIndexOf("-"))); } else { foreach (Control controlTabla in celdaTabla.Controls) { if (controlTabla is TextBox && controlTabla.ID.StartsWith("txtPregunta")) { TextBox tempTextBox = (TextBox)controlTabla; string id = tempTextBox.ID.Remove(0, 11); int idPregunta = int.Parse(id.Substring(0, id.LastIndexOf("-"))); clsNSolucionCuestionario tempSolucion = respuestas.Where(s => s.IDOBJETIVO == idObjetivo && s.IDINDICADOR == idIndicador && s.IDPREGUNTA == idPregunta).First(); tempSolucion.TEXTOSOLUCIONCUESTIONARIO = tempTextBox.Text; modificarSolucion(tempSolucion); } else if (controlTabla is RadioButtonList && controlTabla.ID.StartsWith("rblPregunta")) { RadioButtonList tempRadioButtonList = (RadioButtonList)controlTabla; string id = tempRadioButtonList.ID.Remove(0, 11); int idPregunta = int.Parse(id.Substring(0, id.LastIndexOf("-"))); clsNSolucionCuestionario tempSolucion = respuestas.Where(s => s.IDOBJETIVO == idObjetivo && s.IDINDICADOR == idIndicador && s.IDPREGUNTA == idPregunta).First(); tempSolucion.TEXTOSOLUCIONCUESTIONARIO = tempRadioButtonList.Items.FindByValue(tempRadioButtonList.SelectedValue).Text; modificarSolucion(tempSolucion); } else if (controlTabla is CheckBoxList && controlTabla.ID.StartsWith("chkPregunta")) { CheckBoxList tempCheckBoxList = (CheckBoxList)controlTabla; string id = tempCheckBoxList.ID.Remove(0, 11); foreach (ListItem opcion in tempCheckBoxList.Items) { if (opcion.Selected) { guardarSolucion(int.Parse(id.Substring(0, id.LastIndexOf("-"))), opcion.Text); } } } } } } } objDSolucionCuestionario.D_guardarRespuestaCuestionario(listaRespuestasAGuardar); objDSolucionCuestionario.D_modificarRespuestaCuestionario(listaRespuestasAModificar); trans.Complete(); } }
private void modificarSolucion(clsNSolucionCuestionario modificacion) { nuevasolucion = modificacion; nuevasolucion.FECHAMODIFICACIONCUESTIONARIO = DateTime.Now; objDSolucionCuestionario.D_modificarRespuestaCuestionario(nuevasolucion); }