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>"); pro.IdLogin = Convert.ToInt32(Session["idlogin"]); pro.IdProfessor = proDAL.AcharProf(pro); pro = proDAL.PreencherPeloID(pro); Session.Add("idprof", pro.IdProfessor); Session.Add("nome", pro.Nome); Session.Add("email", pro.Email); Session.Add("telefone", pro.Telefone); Session.Add("descricao", pro.Descricao); Session.Add("foto", pro.Foto); Session.Add("cpf", pro.Cpf); //se precisar faz para idlogin } else { Response.Redirect("../ADMINISTRADOR/LoginAdm.aspx"); } } else { Response.Redirect("../ADMINISTRADOR/LoginAdm.aspx"); } } }
public BLL.Professor PreencherPeloID(BLL.Professor pro) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Professor, Nome, Email, Telefone, Descricao, Foto, cpf, Id_Login from Professor Where Id_Login = @idlogin"; cmd.Parameters.AddWithValue("@idlogin", pro.IdLogin); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); pro.IdProfessor = Convert.ToInt32(dr["Id_Professor"]); pro.Nome = dr["Nome"].ToString(); pro.Email = dr["Email"].ToString(); pro.Telefone = dr["Telefone"].ToString(); pro.Descricao = dr["Descricao"].ToString(); pro.Foto = dr["Foto"].ToString(); pro.Cpf = dr["Cpf"].ToString(); pro.IdLogin = Convert.ToInt32(dr["Id_Login"]); dr.Close(); } else { pro.IdProfessor = 0; } con.Desconectar(); return(pro); }
public BLL.Professor Login(BLL.Professor pro) { SqlDataReader dr; SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"select CodProf, Nome,Rg,Cpf,Etec,Email,CREF,senha from Professor Where Email = @email and Senha = @senha"; cmd.Parameters.AddWithValue("@email", pro.Email); cmd.Parameters.AddWithValue("@senha", pro.Senha); dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); pro.CodProf = Convert.ToInt32(dr["CodProf"]); pro.Nome = dr["Nome"].ToString(); pro.Email = dr["Email"].ToString(); pro.CPF = dr["Cpf"].ToString(); pro.RG = dr["Rg"].ToString(); pro.CREF = dr["CREF"].ToString(); pro.Senha = dr["Senha"].ToString(); pro.Etec = dr["Etec"].ToString(); } else { pro.CodProf = 0; } return(pro); }
public void Excluir(BLL.Professor pro) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"DELETE FROM Professor WHERE Id_Professor = @idprofessor"; cmd.Parameters.AddWithValue("@idprofessor", pro.IdProfessor); cmd.ExecuteNonQuery(); con.Desconectar(); }
public void Cadastrar(BLL.Professor PF) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"Insert into Professor(Nome,Rg,Cpf,Etec,Email,CREF,senha) Values(@Nome,@Rg,@Cpf,@Etec,@Email,@CREF,@senha)"; cmd.Parameters.AddWithValue("@nome", PF.Nome); cmd.Parameters.AddWithValue("@Rg", PF.RG); cmd.Parameters.AddWithValue("@Cpf", PF.CPF); cmd.Parameters.AddWithValue("@Etec", PF.Etec); cmd.Parameters.AddWithValue("@Email", PF.Email); cmd.Parameters.AddWithValue("@CREF", PF.CREF); cmd.Parameters.AddWithValue("@senha", PF.Senha); cmd.ExecuteNonQuery(); con.Desconectar(); }
public DataTable Listar(BLL.Professor pro) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Professor, Nome, Email, Telefone, Descricao, Foto, cpf, Id_Login from Professor WHERE Nome LIKE @nome"; cmd.Parameters.AddWithValue("@nome", "%" + pro.Nome + "%"); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); con.Desconectar(); return(dt); }
public void Atualizar(BLL.Professor pro) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"UPDATE Professor SET Nome = @nome, Email = @email, Telefone = @telefone , Descricao = @descricao, Foto = @foto, Cpf = @cpf WHERE Id_Professor = @idprofessor"; cmd.Parameters.AddWithValue("@idprofessor", pro.IdProfessor); cmd.Parameters.AddWithValue("@nome", pro.Nome); cmd.Parameters.AddWithValue("@email", pro.Email); cmd.Parameters.AddWithValue("@telefone", pro.Telefone); cmd.Parameters.AddWithValue("@descricao", pro.Descricao); cmd.Parameters.AddWithValue("@foto", pro.Foto); cmd.Parameters.AddWithValue("@cpf", pro.Cpf); cmd.ExecuteNonQuery(); con.Desconectar(); }
public void Cadastrar(BLL.Professor pro) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"INSERT INTO Professor(Nome, Email, Telefone, Descricao, Foto, cpf, Id_Login) VALUES (@nome, @email, @telefone, @descricao, @foto, @cpf, @idlogin)"; cmd.Parameters.AddWithValue("@nome", pro.Nome); cmd.Parameters.AddWithValue("@email", pro.Email); cmd.Parameters.AddWithValue("@telefone", pro.Telefone); cmd.Parameters.AddWithValue("@descricao", pro.Descricao); cmd.Parameters.AddWithValue("@foto", pro.Foto); cmd.Parameters.AddWithValue("@cpf", pro.Cpf); cmd.Parameters.AddWithValue("@idlogin", pro.IdLogin); cmd.ExecuteNonQuery(); con.Desconectar(); }
protected void btnCadP_Click(object sender, EventArgs e) { BLL.Professor Prof = new BLL.Professor(); Prof.Nome = txtNomeP.Text; Prof.RG = txtRGP.Text; Prof.CPF = txtCPFP.Text; Prof.CREF = txtCref.Text; Prof.Email = txtEmailP.Text; Prof.Etec = ddlETEC.SelectedValue; Prof.Senha = txtSenhaP.Text; DAL.ProfessorDAL ProfDAL = new DAL.ProfessorDAL(); ProfDAL.Cadastrar(Prof); Response.Write("<script>alert('Cadastro Efetuado')</script>"); Response.Redirect("Index.aspx"); }
public int AcharProf(BLL.Professor pro) { int la = 1; DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con.Conectar(); cmd.CommandText = @"SELECT Id_Professor, Nome, Email, Telefone, Descricao, Foto, cpf, Id_Login from Professor WHERE Id_Login LIKE @idlogin"; cmd.Parameters.AddWithValue("@idlogin", pro.IdLogin); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { dr.Read(); pro.IdProfessor = Convert.ToInt32(dr["Id_Professor"]); pro.Nome = dr["Nome"].ToString(); pro.Email = dr["Email"].ToString(); pro.Telefone = dr["Telefone"].ToString(); pro.Descricao = dr["Descricao"].ToString(); pro.Foto = dr["Foto"].ToString(); pro.Cpf = dr["Cpf"].ToString(); pro.IdLogin = Convert.ToInt32(dr["Id_Login"]); dr.Close(); } else { pro.IdLogin = 0; //tava antes idprofessor } con.Desconectar(); return(la); }
protected void btnEntrar_Click(object sender, EventArgs e) { BLL.Atleta AT = new BLL.Atleta(); BLL.Professor PF = new BLL.Professor(); BLL.Torcedor TO = new BLL.Torcedor(); //FAZ UM DESSE DE ADMINISTRADOR string ca = ddlgn.SelectedValue; if (ca == "Professor") { BLL.Professor pro = new BLL.Professor(); pro.Email = txtEmail.Text; pro.Senha = txtSenha.Text; DAL.ProfessorDAL proDAL = new DAL.ProfessorDAL(); pro = proDAL.Login(pro); if (pro.CodProf == 0) { Response.Write("<script>alert('Login inválido')</script>"); txtEmail.Text = ""; txtSenha.Text = ""; txtEmail.Focus(); } else { Response.Redirect("Home.aspx"); } } else if (ca == "Atleta") { BLL.Atleta atl = new BLL.Atleta(); atl.Email = txtEmail.Text; atl.Senha = txtSenha.Text; DAL.AtletaDAL atlDAL = new DAL.AtletaDAL(); atl = atlDAL.Login(atl); if (atl.CodA == 0) { Response.Write("<script>alert('Login inválido')</script>"); txtEmail.Text = ""; txtSenha.Text = ""; txtEmail.Focus(); } else { Response.Redirect("Home.aspx"); } } else if (ca == "Torcedor") { BLL.Torcedor tor = new BLL.Torcedor(); tor.Email = txtEmail.Text; tor.Senha = txtSenha.Text; DAL.TorcedorDAL torDAL = new DAL.TorcedorDAL(); tor = torDAL.Login(tor); if (tor.CodT == 0) { Response.Write("<script>alert('Login inválido')</script>"); txtEmail.Text = ""; txtSenha.Text = ""; txtEmail.Focus(); } else { Response.Redirect("Home.aspx"); } } else if (ca == "Administrador") { //FAZER O MESMO QUE OS OUTROS SÓ QUE PARA ADMIN } else { Response.Write("<script>alert('Categoria inválida!')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["usuario"] != null) { if (Session["usuario"].ToString() != string.Empty) { pro.IdLogin = Convert.ToInt32(Session["idlogin"]); pro = proDAL.PreencherPeloID(pro); if (pro.IdProfessor.ToString() != null) { if (pro.IdProfessor.ToString() != "") { int idRecebido; int.TryParse(pro.IdProfessor.ToString(), out idRecebido); //pro.IdProfessor = idRecebido; //pro = proDAL.PreencherPeloID(pro); lo.IdLogin = Convert.ToInt32(Session["idlogin"]); lo = loDAL.PreencherPeloID(lo); if (pro.IdProfessor != 0) { lblId.Text = pro.IdProfessor.ToString(); Image1.ImageUrl = pro.Foto; txtNome.Text = pro.Nome; txtEmail.Text = pro.Email; txtTelefone.Text = pro.Telefone; txtDescricao.Text = pro.Descricao; txtCpf.Text = pro.Cpf; Image1.ImageUrl = pro.Foto; lblNome.Text = pro.Nome; lblEmail.Text = pro.Email; lblTelefone.Text = pro.Telefone; lblDescricao.Text = pro.Descricao; lblCpf.Text = pro.Cpf; lblIdL.Text = lo.IdLogin.ToString(); txtUsuario.Text = lo.Usuario; txtSenha.Text = lo.Senha; } else { //lblId.Text = "ID INVÁLIDO"; } } else { //lblId.Text = "ID INVÁLIDO"; } } else { //lblId.Text = "ID INVÁLIDO"; } } else { Response.Redirect("../ADMINISTRADOR/LoginAdm.aspx"); } } else { Response.Redirect("../ADMINISTRADOR/LoginAdm.aspx"); } } }