public static int InserirPergunta(EnquetePergunta pobjEnquetePergunta) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_I_ENQUETE_PERGUNTA"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@enqueteId", SqlDbType.Int).Value = pobjEnquetePergunta.IdEnquete; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pobjEnquetePergunta.IdIdioma; objComando.Parameters.Add("@pergunta", SqlDbType.VarChar, 400).Value = pobjEnquetePergunta.Pergunta; objComando.Parameters.Add("@resposta1", SqlDbType.VarChar, 100).Value = pobjEnquetePergunta.Resposta1; objComando.Parameters.Add("@resposta2", SqlDbType.VarChar, 100).Value = pobjEnquetePergunta.Resposta2; if (!String.IsNullOrWhiteSpace(pobjEnquetePergunta.Resposta3)) { objComando.Parameters.Add("@resposta3", SqlDbType.VarChar, 100).Value = pobjEnquetePergunta.Resposta3; } if (!String.IsNullOrWhiteSpace(pobjEnquetePergunta.Resposta4)) { objComando.Parameters.Add("@resposta4", SqlDbType.VarChar, 100).Value = pobjEnquetePergunta.Resposta4; } if (!String.IsNullOrWhiteSpace(pobjEnquetePergunta.Resposta5)) { objComando.Parameters.Add("@resposta5", SqlDbType.VarChar, 100).Value = pobjEnquetePergunta.Resposta5; } try { //Abre conexão com o banco de dados objConexao.Open(); //Declara variavel de retorno int intRetorno = 0; //Executa comando no banco de dados intRetorno = objComando.ExecuteNonQuery(); return(intRetorno); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static List <EnquetePergunta> ListarPergunta(int pintIdEnquete, int pintIdIdioma = 0) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_ENQUETE_PERGUNTA"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@enqueteId", SqlDbType.Int).Value = pintIdEnquete; if (pintIdIdioma > 0) { objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; } try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <EnquetePergunta> objList = new List <EnquetePergunta>(); EnquetePergunta obj = default(EnquetePergunta); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new EnquetePergunta(); obj.FromIDataReader(idrReader); objList.Add(obj); } return(objList); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static EnquetePergunta ObterPergunta(int pintIdPergunta, int pintIdEnquete, int pintIdIdioma) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_ENQUETE_PERGUNTA_ID"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@enquetePerguntaId", SqlDbType.Int).Value = pintIdPergunta; objComando.Parameters.Add("@enqueteId", SqlDbType.Int).Value = pintIdEnquete; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; try { objConexao.Open(); EnquetePergunta obj = new EnquetePergunta(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
protected void rptEnquete_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { EnquetePergunta item = (EnquetePergunta)e.Item.DataItem; RadioButtonList rdbResposta = (RadioButtonList)e.Item.FindControl("rdbResposta"); HiddenField hdnPerguntaId = (HiddenField)e.Item.FindControl("hdnPerguntaId"); hdnPerguntaId.Value = item.IdEnquetePergunta.ToString(); rdbResposta.Items.Add(new ListItem(item.Resposta1)); rdbResposta.Items.Add(new ListItem(item.Resposta2)); if (!string.IsNullOrEmpty(item.Resposta3)) { rdbResposta.Items.Add(new ListItem(item.Resposta3)); } if (!string.IsNullOrEmpty(item.Resposta4)) { rdbResposta.Items.Add(new ListItem(item.Resposta4)); } if (!string.IsNullOrEmpty(item.Resposta5)) { rdbResposta.Items.Add(new ListItem(item.Resposta5)); } } else if (e.Item.ItemType == ListItemType.Footer) { Button btnProximo = (Button)e.Item.FindControl("btnProximo"); if (PaginaAtual == TotalPagina) { divEtapaFinal.Visible = true; btnProximo.Visible = false; } } }
private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao) { switch (objTipoTransacao) { //Novo Grupo case Utilitarios.TipoTransacao.Limpar: ddlIdioma.SelectedIndex = 0; txtPergunta.Text = string.Empty; txtResposta1.Text = string.Empty; txtResposta2.Text = string.Empty; txtResposta3.Text = string.Empty; txtResposta4.Text = string.Empty; txtResposta5.Text = string.Empty; break; //Carregar Dados do Link case Utilitarios.TipoTransacao.Salvar: if (gobjEnquetePergunta == null) { gobjEnquetePergunta = new EnquetePergunta(); } gobjEnquetePergunta.IdEnquetePergunta = IdPergunta; gobjEnquetePergunta.IdEnquete = IdEnquete; gobjEnquetePergunta.IdIdioma = Convert.ToInt16(ddlIdioma.SelectedValue); gobjEnquetePergunta.Pergunta = txtPergunta.Text; gobjEnquetePergunta.Resposta1 = txtResposta1.Text; gobjEnquetePergunta.Resposta2 = txtResposta2.Text; if (!string.IsNullOrEmpty(txtResposta3.Text)) { gobjEnquetePergunta.Resposta3 = txtResposta3.Text; } if (!string.IsNullOrEmpty(txtResposta4.Text)) { gobjEnquetePergunta.Resposta4 = txtResposta4.Text; } if (!string.IsNullOrEmpty(txtResposta5.Text)) { gobjEnquetePergunta.Resposta5 = txtResposta5.Text; } break; //Carregar Dados do Link case Utilitarios.TipoTransacao.Carregar: ddlIdioma.SelectedValue = gobjEnquetePergunta.IdIdioma.ToString(); ddlIdioma.Enabled = false; txtPergunta.Text = gobjEnquetePergunta.Pergunta; txtResposta1.Text = gobjEnquetePergunta.Resposta1; txtResposta2.Text = gobjEnquetePergunta.Resposta2; if (!String.IsNullOrWhiteSpace(gobjEnquetePergunta.Resposta3)) { txtResposta3.Text = gobjEnquetePergunta.Resposta3; } if (!String.IsNullOrWhiteSpace(gobjEnquetePergunta.Resposta4)) { txtResposta4.Text = gobjEnquetePergunta.Resposta4; } if (!String.IsNullOrWhiteSpace(gobjEnquetePergunta.Resposta5)) { txtResposta5.Text = gobjEnquetePergunta.Resposta5; } break; } }