示例#1
0
        protected void btnBSearch_Click(object sender, EventArgs e)
        {
            Collection <BrandCL> grd = brandBLL.getAllBrands();
            var xyz = grd.Where(x => x.id >= 0);

            if (txtName.Text == string.Empty && txtPromotions.Text == string.Empty && ddlBrandRating.Text == 0.ToString())
            {
                if (grd.Count > 0)
                {
                    GvBrand.DataSource = grd;
                    GvBrand.DataBind();
                }
                else
                {
                    DataTable dt = new DataTable();
                    ShowNoResultFound(grd, GvBrand);
                }
            }
            else
            {
                if (txtName.Text != string.Empty)
                {
                    xyz = from x in xyz where x.name.ToLower().Contains(txtName.Text.ToLower()) select x;
                }
                if (txtPromotions.Text != string.Empty)
                {
                    xyz = from x in xyz where x.promotions == Convert.ToDecimal(txtPromotions.Text) select x;
                }
                if (ddlBrandRating.Text != 0.ToString())
                {
                    xyz = from x in xyz where x.brandRating == Convert.ToInt32(ddlBrandRating.Text) select x;
                }
                Collection <BrandCL> xyzUpdate = new Collection <BrandCL>();
                foreach (var item in xyz)
                {
                    xyzUpdate.Add(new BrandCL()
                    {
                        id           = item.id,
                        dateModified = item.dateModified,
                        dateCreated  = item.dateCreated,
                        brandRating  = item.brandRating,
                        isDeleted    = item.isDeleted,
                        name         = item.name,
                        promotions   = item.promotions
                    });
                }
                if (xyzUpdate.Count() > 0)
                {
                    GvBrand.DataSource = xyzUpdate;
                    GvBrand.DataBind();
                }
                else
                {
                    DataTable dt = new DataTable();
                    ShowNoResultFound(xyzUpdate, GvBrand);
                }
            }
        }
示例#2
0
        private void bindGrid()
        {
            Collection <BrandCL> brands = brandBLL.getAllBrands();

            if (brands.Count() > 0)
            {
                GvBrand.DataSource = brands;
                GvBrand.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                ShowNoResultFound(brands, GvBrand);
            }
        }