Example #1
0
 public ArrayList listar()
 {
     ArrayList arr = new ArrayList();
     string sql = "SELECT * FROM bairro;";
     MySqlCommand commS = new MySqlCommand(sql, Conn.mConn);
     DataTable dt = Conn.ExecuteQuery(commS);
     if (dt != null)
     {
         int i = 0;
         while (i < dt.Rows.Count)
         {
             Bairro bai = new Bairro();
             bai.Idbairro = int.Parse(dt.Rows[i][0].ToString());
             bai.Nome = dt.Rows[i][1].ToString();
             bai.Tempodeentrega = dt.Rows[i][2].ToString();
             bai.Valordeentrega = dt.Rows[i][3].ToString();
             bai.Percentual = dt.Rows[i][4].ToString();
             arr.Add(bai);
             i++;
         }
     }
     return arr;
 }
Example #2
0
        public ArrayList listar(string nom)
        {
            ArrayList arr = new ArrayList();
            string sql = "SELECT * FROM bairro where nome like'%" + nom + "%';";

            MySqlCommand commS = new MySqlCommand(sql, Conn.mConn);

            commS.Parameters.Add("@nome", MySqlDbType.VarChar);
            commS.Parameters["@nome"].Value = nom;

            DataTable dt = Conn.ExecuteQuery(commS);
            if (dt != null)
            {
                int i = 0;
                while (i < dt.Rows.Count)
                {
                    Bairro bai = new Bairro();
                    bai.Idbairro = int.Parse(dt.Rows[i][0].ToString());
                    bai.Nome = dt.Rows[i][1].ToString();
                    bai.Tempodeentrega = dt.Rows[i][2].ToString();
                    bai.Valordeentrega = dt.Rows[i][3].ToString();
                    bai.Percentual = dt.Rows[i][4].ToString();

                    arr.Add(bai);
                    i++;
                }
            }
            return arr;
        }