Beispiel #1
0
        public List <ControleDeAlunoEnt> Lista()
        {
            using (SqlConnection con = new SqlConnection()) //Instanciando conexão
            {
                con.ConnectionString = Properties.Settings.Default.banco;
                SqlCommand cn = new SqlCommand();
                cn.CommandType = CommandType.Text;
                con.Open();
                cn.CommandText = "SELECT * FROM controledealuno ORDER BY id ASC";
                cn.Connection  = con;
                SqlDataReader             dr;
                List <ControleDeAlunoEnt> Lista = new List <ControleDeAlunoEnt>();
                dr = cn.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ControleDeAlunoEnt dado = new ControleDeAlunoEnt();
                        dado.Id         = Convert.ToString(dr["id"]);
                        dado.Nome       = Convert.ToString(dr["nome"]);
                        dado.Frequencia = Convert.ToString(dr["frequencia"]);
                        dado.Pagamento  = Convert.ToString(dr["pagamento"]);
                        Lista.Add(dado);
                    }
                }
                return(Lista);
            }
        }
Beispiel #2
0
        public List <ControleDeAlunoEnt> Buscar(ControleDeAlunoEnt objtabela)
        {
            using (SqlConnection con = new SqlConnection()) //Instanciando conexão
            {
                con.ConnectionString = Properties.Settings.Default.banco;
                SqlCommand cn = new SqlCommand();
                cn.CommandType = CommandType.Text;
                con.Open();
                cn.CommandText = "SELECT * FROM controledealuno WHERE nome LIKE @nome";
                //Parâmetros ControleDeAluno
                cn.Parameters.Add("nome", SqlDbType.VarChar).Value = objtabela.Nome + "%";
                cn.Connection = con;
                SqlDataReader             dr;
                List <ControleDeAlunoEnt> Lista = new List <ControleDeAlunoEnt>();
                dr = cn.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ControleDeAlunoEnt dado = new ControleDeAlunoEnt();
                        dado.Id         = Convert.ToString(dr["id"]);
                        dado.Nome       = Convert.ToString(dr["nome"]);
                        dado.Frequencia = Convert.ToString(dr["frequencia"]);
                        dado.Pagamento  = Convert.ToString(dr["pagamento"]);
                        Lista.Add(dado);
                    }
                }
                return(Lista);
            }
        }
Beispiel #3
0
 public int Excluir(ControleDeAlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "DELETE FROM controledealuno WHERE id = @id";
         //Parâmetros ControleDeAluno
         cn.Parameters.Add("id", SqlDbType.VarChar).Value = objtabela.Id;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
Beispiel #4
0
 public int Inserir(ControleDeAlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "INSERT INTO controledealuno ([nome], [frequencia], [pagamento]) VALUES (@nome, @frequencia, @pagamento)";
         //Parâmetros ControleDeAluno
         cn.Parameters.Add("nome", SqlDbType.VarChar).Value       = objtabela.Nome;
         cn.Parameters.Add("frequencia", SqlDbType.VarChar).Value = objtabela.Frequencia;
         cn.Parameters.Add("pagamento", SqlDbType.VarChar).Value  = objtabela.Pagamento;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
Beispiel #5
0
 public int Editar(ControleDeAlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "";
         cn.CommandText = "UPDATE controledealuno SET nome = @nome, frequencia = @frequencia, pagamento = @pagamento WHERE id = @id";
         //Parâmetros ControleDeAluno
         cn.Parameters.Add("id", SqlDbType.VarChar).Value         = objtabela.Id;
         cn.Parameters.Add("nome", SqlDbType.VarChar).Value       = objtabela.Nome;
         cn.Parameters.Add("frequencia", SqlDbType.VarChar).Value = objtabela.Frequencia;
         cn.Parameters.Add("pagamento", SqlDbType.VarChar).Value  = objtabela.Pagamento;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
 public static int Editar(ControleDeAlunoEnt objtabela) //Método Editar
 {
     return(new ControleDeAlunoControl().Editar(objtabela));
 }
 public static int Excluir(ControleDeAlunoEnt objtabela) //Método Excluir
 {
     return(new ControleDeAlunoControl().Excluir(objtabela));
 }
 public List <ControleDeAlunoEnt> Buscar(ControleDeAlunoEnt objtabela) //Método Buscar
 {
     return(new ControleDeAlunoControl().Buscar(objtabela));
 }
 public static int Inserir(ControleDeAlunoEnt objtabela) //Método Inserir
 {
     return(new ControleDeAlunoControl().Inserir(objtabela));
 }