예제 #1
0
 public Boolean UpdateDailyNeedsProduct(DailyNeedProduct product)
 {
     if (productGetway.UpdateProductInfo(product) > 0)
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
 public JsonResult updateDailyNeedProduct(DailyNeedProduct product)
 {
     if (productManager.UpdateDailyNeedsProduct(product))
     {
         return(Json("true", JsonRequestBehavior.AllowGet));
     }
     return(Json("false", JsonRequestBehavior.AllowGet));
 }
예제 #3
0
        public ActionResult ProductPage(String code, int sectionId, String name)
        {
            List <SectionC> sections = sectionManager.getAllSections();

            ViewBag.sections = sections;

            if (sectionId == 1)
            {
                ClothingProduct clothingProduct = productManager.getAClothingProduct(code)[0];
                ViewBag.product = clothingProduct;
            }
            else if (sectionId == 2)
            {
                ElectronicsProduct electronicsProduct = productManager.GetElectronicsProducts(code)[0];
                ViewBag.product = electronicsProduct;
            }
            else if (sectionId == 3)
            {
                DailyNeedProduct dailyNeedProduct = productManager.GetADailyNeedProuct(code)[0];
                ViewBag.product = dailyNeedProduct;
            }
            else if (sectionId == 4)
            {
                MobileProduct mobileProduct = productManager.GetAllMobileProduct(code)[0];
                ViewBag.product = mobileProduct;
            }
            else if (code.Equals("null") && sectionId == -1)
            {
                List <Product> products = productManager.GetProduct(name);

                int secId = products[0].SectionId;

                if (secId == 1)
                {
                    ClothingProduct clothingProduct = productManager.getAClothingProduct(products[0].ProductCode)[0];
                    ViewBag.product = clothingProduct;
                }
                else if (secId == 2)
                {
                    ElectronicsProduct electronicsProduct = productManager.GetElectronicsProducts(products[0].ProductCode)[0];
                    ViewBag.product = electronicsProduct;
                }
                else if (secId == 3)
                {
                    DailyNeedProduct dailyNeedProduct = productManager.GetADailyNeedProuct(products[0].ProductCode)[0];
                    ViewBag.product = dailyNeedProduct;
                }
                else if (secId == 4)
                {
                    MobileProduct mobileProduct = productManager.GetAllMobileProduct(products[0].ProductCode)[0];
                    ViewBag.product = mobileProduct;
                }
            }


            return(View());
        }
예제 #4
0
        public Boolean InsertDailyNeedsProduct(DailyNeedProduct product)
        {
            if (productGetway.insertDailyNeedsProduct(product) > 0)
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
        public int insertDailyNeedsProduct(DailyNeedProduct product)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            String        Query      = "INSERT INTO products VALUES ('" + product.ProductName + "','" + product.ProductCode + "'," + product.SectionId + "," + product.Price + ",'" + product.Category + "','" + product.Description + "','" + product.ImageLink + "',null,null,null,null," + product.Quantity + ",'" + product.BrandName + "')";
            SqlCommand    command    = new SqlCommand(Query, connection);

            connection.Open();
            int res = command.ExecuteNonQuery();

            connection.Close();

            return(res);
        }
예제 #6
0
        public int UpdateProductInfo(DailyNeedProduct product)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            String        Query      = "UPDATE products SET productName = '" + product.ProductName + "',ProductCode='" + product.ProductCode +
                                       "',Price=" + product.Price + ",Category ='" + product.Category + "',Description='" + product.Description + "',Quantity=" + product.Quantity +
                                       ",BrandName='" + product.BrandName + "' WHERE ProductId=" + product.ProductId;
            SqlCommand command = new SqlCommand(Query, connection);

            connection.Open();
            int res = command.ExecuteNonQuery();

            connection.Close();

            return(res);
        }
예제 #7
0
        public ActionResult AddProduct(ClothingProduct product, ElectronicsProduct electronics, DailyNeedProduct dailyNeeds, MobileProduct mobile, int SectionId)
        {
            WebImage photo       = null;
            var      newFileName = "";
            var      imagePath   = "";

            photo = WebImage.GetImageFromRequest();
            if (product.ProductName != null && product.SectionId > 0 && product.ProductCode != null && product.Price != 0 && photo != null)
            {
                if (!productManager.isThisCodeAlreadyExist(product.ProductCode))
                {
                    photo.FileName = product.ProductCode + "img";
                    newFileName    = photo.FileName;


                    imagePath = @"Style/ProductImage/" + product.SectionId + @"/" + newFileName;

                    photo.Save(@"~/" + imagePath);
                    Boolean res = false;
                    if (SectionId == 1)
                    {
                        product.ImageLink = imagePath;
                        res = productManager.InsertClothingProduct(product);
                    }

                    else if (SectionId == 2)
                    {
                        electronics.ImageLink = imagePath;
                        res = productManager.InsertElectronicsProduct(electronics);
                    }

                    else if (SectionId == 3)
                    {
                        dailyNeeds.ImageLink = imagePath;
                        res = productManager.InsertDailyNeedsProduct(dailyNeeds);
                    }

                    else if (SectionId == 4)
                    {
                        mobile.ImageLink = imagePath;
                        productManager.InsertMobileProduct(mobile);
                    }

                    if (res)
                    {
                        ViewBag.insertResult = "1";

                        List <ClothingProduct>    clothingProducts    = productManager.GetAllCLothingProduct();
                        List <ElectronicsProduct> electronicsProducts = productManager.GetAllElectroinicProduct();
                        List <DailyNeedProduct>   dailyNeedProducts   = productManager.GetADailyNeedProuct();
                        List <MobileProduct>      mobileProducts      = productManager.GetAllMobileProduct();
                        return(View(new AdminSectionC((AdminC)Session["adminIndo"], (List <SectionC>)Session["sectionInfo"], clothingProducts, electronicsProducts, dailyNeedProducts, mobileProducts)));
                    }
                    else
                    {
                        List <ClothingProduct>    clothingProducts    = productManager.GetAllCLothingProduct();
                        List <ElectronicsProduct> electronicsProducts = productManager.GetAllElectroinicProduct();
                        List <DailyNeedProduct>   dailyNeedProducts   = productManager.GetADailyNeedProuct();
                        List <MobileProduct>      mobileProducts      = productManager.GetAllMobileProduct();
                        return(View(new AdminSectionC((AdminC)Session["adminIndo"], (List <SectionC>)Session["sectionInfo"], clothingProducts, electronicsProducts, dailyNeedProducts, mobileProducts)));
                    }
                }
                else
                {
                    ViewBag.insertResult = "2";
                    List <ClothingProduct>    clothingProducts    = productManager.GetAllCLothingProduct();
                    List <ElectronicsProduct> electronicsProducts = productManager.GetAllElectroinicProduct();
                    List <DailyNeedProduct>   dailyNeedProducts   = productManager.GetADailyNeedProuct();
                    List <MobileProduct>      mobileProducts      = productManager.GetAllMobileProduct();
                    return(View(new AdminSectionC((AdminC)Session["adminIndo"], (List <SectionC>)Session["sectionInfo"], clothingProducts, electronicsProducts, dailyNeedProducts, mobileProducts)));
                }
            }
            else
            {
                ViewBag.insertResult = "3";
                List <ClothingProduct>    clothingProducts    = productManager.GetAllCLothingProduct();
                List <ElectronicsProduct> electronicsProducts = productManager.GetAllElectroinicProduct();
                List <DailyNeedProduct>   dailyNeedProducts   = productManager.GetADailyNeedProuct();
                List <MobileProduct>      mobileProducts      = productManager.GetAllMobileProduct();
                return(View(new AdminSectionC((AdminC)Session["adminIndo"], (List <SectionC>)Session["sectionInfo"], clothingProducts, electronicsProducts, dailyNeedProducts, mobileProducts)));
            }
        }