public ArrayList listar(int cod) { ArrayList arr = new ArrayList(); string sql = "SELECT * FROM entrar where identrar='" + cod + "';"; //string sql = "SELECT * FROM entrar where identrar like " + " @cod "; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); commS.Parameters.Add("@cod", MySqlDbType.VarChar); commS.Parameters["@cod"].Value = cod; DataTable dt = Conn.ExecuteQuery(commS); if (dt != null) { int i = 0; while (i < dt.Rows.Count) { Usuario u = new Usuario(); u.Codigo = int.Parse(dt.Rows[i][0].ToString()); u.Login = dt.Rows[i][1].ToString(); u.Senha = dt.Rows[i][2].ToString(); u.Tipodeconta = dt.Rows[i][3].ToString(); u.Nomecompleto = dt.Rows[i][4].ToString(); u.Email = dt.Rows[i][5].ToString(); arr.Add(u); i++; } } return arr; }
//aqui é para listar e depois testar no login, public ArrayList Usuarios() { //se ele e a respectiva senha são válidos ArrayList arr = new ArrayList(); string sql = "SELECT*FROM entrar;"; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); DataTable dt = Conn.ExecuteQuery(commS); if (dt != null) { int i = 0; while (i < dt.Rows.Count) { Usuario u = new Usuario(); u.Codigo = int.Parse(dt.Rows[i][0].ToString()); u.Login = dt.Rows[i][1].ToString(); u.Senha = dt.Rows[i][2].ToString(); u.Tipodeconta = dt.Rows[i][3].ToString(); u.Nomecompleto = dt.Rows[i][4].ToString(); u.Email = dt.Rows[i][5].ToString(); arr.Add(u); i++; } } return arr; }
//serve para lista e verificar o status de ligar ou desligar no carregamento do load da tela gerais public ArrayList Condicaoligar() { ArrayList arr = new ArrayList(); string sql = "SELECT * FROM configuracoes;"; MySqlCommand commS = new MySqlCommand(sql, Conn.mConn); DataTable dt = Conn.ExecuteQuery(commS); if(dt != null) { int i = 0; while(i < dt.Rows.Count) { Usuario us = new Usuario(); us.Ligar = dt.Rows[i][0].ToString(); arr.Add(us); i++; } } return arr; }