private void _Carregar(int qtc_id, int qtr_id) { try { CLS_QuestionarioResposta Resposta = new CLS_QuestionarioResposta { qtc_id = qtc_id, qtr_id = qtr_id }; CLS_QuestionarioRespostaBO.GetEntity(Resposta); CLS_Questionario Questionario = CLS_QuestionarioBO.GetEntity(new CLS_Questionario { qst_id = _VS_qst_id }); CLS_QuestionarioConteudo Conteudo = CLS_QuestionarioConteudoBO.GetEntity(new CLS_QuestionarioConteudo { qst_id = _VS_qst_id, qtc_id = _VS_qtc_id }); ExibePeso = ((Conteudo.qtc_tipoResposta == (byte)QuestionarioTipoResposta.SelecaoUnica) || (Conteudo.qtc_tipoResposta == (byte)QuestionarioTipoResposta.MultiplaSelecao)) && (Questionario.qst_tipoCalculo != (byte)QuestionarioTipoCalculo.SemCalculo); _VS_qtr_id = Resposta.qtr_id; _VS_qtc_id = Resposta.qtc_id; _txtTexto.Text = Resposta.qtr_texto; divPeso.Visible = ExibePeso; _txtPeso.Text = divPeso.Visible ? String.Format("{0:0.00}", Resposta.qtr_peso) : String.Format("{0:0.00}", 0); _chkPermiteAdicionarTexto.Checked = Resposta.qtr_permiteAdicionarTexto; } catch (Exception e) { ApplicationWEB._GravaErro(e); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar a resposta.", UtilBO.TipoMensagem.Erro); } }
protected void ddlPergunta_SelectedIndexChanged(object sender, EventArgs e) { try { if (Convert.ToInt32(ddlPergunta.SelectedValue) > 0) { ddlResposta.Items.Clear(); ddlResposta.DataSource = CLS_QuestionarioRespostaBO.SelectByConteudo(Convert.ToInt32(ddlPergunta.SelectedValue)); ddlResposta.DataTextField = "qtr_texto"; ddlResposta.DataValueField = "qtr_id"; ddlResposta.Items.Insert(0, new ListItem("-- Selecione uma resposta --", "-1", true)); ddlResposta.AppendDataBoundItems = true; ddlResposta.DataBind(); ddlResposta.Enabled = true; } else { ddlResposta.Enabled = false; } ddlResposta.SelectedIndex = 0; } catch (Exception ex) { ApplicationWEB._GravaErro(ex); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "ScrollToTop", "setTimeout('window.scrollTo(0,0);', 0);", true); lblMessage.Text = UtilBO.GetErroMessage("Erro ao carregar perguntas.", UtilBO.TipoMensagem.Erro); } }
protected void grvResultado_DataBound(object sender, EventArgs e) { // Mostra o total de registros UCTotalRegistros1.Total = CLS_QuestionarioRespostaBO.GetTotalRecords(); if (grvResultado.Rows.Count > 0) { ((ImageButton)grvResultado.Rows[0].FindControl("_btnSubir")).Style.Add("visibility", "hidden"); ((ImageButton)grvResultado.Rows[grvResultado.Rows.Count - 1].FindControl("_btnDescer")).Style.Add("visibility", "hidden"); } }
/// <summary> /// Carrega os questionarios /// </summary> private void CarregaQuestionarios() { List <REL_GraficoAtendimento_FiltrosPersonalizados> lstFiltrosPersonalizados = REL_GraficoAtendimento_FiltrosPersonalizadosBO.SelectBy_gra_id(VS_gra_id); VS_listQuestionarioConteudoResposta = new List <QuestionarioConteudoResposta>(); QuestionarioConteudoResposta qcr; foreach (REL_GraficoAtendimento_FiltrosPersonalizados gfp in lstFiltrosPersonalizados) { qcr = new QuestionarioConteudoResposta { qtr_id = gfp.qtr_id }; qcr = CLS_QuestionarioRespostaBO.GetEntityQuestionarioConteudoResposta(qcr); qcr.IsNew = gfp.IsNew; VS_listQuestionarioConteudoResposta.Add(qcr); } gvQuestionario.DataSource = VS_listQuestionarioConteudoResposta.OrderBy(f => f.qst_titulo).ThenBy(f => f.qtc_texto).ThenBy(f => f.qtr_texto); gvQuestionario.DataBind(); }
private void _Salvar() { try { CLS_QuestionarioResposta Resposta = new CLS_QuestionarioResposta { qtr_id = _VS_qtr_id , qtc_id = _VS_qtc_id }; CLS_QuestionarioRespostaBO.GetEntity(Resposta); if (_txtTexto.Text.Length > 4000) { throw new ValidationException("O texto da resposta não deve exceder 4000 caracteres."); } decimal peso = 0; if (ExibePeso) { Decimal.TryParse(_txtPeso.Text, out peso); if (peso < 0) { throw new ValidationException("O peso da resposta deve ser maior ou igual a zero."); } } Resposta.qtr_texto = _txtTexto.Text; Resposta.qtr_permiteAdicionarTexto = _chkPermiteAdicionarTexto.Checked; Resposta.qtr_peso = peso; Resposta.qtr_situacao = 1; //ativo if (CLS_QuestionarioRespostaBO.Save(Resposta)) { if (_VS_qtr_id <= 0) { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "qtc_id: " + Resposta.qtc_id + "qtr_id: " + Resposta.qtr_id); __SessionWEB.PostMessages = UtilBO.GetErroMessage("Resposta incluída com sucesso.", UtilBO.TipoMensagem.Sucesso); } else { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "qtc_id: " + Resposta.qtc_id + "qtr_id: " + Resposta.qtr_id); __SessionWEB.PostMessages = UtilBO.GetErroMessage("Resposta alterada com sucesso.", UtilBO.TipoMensagem.Sucesso); } Session["qtc_id"] = _VS_qtc_id; Session["qst_id"] = _VS_qst_id; Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "Configuracao/Questionario/BuscaResposta.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else { _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar a resposta.", UtilBO.TipoMensagem.Erro); } } catch (ValidationException e) { _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta); } catch (DuplicateNameException e) { _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta); } catch (ArgumentException e) { _lblMessage.Text = UtilBO.GetErroMessage(e.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception e) { ApplicationWEB._GravaErro(e); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar a resposta.", UtilBO.TipoMensagem.Erro); } }
protected void grvResultado_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Deletar") { try { int index = int.Parse(e.CommandArgument.ToString()); int qtr_id = Convert.ToInt32(grvResultado.DataKeys[index].Values["qtr_id"]); CLS_QuestionarioResposta entity = new CLS_QuestionarioResposta { qtr_id = qtr_id }; if (CLS_QuestionarioRespostaBO.Delete(entity)) { grvResultado.PageIndex = 0; grvResultado.DataBind(); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "qtr_id: " + entity.qtr_id + ", qtc_id: " + entity.qtc_id); lblMessage.Text = UtilBO.GetErroMessage("Resposta excluída com sucesso.", UtilBO.TipoMensagem.Sucesso); } } catch (ValidationException ex) { lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao excluir resposta.", UtilBO.TipoMensagem.Erro); } } if (e.CommandName == "Subir") { try { int index = int.Parse(e.CommandArgument.ToString()); int qtr_idDescer = Convert.ToInt32(grvResultado.DataKeys[index - 1]["qtr_id"]); int qtr_ordemDescer = Convert.ToInt32(grvResultado.DataKeys[index]["qtr_ordem"]); CLS_QuestionarioResposta entityDescer = new CLS_QuestionarioResposta { qtr_id = qtr_idDescer, qtc_id = _VS_qtc_id }; CLS_QuestionarioRespostaBO.GetEntity(entityDescer); entityDescer.qtr_ordem = qtr_ordemDescer; int qtr_idSubir = Convert.ToInt32(grvResultado.DataKeys[index]["qtr_id"]); int qtr_ordemSubir = Convert.ToInt32(grvResultado.DataKeys[index - 1]["qtr_ordem"]); CLS_QuestionarioResposta entitySubir = new CLS_QuestionarioResposta { qtr_id = qtr_idSubir, qtc_id = _VS_qtc_id }; CLS_QuestionarioRespostaBO.GetEntity(entitySubir); entitySubir.qtr_ordem = qtr_ordemSubir; if (CLS_QuestionarioRespostaBO.SaveOrdem(entityDescer, entitySubir)) { grvResultado.DataBind(); grvResultado.PageIndex = 0; grvResultado.DataBind(); } ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "qtr_id: " + qtr_idSubir + ", qtc_id: " + _VS_qtc_id); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "qtr_id: " + qtr_idDescer + ", qtc_id: " + _VS_qtc_id); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro); } } if (e.CommandName == "Descer") { try { int index = int.Parse(e.CommandArgument.ToString()); int qtr_idDescer = Convert.ToInt32(grvResultado.DataKeys[index]["qtr_id"]); int qtr_ordemDescer = Convert.ToInt32(grvResultado.DataKeys[index + 1]["qtr_ordem"]); CLS_QuestionarioResposta entityDescer = new CLS_QuestionarioResposta { qtr_id = qtr_idDescer, qtc_id = _VS_qtc_id }; CLS_QuestionarioRespostaBO.GetEntity(entityDescer); entityDescer.qtr_ordem = qtr_ordemDescer; int qtr_idSubir = Convert.ToInt32(grvResultado.DataKeys[index + 1]["qtr_id"]); int qtr_ordemSubir = Convert.ToInt32(grvResultado.DataKeys[index]["qtr_ordem"]); CLS_QuestionarioResposta entitySubir = new CLS_QuestionarioResposta { qtr_id = qtr_idSubir, qtc_id = _VS_qtc_id }; CLS_QuestionarioRespostaBO.GetEntity(entitySubir); entitySubir.qtr_ordem = qtr_ordemSubir; if (CLS_QuestionarioRespostaBO.SaveOrdem(entityDescer, entitySubir)) { grvResultado.DataBind(); grvResultado.PageIndex = 0; grvResultado.DataBind(); } ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "qtr_id: " + qtr_idSubir + ", qtc_id: " + _VS_qtc_id); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "qtr_id: " + qtr_idDescer + ", qtc_id: " + _VS_qtc_id); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro); } } }