Esempio n. 1
0
        private void bindGrid()
        {
            Collection <ProductCL>    products = productBLL.getAllProducts();
            Collection <newProductCL> prod     = ConvertProductToGrid(products);

            if (prod.Count() > 0)
            {
                GvProductMangmt.DataSource = prod;
                GvProductMangmt.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                ShowNoResultFound(prod, GvProductMangmt);
            }
        }
Esempio n. 2
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Collection <ProductCL>    grd        = productBLL.getAllProducts();
            Collection <newProductCL> newProdgrd = ConvertProductToGrid(grd);
            var xyz = newProdgrd.Where(x => x.id >= 0);

            if (txtFeature1.Text == string.Empty && txtStkQty.Text == string.Empty && txtPrice.Text == string.Empty && txtName.Text == string.Empty && txtFeature2.Text == string.Empty && txtFeature3.Text == string.Empty && txtFeature4.Text == string.Empty && txtWeight.Text == string.Empty && txtKeywords.Text == string.Empty && ddlCodApplicable.SelectedValue == "0" && txtDispatchTime.Text == string.Empty && txtWarranty.Text == string.Empty && txtShippingCharge.Text == string.Empty)
            {
                if (newProdgrd.Count > 0)
                {
                    GvProductMangmt.DataSource = newProdgrd;
                    GvProductMangmt.DataBind();
                }
                else
                {
                    DataTable dt = new DataTable();
                    ShowNoResultFound(newProdgrd, GvProductMangmt);
                }
            }
            else
            {
                if (txtName.Text != string.Empty)
                {
                    xyz = xyz.Where(x => x.productName.ToLower().Contains(txtName.Text.ToLower()));
                }
                if (txtPrice.Text != string.Empty)
                {
                    xyz = from x in xyz where x.productPrice.Contains(txtPrice.Text) select x;
                }
                if (txtStkQty.Text != string.Empty)
                {
                    xyz = from x in xyz where x.stockQuantity.Contains(txtStkQty.Text) select x;
                }
                if (txtFeature1.Text != string.Empty)
                {
                    xyz = from x in xyz where x.feature1.ToLower().Contains(txtFeature1.Text.ToLower()) select x;
                }
                if (txtFeature2.Text != string.Empty)
                {
                    xyz = from x in xyz where x.feature2.ToLower().Contains(txtFeature2.Text.ToLower()) select x;
                }
                if (txtFeature3.Text != string.Empty)
                {
                    xyz = from x in xyz where x.feature3.ToLower().Contains(txtFeature3.Text.ToLower()) select x;
                }
                if (txtFeature4.Text != string.Empty)
                {
                    xyz = from x in xyz where x.feature4.ToLower().Contains(txtFeature4.Text.ToLower()) select x;
                }
                if (txtKeywords.Text != string.Empty)
                {
                    xyz = from x in xyz where x.keywords.ToLower().Contains(txtKeywords.Text.ToLower()) select x;
                }
                if (txtWeight.Text != string.Empty)
                {
                    xyz = from x in xyz where x.weight.Contains(txtWeight.Text) select x;
                }
                if (ddlCodApplicable.SelectedValue != "0")
                {
                    xyz = from x in xyz where x.codApplicable == ddlCodApplicable.Text select x;
                }
                if (txtDispatchTime.Text != string.Empty)
                {
                    xyz = from x in xyz where x.dispatchTime == txtDispatchTime.Text select x;
                }
                if (txtShippingCharge.Text != string.Empty)
                {
                    xyz = from x in xyz where x.shippingCharge.Contains(txtShippingCharge.Text) select x;
                }
                if (txtWarranty.Text != string.Empty)
                {
                    xyz = from x in xyz where x.warranty.Contains(txtWarranty.Text) select x;
                }
                Collection <newProductCL> xyzUpdate = new Collection <newProductCL>();
                foreach (newProductCL item in xyz)
                {
                    xyzUpdate.Add(new newProductCL
                    {
                        codApplicable  = item.codApplicable,
                        dateCreated    = item.dateCreated,
                        dateModified   = item.dateModified,
                        description    = item.description,
                        dispatchTime   = item.dispatchTime,
                        feature1       = item.feature1,
                        feature2       = item.feature2,
                        feature3       = item.feature3,
                        feature4       = item.feature4,
                        id             = item.id,
                        imageUrl       = item.imageUrl,
                        isDeleted      = item.isDeleted,
                        isHot          = item.isHot,
                        keywords       = item.keywords,
                        productName    = item.productName,
                        productPrice   = item.productPrice,
                        shippingCharge = item.shippingCharge,
                        stockQuantity  = item.stockQuantity,
                        warranty       = item.warranty,
                        weight         = item.weight,
                    });
                }
                if (xyzUpdate.Count() > 0)
                {
                    GvProductMangmt.DataSource = xyzUpdate;
                    GvProductMangmt.DataBind();
                }
                else
                {
                    DataTable dt = new DataTable();
                    ShowNoResultFound(xyzUpdate, GvProductMangmt);
                }
            }
        }