Beispiel #1
0
        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 override bool ReceberAutoIncremento(QuerySelectStoredProcedure qs, CLS_QuestionarioResposta entity)
        {
            if (entity != null & qs != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        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);
            }
        }
 public override bool Delete(CLS_QuestionarioResposta entity)
 {
     __STP_DELETE = "NEW_CLS_QuestionarioResposta_UpdateSituacao";
     return(base.Delete(entity));
 }
 protected override bool Alterar(CLS_QuestionarioResposta entity)
 {
     __STP_UPDATE = "NEW_CLS_QuestionarioResposta_UPDATE";
     return(base.Alterar(entity));
 }
 protected override void ParamAlterar(QueryStoredProcedure qs, CLS_QuestionarioResposta entity)
 {
     entity.qtr_dataAlteracao = DateTime.Now;
     base.ParamAlterar(qs, entity);
     qs.Parameters.RemoveAt("@qtr_dataCriacao");
 }
 protected override void ParamInserir(QuerySelectStoredProcedure qs, CLS_QuestionarioResposta entity)
 {
     entity.qtr_dataCriacao = entity.qtr_dataAlteracao = DateTime.Now;
     base.ParamInserir(qs, entity);
 }
Beispiel #8
0
        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);
                }
            }
        }