Esempio n. 1
0
        /// <summary>
        /// Fetches the data from the product table by Id.
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public ProductCL getProduct(int productId)
        {
            Product   productDB  = (from productInfo in dbcontext.Products where productInfo.Id == productId && productInfo.IsDeleted == false select productInfo).FirstOrDefault();
            ProductCL productget = new ProductCL()
            {
                Id             = productDB.Id,
                categoryId     = productDB.CategoryId,
                brandId        = productDB.BrandId,
                name           = productDB.Name,
                featureDetails = productDB.FeatureDetails,
                price          = productDB.Price,
                stockQuantity  = Convert.ToInt32(productDB.StockQuantity),
                dateCreated    = productDB.DateCreated,
                dateModified   = productDB.DateModified,
                isDeleted      = productDB.IsDeleted,
                dispatchTime   = productDB.DispatchTime,
                codApplicable  = productDB.CODApplicable,
                shippingCharge = productDB.ShippingCharge,
                keywordsMeta   = productDB.Keywords_Meta,
                weight         = productDB.Weight,
                description    = productDB.Description,
                warranty       = productDB.Warranty,
                imageUrl       = productDB.ImageURL,
                isHot          = productDB.IsHot,
                productCode    = productDB.ProductCode,
            };

            return(productget);
        }
Esempio n. 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            int        productId  = Convert.ToInt32(Request.QueryString["productId"]);
            ProductCL  productCL  = productBLL.getProduct(productId);

            if (txtProductFeature2.Visible == false)
            {
                productCL.featureDetails = txtProductFeature1.Text + ";" + ";" + ";" + ";";
            }
            else if (txtProductFeature3.Visible == false)
            {
                productCL.featureDetails = txtProductFeature1.Text + ";" + txtProductFeature2.Text + ";" + ";" + ";";
            }
            else if (txtProductFeature4.Visible == false)
            {
                productCL.featureDetails = txtProductFeature1.Text + ";" + txtProductFeature2.Text + ";" + txtProductFeature3.Text + ";" + ";";
            }
            else
            {
                productCL.featureDetails = txtProductFeature1.Text + ";" + txtProductFeature2.Text + ";" + txtProductFeature3.Text + ";" + txtProductFeature4.Text + ";";
            }
            productBLL.updateProduct(productCL);
            string s = "window.close();";

            ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
        }
Esempio n. 3
0
        public ProductCL getProductbyCartId(int cartId)
        {
            CartProduct cartProductQuery = (from x in dbcontext.CartProducts where x.Id == cartId select x).FirstOrDefault();
            Product     productQuery     = (from z in dbcontext.Products where z.Id == cartProductQuery.ProductId select z).FirstOrDefault();
            ProductCL   productCL        = new ProductCL()
            {
                brandId        = productQuery.BrandId,
                categoryId     = productQuery.CategoryId,
                codApplicable  = productQuery.CODApplicable,
                dateCreated    = productQuery.DateCreated,
                dateModified   = productQuery.DateModified,
                description    = productQuery.Description,
                dispatchTime   = productQuery.DispatchTime,
                featureDetails = productQuery.FeatureDetails,
                Id             = productQuery.Id,
                imageUrl       = productQuery.ImageURL,
                isDeleted      = productQuery.IsDeleted,
                keywordsMeta   = productQuery.Keywords_Meta,
                name           = productQuery.Name,
                price          = productQuery.Price,
                shippingCharge = productQuery.ShippingCharge,
                isHot          = productQuery.IsHot,
                stockQuantity  = Convert.ToInt32(productQuery.StockQuantity),
                warranty       = productQuery.Warranty,
                weight         = productQuery.Weight,
            };

            return(productCL);
        }
        protected void btnDelProd_Click(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            ProductCL  productCL  = new ProductCL();

            productCL.Id = id;
            productBLL.deleteProduct(productCL);
            Response.Redirect("ProductManagement.aspx");
        }
        private void bindFeatures()
        {
            ProductBLL productBLL = new ProductBLL();
            ProductCL  productCL  = productBLL.getProduct(productId);

            string[] abc = productCL.featureDetails.Split(';');
            txtProductFeature1.Text = abc[0];
            txtProductFeature2.Text = abc[1];
            txtProductFeature3.Text = abc[2];
            txtProductFeature4.Text = abc[3];
        }
Esempio n. 6
0
        /// <summary>
        /// The method deletes a Product in the Database.
        /// </summary>
        /// <param name="brandCL">Details of Product to be deleted in the database.</param>
        /// <returns>Deleted Product Communication Layer </returns>
        public ProductCL deleteProduct(ProductCL productCL)
        {
            Product prod = (from x in dbcontext.Products where x.Id == productCL.Id select x).FirstOrDefault();

            //Initialises the query of fetching the Product from the Data Base.
            prod.IsDeleted = true;
            //Updating the instance of DataBase to a Inputed Communication Layer class instance by the user.
            dbcontext.SaveChanges();
            //Updating the Database.
            productCL.isDeleted = prod.IsDeleted;
            //Updating the Communication Layer class instance by the user data by the instance of DataBase.
            return(productCL);
            //Returning the Communication Layer Class with Deleted Product data on it.
        }
Esempio n. 7
0
        /// <summary>
        /// The method updates a Product in the Database.
        /// </summary>
        /// <param name="productCL">Details of Product to be updated in the database.</param>
        /// <returns>Updated Product Communication Layer Class.</returns>
        public ProductCL updateProduct(ProductCL productCL)
        {
            Product prod = (from x in dbcontext.Products where x.Id == productCL.Id select x).FirstOrDefault();

            //Initialises the query of fetching the Product from the Data Base.
            prod.IsDeleted      = productCL.isDeleted;
            prod.DateCreated    = productCL.dateCreated;
            prod.DateModified   = productCL.dateModified;
            prod.Name           = productCL.name;
            prod.Keywords_Meta  = productCL.keywordsMeta;
            prod.Price          = productCL.price;
            prod.ShippingCharge = productCL.shippingCharge;
            prod.StockQuantity  = productCL.stockQuantity;
            prod.Weight         = Convert.ToDecimal(productCL.weight);
            prod.BrandId        = productCL.brandId;
            prod.CategoryId     = productCL.categoryId;
            prod.CODApplicable  = productCL.codApplicable;
            prod.DispatchTime   = productCL.dispatchTime;
            prod.FeatureDetails = productCL.featureDetails;
            prod.IsHot          = productCL.isHot;
            prod.Description    = productCL.description;
            prod.ImageURL       = productCL.imageUrl;
            prod.Warranty       = productCL.warranty;
            //Updating the instance of DataBase to a Inputed Communication Layer class instance by the user.
            dbcontext.SaveChanges();
            //Updating the Database.
            productCL.dateCreated    = prod.DateCreated;
            productCL.dateModified   = prod.DateModified;
            productCL.isDeleted      = prod.IsDeleted;
            productCL.name           = prod.Name;
            productCL.keywordsMeta   = prod.Keywords_Meta;
            productCL.price          = prod.Price;
            productCL.shippingCharge = prod.ShippingCharge;
            productCL.stockQuantity  = Convert.ToInt32(prod.StockQuantity);
            productCL.weight         = prod.Weight;
            productCL.brandId        = prod.BrandId;
            productCL.categoryId     = prod.CategoryId;
            productCL.codApplicable  = prod.CODApplicable;
            productCL.dispatchTime   = prod.DispatchTime;
            productCL.featureDetails = prod.FeatureDetails;
            productCL.warranty       = prod.Warranty;
            productCL.isHot          = prod.IsHot;
            productCL.imageUrl       = prod.ImageURL;
            productCL.description    = prod.Description;
            productCL.productCode    = prod.ProductCode;
            //Updating the Communication Layer class instance by the user data by the instance of DataBase.
            return(productCL);
            //Returning the Communication Layer Class with Updated Product data on it.
        }
Esempio n. 8
0
        //Initialises when the Create Brand Button is clicked.
        protected void btnProduct_Click(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            //Instantiates the Product BusinessLogic Layer Class.
            ProductCL productCL = new ProductCL();

            //Instantiates the Product Communication Layer Class.
            if (flImage.HasFile)
            {
                flImage.SaveAs(Server.MapPath("~/") + "Images/" + Path.GetFileName(flImage.FileName));
                productCL.imageUrl = "Images/" + Path.GetFileName(flImage.FileName);
            }
            else
            {
                productCL.imageUrl = "";
            }
            productCL.brandId        = Convert.ToInt32(lstPBrandName.SelectedValue);
            productCL.categoryId     = Convert.ToInt32(lstPCategoryName.SelectedValue);
            productCL.codApplicable  = (ddlCODApplicable.SelectedValue == "Yes") ? true : false;
            productCL.dateCreated    = productCL.dateModified = DateTime.Now;
            productCL.dispatchTime   = Convert.ToInt32(ddlDispatchTime.SelectedValue);
            productCL.featureDetails = ";;;;";
            productCL.isDeleted      = false;
            productCL.shippingCharge = Convert.ToDecimal(txtShippingCharge.Text);
            productCL.keywordsMeta   = txtKeywords.Text;
            productCL.name           = txtProductName.Text;
            productCL.price          = Convert.ToDecimal(txtProductPrice.Text);
            productCL.stockQuantity  = Convert.ToInt32(txtPStockQty.Text);
            if (ddlWeight.SelectedValue == "gms.")
            {
                productCL.weight = Convert.ToDecimal(txtWeight.Text);
            }
            else
            {
                productCL.weight = Convert.ToDecimal(txtWeight.Text) * 1000;
            }
            productCL.description = txtDesc.Text;
            productCL.warranty    = txtWarranty.Text;
            productCL.isHot       = checkHot.Checked;
            //Adds the data entered from the Inputs to the Communication Layer Class instance.
            ProductCL pCL = productBLL.createProduct(productCL);

            lblSuccessfulProduct.Text = "Product Created Successfully.";
            //This method sends the data of the Communication Layer class instance to the Database.
            string url = "ProductPopup.aspx?categoryId=" + productCL.categoryId + "&productId=" + pCL.Id;
            string y   = url;

            OpenNewWindows(y);
        }
        protected void btnProduct_Click(object sender, EventArgs e)
        {
            ProductCL  prodCL  = new ProductCL();
            ProductBLL prodBLL = new ProductBLL();

            prodCL.Id    = id;
            prodCL.name  = txtProductName.Text;
            prodCL.price = Convert.ToDecimal(txtProductPrice.Text);
            //prodCL.weight = Convert.ToDecimal(txtWeight.Text);
            if (flImage.HasFile)
            {
                flImage.SaveAs(Server.MapPath("~/") + "Images/" + Path.GetFileName(flImage.FileName));
                prodCL.imageUrl = "Images/" + Path.GetFileName(flImage.FileName);
            }
            else
            {
                prodCL.imageUrl = imageUl;
            }
            prodCL.shippingCharge = Convert.ToDecimal(txtShippingCharge.Text);
            prodCL.keywordsMeta   = txtKeywords.Text;
            prodCL.stockQuantity  = Convert.ToInt32(txtPStockQty.Text);
            prodCL.codApplicable  = (ddlCODApplicable.Text == "Yes") ? true : false;
            prodCL.dispatchTime   = Convert.ToInt32(ddlDispatchTime.Text);
            if (ddlWeight.Text == "gms.")
            {
                prodCL.weight = Convert.ToDecimal(txtWeight.Text);
            }
            else
            {
                prodCL.weight = Convert.ToDecimal(txtWeight.Text) * 1000;
            }
            prodCL.dateCreated    = DateTime.Now;
            prodCL.dateModified   = DateTime.Now;
            prodCL.isDeleted      = false;
            prodCL.isHot          = false;
            prodCL.categoryId     = Convert.ToInt32(lstPCategoryName.SelectedValue);
            prodCL.warranty       = txtWarranty.Text;
            prodCL.description    = txtDesc.Text;
            prodCL.featureDetails = featureDetails;
            prodCL.brandId        = Convert.ToInt32(lstPBrandName.SelectedValue);
            ProductCL productCL = prodBLL.updateProduct(prodCL);

            lblSuccessfulProduct.Text = "Product Updated Successfully";
            string url = "UpdateProductPopup.aspx?categoryId=" + productCL.categoryId + "&productId=" + productCL.Id;
            string y   = url;

            OpenNewWindows(y);
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int       productId = Convert.ToInt32(Request.QueryString["Id"]);
            ProductCL product   = productBLL.getAllProducts().Where(ex => ex.Id == productId).FirstOrDefault();
            Collection <newProductCL> products = getProdFeatures(product);

            foreach (newProductCL item in products)
            {
                ProductDet uc = (ProductDet)Page.LoadControl("ProductDet.ascx");
                uc.productPrice    = item.productPrice;
                uc.productName     = item.productName;
                uc.config1         = item.feature1;
                uc.config2         = item.feature2;
                uc.config3         = item.feature3;
                uc.config4         = item.feature4;
                uc.productImageURl = item.imageUrl;
                uc.ButtonClick    += product_Click;
            }
        }
Esempio n. 11
0
        private Collection <newProductCL> getProdFeatures(ProductCL products)
        {
            Collection <newProductCL> featuresFromProdId = new Collection <newProductCL>();

            string[] abc = products.featureDetails.Split(';');
            featuresFromProdId.Add(new newProductCL()
            {
                id           = products.Id,
                productName  = products.name,
                productPrice = products.price.ToString(),
                feature1     = abc[0],
                feature2     = abc[1],
                feature3     = abc[2],
                feature4     = abc[3],
                imageUrl     = products.imageUrl
            });

            return(featuresFromProdId);
        }
        private void bindProducts(int productId)
        {
            ProductBLL prodBLL = new ProductBLL();
            ProductCL  prodCL  = prodBLL.getProduct(productId);

            txtProductName.Text            = prodCL.name;
            txtProductPrice.Text           = prodCL.price.ToString();
            lstPBrandName.SelectedValue    = prodCL.brandId.ToString();
            lstPCategoryName.SelectedValue = prodCL.categoryId.ToString();
            txtPStockQty.Text      = prodCL.stockQuantity.ToString();
            txtShippingCharge.Text = prodCL.shippingCharge.ToString();
            txtWeight.Text         = prodCL.weight.ToString();
            ddlCODApplicable.Text  = prodCL.codApplicable.ToString();
            txtKeywords.Text       = prodCL.keywordsMeta;
            ddlDispatchTime.Text   = prodCL.dispatchTime.ToString();
            txtDesc.Text           = prodCL.description;
            txtWarranty.Text       = prodCL.warranty;
            checkHot.Checked       = prodCL.isHot;
            string image = prodCL.imageUrl;

            imageUl        = image;
            featureDetails = prodCL.featureDetails;
        }
Esempio n. 13
0
        //Instantiates the DataBase model from edmx file in this Solution.
        /// <summary>
        /// This method creates a Product in the Database.
        /// </summary>
        /// <param name="productCL">>Details of Product to be created in database.</param>
        /// <returns>Class of Product created in this method.</returns>
        public ProductCL createProduct(ProductCL productCL)
        {
            Product product = dbcontext.Products.Add(new Product
            {
                BrandId        = productCL.brandId,
                CategoryId     = productCL.categoryId,
                CODApplicable  = productCL.codApplicable,
                DateCreated    = DateTime.Now,
                DateModified   = DateTime.Now,
                DispatchTime   = productCL.dispatchTime,
                FeatureDetails = productCL.featureDetails,
                Keywords_Meta  = productCL.keywordsMeta,
                Name           = productCL.name,
                Price          = productCL.price,
                StockQuantity  = productCL.stockQuantity,
                Weight         = Convert.ToDecimal(productCL.weight),
                IsDeleted      = false,
                ShippingCharge = productCL.shippingCharge,
                ImageURL       = productCL.imageUrl,
                Warranty       = productCL.warranty,
                Description    = productCL.description,
                IsHot          = productCL.isHot,
                ProductCode    = "",
            });

            //Adding the data recieved in parameters to DB and to a temporary DataAccess Layer Class.
            dbcontext.SaveChanges();
            string productCode = "";

            if (product.Id.ToString().Length == 1)
            {
                productCode = "000" + product.Id;
            }
            if (product.Id.ToString().Length == 2)
            {
                productCode = "00" + product.Id;
            }
            if (product.Id.ToString().Length == 3)
            {
                productCode = "0" + product.Id;
            }
            if (product.Id.ToString().Length == 4)
            {
                productCode = product.Id.ToString();
            }
            product.ProductCode = product.Name.Substring(0, 3) + productCode;
            dbcontext.SaveChanges();
            //Updating the Database.
            ProductCL productCl = new ProductCL()
            {
                Id             = product.Id,
                brandId        = product.BrandId,
                categoryId     = product.CategoryId,
                codApplicable  = product.CODApplicable,
                dateCreated    = product.DateCreated,
                dateModified   = product.DateModified,
                dispatchTime   = product.DispatchTime,
                featureDetails = product.FeatureDetails,
                isDeleted      = product.IsDeleted,
                keywordsMeta   = product.Keywords_Meta,
                name           = product.Name,
                price          = product.Price,
                stockQuantity  = Convert.ToInt32(product.StockQuantity), //Typecasts to int.
                weight         = product.Weight,                         //Typecasts the variable of any type to string.
                shippingCharge = product.ShippingCharge,
                description    = product.Description,
                warranty       = product.Warranty,
                imageUrl       = product.ImageURL,
                isHot          = product.IsHot,
                productCode    = product.ProductCode,
            };

            //Adding the temporary DataAccess Layer Class data to Communication Layer class.
            return(productCl);
            //Returning the Communication Layer Class with Created Product data on it.
        }