public void Excluir(BLL.Quizz zz) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"DELETE FROM Quizz WHERE Id_Quizz = @idquizz"; cmd.Parameters.AddWithValue("@idquizz", zz.IdQuizz); cmd.ExecuteNonQuery(); con.Desconectar(); }
public void Cadastrar1(BLL.Quizz zz) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"INSERT INTO Quizz(Nome, Id_Curso, Id_Adm) VALUES (@nome, @idCurso, @idadm)"; cmd.Parameters.AddWithValue("@nome", zz.Nome); cmd.Parameters.AddWithValue("@idcurso", zz.IdCurso); cmd.Parameters.AddWithValue("idadm", zz.IdAdm); cmd.ExecuteNonQuery(); con.Desconectar(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["usuario"] != null) { if (Session["usuario"].ToString() != string.Empty) { /*Response.Write("<script>alert('Bem-vindo, " + Session["usuario"] + "')</script>"); * * adm.IdLogin = Convert.ToInt32(Session["idlogin"]); * adm.IdAdm = admDAL.AcharAdm(adm); * * adm = admDAL.PreencherPeloID(adm); * * Session.Add("idadm", adm.IdAdm); * Session.Add("nome", adm.Nome); * Session.Add("email", adm.Email); * Session.Add("foto", adm.Foto);*/ zz.IdQuizz = 1002; zz = zzDAL.PreencherPeloID(zz); lblNome.Text = zz.Nome; pe.IdQuizz = zz.IdQuizz; pe = peDAL.PreencherPeloID2(pe); lblQuestao.Text = pe.Questao; lblRes1.Text = pe.Res1; lblRes2.Text = pe.Res2; lblRes3.Text = pe.Res3; lblRes4.Text = pe.Res4; } else { Response.Redirect("../EXTERNO/Login.aspx"); } } else { Response.Redirect("../EXTERNO/Login.aspx"); } } }
public void Atualizar(BLL.Quizz zz) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"UPDATE Quizz SET Nome = @nome WHERE Id_Quizz = @idquizz"; cmd.Parameters.AddWithValue("@idquizz", zz.IdQuizz); cmd.Parameters.AddWithValue("@nome", zz.Nome); cmd.Parameters.AddWithValue("@idcurso", zz.IdCurso); cmd.Parameters.AddWithValue("@idprofessor", zz.IdProfessor); cmd.Parameters.AddWithValue("@idadm", zz.IdAdm); cmd.ExecuteNonQuery(); con.Desconectar(); }
public DataTable Listar1(BLL.Quizz zz) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Quizz, Nome, Id_Curso, Id_Professor FROM Quizz WHERE Id_Professor = @idprofessor"; cmd.Parameters.AddWithValue("@idprofessor", zz.IdProfessor); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); con.Desconectar(); return(dt); }
public DataTable Listar2(BLL.Quizz zz) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Quizz, Nome, Id_Curso, Id_Professor, Id_Adm FROM Quizz WHERE Nome LIKE @nome"; cmd.Parameters.AddWithValue("@nome", "%" + zz.Nome + "%"); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); con.Desconectar(); return(dt); }
public BLL.Quizz PreencherPeloID(BLL.Quizz zz) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Quizz, Nome, Id_Curso, Id_Professor, Id_Adm FROM Quizz WHERE Id_Quizz LIKE @idquizz"; cmd.Parameters.AddWithValue("@idquizz", zz.IdQuizz); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); zz.IdQuizz = Convert.ToInt32(dr["Id_Quizz"]); zz.Nome = dr["Nome"].ToString(); zz.IdCurso = Convert.ToInt32(dr["Id_Curso"]); if (dr["Id_Professor"] is DBNull) { zz.IdProfessor = 0; } else { zz.IdProfessor = Convert.ToInt32(dr["Id_Professor"]); } zz.IdAdm = Convert.ToInt32(dr["Id_Adm"]); dr.Close(); } else { zz.IdQuizz = 0; } con.Desconectar(); return(zz); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["usuario"] != null) { if (Session["usuario"].ToString() != string.Empty) { ddlCurso.DataSource = cuDAL.Listar(); ddlCurso.DataTextField = "Nome"; ddlCurso.DataValueField = "Id_Curso"; ddlCurso.DataBind(); gvQuizz.DataSource = zzDAL.Listar(); gvQuizz.DataBind(); if (Request.QueryString["id"] != null) { if (Request.QueryString["id"].ToString() != "") { int idRecebido; int.TryParse(Request.QueryString["id"], out idRecebido); zz.IdQuizz = idRecebido; zz = zzDAL.PreencherPeloID(zz); if (zz.IdQuizz != 0) { //mudar visibilidade lblAtu.Visible = true; lblCad.Visible = false; lblId.Visible = true; lblIsso.Visible = true; ddlCurso.Visible = false; btnEnviar.Visible = false; btnAtualizar.Visible = true; gvQuizz.Visible = false; txtFiltro.Visible = false; btnFiltrar.Visible = false; lblId.Text = zz.IdQuizz.ToString(); lblIdC.Text = zz.IdCurso.ToString(); txtNome.Text = zz.Nome; } else { lblId.Text = "ID INVÁLIDO"; } } } } else { Response.Redirect("LoginAdm.aspx"); } } else { Response.Redirect("LoginAdm.aspx"); } } }