Example #1
0
 public List<AdDetails> GetAds(int region, int bedroomCount, int minArea,
     int maxArea, int minPrice, int maxPrice)
 {
     SqlCommand cmd = new SqlCommand("GetAds", sqlCon);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.Add(new SqlParameter("@region", SqlDbType.Int, 4));
     cmd.Parameters["@region"].Value = region;
     cmd.Parameters.Add(new SqlParameter("@bedroom_count", SqlDbType.TinyInt, 1));
     cmd.Parameters["@bedroom_count"].Value = bedroomCount;
     cmd.Parameters.Add(new SqlParameter("@minArea", SqlDbType.Int, 4));
     cmd.Parameters["@minArea"].Value = minArea;
     cmd.Parameters.Add(new SqlParameter("@maxArea", SqlDbType.Int, 4));
     cmd.Parameters["@maxArea"].Value = maxArea;
     cmd.Parameters.Add(new SqlParameter("@minPrice", SqlDbType.Money, 8));
     cmd.Parameters["@minPrice"].Value = minArea;
     cmd.Parameters.Add(new SqlParameter("@maxPrice", SqlDbType.Money, 8));
     cmd.Parameters["@maxPrice"].Value = maxArea;
     List<AdDetails> ads = new List<AdDetails>();
     sqlCon.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     while (reader.Read())
     {
         AdDetails ad = new AdDetails((string)reader["msg"]);
         ads.Add(ad);
     }
     reader.Close();
     sqlCon.Close();
     return ads;
 }
Example #2
0
        public List <AdDetails> GetAds(int region, int bedroomCount, int minArea,
                                       int maxArea, int minPrice, int maxPrice)
        {
            SqlCommand cmd = new SqlCommand("GetAds", sqlCon);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@region", SqlDbType.Int, 4));
            cmd.Parameters["@region"].Value = region;
            cmd.Parameters.Add(new SqlParameter("@bedroom_count", SqlDbType.TinyInt, 1));
            cmd.Parameters["@bedroom_count"].Value = bedroomCount;
            cmd.Parameters.Add(new SqlParameter("@minArea", SqlDbType.Int, 4));
            cmd.Parameters["@minArea"].Value = minArea;
            cmd.Parameters.Add(new SqlParameter("@maxArea", SqlDbType.Int, 4));
            cmd.Parameters["@maxArea"].Value = maxArea;
            cmd.Parameters.Add(new SqlParameter("@minPrice", SqlDbType.Money, 8));
            cmd.Parameters["@minPrice"].Value = minArea;
            cmd.Parameters.Add(new SqlParameter("@maxPrice", SqlDbType.Money, 8));
            cmd.Parameters["@maxPrice"].Value = maxArea;
            List <AdDetails> ads = new List <AdDetails>();

            sqlCon.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                AdDetails ad = new AdDetails((string)reader["msg"]);
                ads.Add(ad);
            }
            reader.Close();
            sqlCon.Close();
            return(ads);
        }