示例#1
0
        public string GetProductDetails()
        {
            string          query = "select * from Product_Details";
            Product_Details pd    = new Product_Details();

            return(pd.getProduct(query));
        }
示例#2
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if (double.Parse(txtPayment.Text) >= f)
            {
                txtPayment.Enabled = false;
                lblPaid.Text       = lblPaid.Text + txtPayment.Text;

                lblReturn.Text = lblReturn.Text + (double.Parse(txtPayment.Text) - f);
                btnPay.Enabled = false;

                for (int i = dgPos.RowCount - 1; i >= 0; i--)
                {
                    DataGridViewRow r = dgPos.Rows[i];
                    //t = t + double.Parse(r.Cells["totalDataGridViewTextBoxColumn"].Value.ToString());
                    string p_id  = r.Cells["pIdDataGridViewTextBoxColumn1"].Value.ToString();
                    int    q     = int.Parse(r.Cells["quantityDataGridViewTextBoxColumn"].Value.ToString());
                    float  price = float.Parse(r.Cells["priceDataGridViewTextBoxColumn"].Value.ToString());
                    float  total = float.Parse(r.Cells["totalDataGridViewTextBoxColumn"].Value.ToString());

                    sal.AddSales(lblId.Text, date, p_id, q, price, total);

                    int             id = int.Parse(p_id);
                    Product_Details p  = new Product_Details();
                    p                  = cmd.Product_Details.First(x => x.P_ID == id);
                    p.Stock            = p.Stock - q;
                    cmd.Entry(p).State = EntityState.Modified;
                    cmd.SaveChanges();
                }
                btnNew.PerformClick();
            }
            else
            {
                MessageBox.Show("Insufficient Amount");
            }
        }
示例#3
0
        // GET: Product_Details/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Details product_Details = db.Product_Details.Find(id);

            if (product_Details == null)
            {
                return(HttpNotFound());
            }

            var heatType = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Lạnh", Value = "0"
                },
                new SelectListItem {
                    Text = "Nóng lạnh", Value = "1"
                }
            };

            ViewBag.HeatType = new SelectList(heatType, "Value", "Text");

            ViewBag.Brand_Id       = new SelectList(db.Brands, "Id", "BrandName", product_Details.Brand_Id);
            ViewBag.ProductType_Id = new SelectList(db.ProductTypes, "Id", "TypeName", product_Details.ProductType_Id);
            return(View(product_Details));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("DetailID,ProductDetails,ArticleNumber")] Product_Details product_Details)
        {
            if (id != product_Details.DetailID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product_Details);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Product_DetailsExists(product_Details.DetailID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleNumber"] = new SelectList(_context.Products, "ArticleNumber", "Name", product_Details.ArticleNumber);
            return(View(product_Details));
        }
示例#5
0
        public ActionResult Create(Product_Details product_Details)
        {
            product_Details.ProductImages = "http://mvcshopuploadimages.gear.host/Uploads/default.png";
            product_Details.ProductStatus = 1;
            product_Details.ProductOrder  = 1;

            foreach (string file in Request.Files)
            {
                var postedFile = Request.Files[file];

                var res = UploadImgAsync(postedFile).ToString();
                //product_Details.ProductImages = res;
                var baseAddress = "http://mvcshopuploadimages.gear.host/Uploads/";
                var imgUrl      = Path.Combine(baseAddress, postedFile.FileName);

                product_Details.ProductImages = imgUrl;
            }
            if (ModelState.IsValid)
            {
                db.Product_Details.Add(product_Details);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.Brand_Id       = new SelectList(db.Brands, "Id", "BrandName", product_Details.Brand_Id);
            ViewBag.ProductType_Id = new SelectList(db.ProductTypes, "Id", "TypeName", product_Details.ProductType_Id);

            return(View(product_Details));
        }
示例#6
0
        public string GetProductDetails(int id)
        {
            string          query = "select * from Product_Details where Product_Id=" + id.ToString();
            Product_Details pd    = new Product_Details();

            return(pd.getProduct(query));
        }
示例#7
0
        public ActionResult CreateCustomer()
        {
            Product_Details objProject = new Product_Details();

            CMPSEntities5 dbcontext = new CMPSEntities5();

            return(PartialView("InsertCustomers", dbcontext.Product_Details));
        }
示例#8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Product_Details product_Details = db.Product_Details.Find(id);

            db.Product_Details.Remove(product_Details);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IActionResult Delete(int id)
        {
            // where bikeid = id
            Product_Details bike = db.Product_Details.Find(id);

            db.Product_Details.Remove(bike);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(Product_Details bike)
        {
            if (ModelState.IsValid)
            {
                db.Update(bike);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(bike));
        }
示例#11
0
 public ActionResult Edit(Product_Details prod)
 {
     if (ModelState.IsValid)
     {
         var product = test.FirstOrDefault(x => x.Product_Id == prod.Product_Id);
         test.Remove(product);
         test.Add(prod);
         //repository.Edit(prod);
         return(RedirectToAction("Index"));
     }
     return(View(prod));
 }
示例#12
0
        public ActionResult Create(Product_Details prod)
        {
            // TODO: Add insert logic here

            if (ModelState.IsValid)
            {
                test.Add(prod);
                //repository.Create(prod);
                return(RedirectToAction("Index"));
            }
            return(View(prod));
        }
示例#13
0
        public async Task <IActionResult> Create([Bind("DetailID,ProductDetails,ArticleNumber")] Product_Details product_Details)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product_Details);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleNumber"] = new SelectList(_context.Products, "ArticleNumber", "Name", product_Details.ArticleNumber);
            return(View(product_Details));
        }
示例#14
0
        // GET: Product_Details/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Details product_Details = db.Product_Details.Find(id);

            if (product_Details == null)
            {
                return(HttpNotFound());
            }
            return(View(product_Details));
        }
示例#15
0
        // POST api/values
        public HttpStatusCode Post([FromBody] Product_Details value)
        {
            Product_Details Pd        = new Product_Details();
            int             IsSuccess = Pd.PostProduct(value);

            if (IsSuccess == 1)
            {
                return(HttpStatusCode.Created);
            }
            else
            {
                return(HttpStatusCode.BadRequest);
            }
        }
示例#16
0
        // DELETE api/values/5
        public HttpStatusCode Delete(Product_Details id)
        {
            Product_Details Pd = new Product_Details();

            int IsSuccess = Pd.PostProduct(id);

            if (IsSuccess == 1)
            {
                return(HttpStatusCode.Created);
            }
            else
            {
                return(HttpStatusCode.BadRequest);
            }
        }
示例#17
0
 public ActionResult Create(ClsProduct model)
 {
     using (CMPSEntities5 dbcontext = new CMPSEntities5())
     {
         if (model.Id == 0)
         {
             Product_Details tblCustomer = new Product_Details();
             tblCustomer.ModelPlace = model.ModelPlace;
             tblCustomer.Rate       = model.Rate;
             tblCustomer.ProductId  = model.ProductId;
             dbcontext.Product_Details.Add(tblCustomer);
             dbcontext.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
示例#18
0
 public ActionResult Update(ClsProduct model)
 {
     using (CMPSEntities5 dbcontext = new CMPSEntities5())
     {
         if (model.Id > 0)
         {
             Product_Details tblCustomer = dbcontext.Product_Details.Where(a => a.Id == model.Id).FirstOrDefault();
             if (tblCustomer != null)
             {
                 tblCustomer.ModelPlace = model.ModelPlace;
                 tblCustomer.Rate       = model.Rate;
                 dbcontext.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Index"));
 }
        public async Task <IActionResult> Create(Product_Details bike)
        {
            if (ModelState.IsValid)   // it will check whether our form is valid or not
            {
                if (bike.BikeImage != null)
                {
                    string rootPath   = env.WebRootPath;                  // get the root directory i.e. /wwwroot/
                    string uniqueName = Guid.NewGuid().ToString();

                    string fileName   = uniqueName + bike.BikeImage.FileName;  // file uploaded name
                    string uploadPath = rootPath + "/Images/" + fileName;      // creating upload path
                    bike.ImageName = fileName;                                 // assing file name to bike>imagename
                    using (var filestream = new FileStream(uploadPath, FileMode.Create))
                    {
                        await bike.BikeImage.CopyToAsync(filestream);
                    }
                }
                db.Add(bike);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(bike));
        }
示例#20
0
        public static void Seed(WebsiteContext C)
        {
            Branch_Category Chicken = new Branch_Category
            {
                Name = "Chicken"
            };

            Branch_Category Pork = new Branch_Category
            {
                Name = "Pork"
            };

            Branch_Category Fruit = new Branch_Category
            {
                Name = "Fruit"
            };

            Type_Category ChickenSoup = new Type_Category
            {
                Name           = "ChickenSoup",
                BranchCategory = Chicken,
            };

            Type_Category ChickenEgg = new Type_Category
            {
                Name           = "ChickenEgg",
                BranchCategory = Chicken,
            };

            Chicken.TypeCategory = new List <Type_Category>();
            Chicken.TypeCategory.Add(ChickenSoup);
            Chicken.TypeCategory.Add(ChickenEgg);
            ChickenSoup.BranchCategory = Chicken;
            ChickenEgg.BranchCategory  = Chicken;

            Normal_Category SaltChicken = new Normal_Category
            {
                Name = "SaltChicken"
            };

            Normal_Category SweetChicken = new Normal_Category
            {
                Name = "SweetChicken"
            };

            Normal_Category NoChicken = new Normal_Category
            {
                Name = "NoChicken"
            };

            Normal_Category GingerChicken = new Normal_Category
            {
                Name = "GingerChicken"
            };

            ChickenSoup.NormalCategory = new List <Normal_Category>();
            ChickenEgg.NormalCategory  = new List <Normal_Category>();
            ChickenSoup.NormalCategory.Add(SaltChicken);
            ChickenSoup.NormalCategory.Add(SweetChicken);
            ChickenSoup.NormalCategory.Add(NoChicken);
            ChickenEgg.NormalCategory.Add(GingerChicken);
            SaltChicken.TypeCategory   = ChickenSoup;
            SweetChicken.TypeCategory  = ChickenSoup;
            NoChicken.TypeCategory     = ChickenSoup;
            GingerChicken.TypeCategory = ChickenEgg;

            Recipe ChickenWings = new Recipe
            {
                Name = "ChickenWings"
            };

            Recipe ChickenNoodles = new Recipe
            {
                Name = "ChickenNoodles"
            };

            Recipe Spinach = new Recipe
            {
                Name = "Spinach"
            };

            TypeCategory_Recipe SpinachSoup = new TypeCategory_Recipe
            {
                Type_Category = ChickenSoup,
                Recipe        = Spinach,
                Percent       = 10,
                Weight        = 0.5
            };

            TypeCategory_Recipe ChickenRecipe = new TypeCategory_Recipe
            {
                Type_Category = ChickenEgg,
                Recipe        = ChickenWings,
                Percent       = 15,
                Weight        = 2.6
            };

            TypeCategory_Recipe ChickenRecipe2 = new TypeCategory_Recipe
            {
                Type_Category = ChickenEgg,
                Recipe        = ChickenNoodles,
                Percent       = 80,
                Weight        = 2.56
            };

            Product ChickenSticks = new Product
            {
                Name        = "ChickenSticks",
                Description = "small",
                Contents    = "very small",
            };

            Product Ketchup = new Product
            {
                Name        = "Ketchup",
                Description = "big",
                Contents    = "very big",
            };

            Product Curry = new Product
            {
                Name        = "Curry",
                Description = "Scary",
                Contents    = "thing",
            };

            Product Bread = new Product
            {
                Name        = "Bread",
                Description = "Useless",
                Contents    = "thing",
            };

            NormalCategory_Product ZeroChickenGiven = new NormalCategory_Product
            {
                Product         = ChickenSticks,
                Normal_Category = NoChicken
            };

            NormalCategory_Product BreadChicken = new NormalCategory_Product
            {
                Product         = Bread,
                Normal_Category = SaltChicken
            };

            NormalCategory_Product SaltyChicken = new NormalCategory_Product
            {
                Product         = Ketchup,
                Normal_Category = SaltChicken
            };

            Product_Details PD0 = new Product_Details
            {
                Product        = Curry,
                ProductDetails = "Tastes bad"
            };

            Product_Details PD1 = new Product_Details
            {
                Product        = Bread,
                ProductDetails = "White"
            };

            Curry.Details = new List <Product_Details>();
            Bread.Details = new List <Product_Details>();
            Curry.Details.Add(PD0);
            Bread.Details.Add(PD1);
            PD0.Product = Curry;
            PD1.Product = Bread;

            Text CurryText = new Text
            {
                Content       = "Bla Bla Pizza",
                WebsitePageID = 1
            };

            Text KetchupText = new Text
            {
                Content       = "Hi Hi Hi",
                WebsitePageID = 1
            };

            Text Important = new Text
            {
                Content       = "No Live",
                WebsitePageID = null
            };

            Text Important2 = new Text
            {
                Content       = "Oh No",
                WebsitePageID = 2
            };

            Product_Text PT0 = new Product_Text
            {
                Product = Bread,
                Text    = Important
            };

            Product_Text PT1 = new Product_Text
            {
                Product = Bread,
                Text    = Important2
            };

            Product_Text PT2 = new Product_Text
            {
                Product = ChickenSticks,
                Text    = CurryText
            };

            Recipe_Text RT0 = new Recipe_Text
            {
                Recipe = Spinach,
                Text   = KetchupText
            };

            Recipe_Text RT1 = new Recipe_Text
            {
                Recipe = ChickenNoodles,
                Text   = KetchupText
            };

            Recipe_Text RT2 = new Recipe_Text
            {
                Recipe = ChickenNoodles,
                Text   = Important2
            };

            News_Item MadPizza = new News_Item
            {
                Event_Date         = new DateTime().AddYears(2020).AddMonths(11).AddDays(2),
                Title              = "MadPizza",
                Last_Modified_Date = new DateTime().AddYears(1996).AddMonths(1).AddDays(5)
            };

            News_Item HappyPizza = new News_Item
            {
                Event_Date         = new DateTime().AddYears(2020).AddMonths(11).AddDays(3),
                Title              = "HappyPizza",
                Last_Modified_Date = new DateTime().AddYears(1996).AddMonths(1).AddDays(5)
            };

            Text_News TN0 = new Text_News
            {
                News = MadPizza,
                Text = CurryText
            };

            Text_News TN1 = new Text_News
            {
                News = MadPizza,
                Text = KetchupText
            };

            Text_News TN2 = new Text_News
            {
                News = HappyPizza,
                Text = CurryText
            };

            Language NL = new Language
            {
                LangTag = "nl"
            };

            Language EN = new Language
            {
                LangTag = "en"
            };

            Language DE = new Language
            {
                LangTag = "de"
            };

            CurryText.Language   = NL;
            Important.Language   = NL;
            Important2.Language  = EN;
            KetchupText.Language = DE;

            NL.Texts = new List <Text>();
            EN.Texts = new List <Text>();
            DE.Texts = new List <Text>();
            NL.Texts.Add(CurryText);
            NL.Texts.Add(Important);
            EN.Texts.Add(Important2);
            DE.Texts.Add(KetchupText);

            News_Category Mad = new News_Category
            {
                Category = "Mad"
            };

            News_Category Happy = new News_Category
            {
                Category = "Happy"
            };

            MadPizza.News_Category   = Mad;
            HappyPizza.News_Category = Happy;
            Mad.Items   = new List <News_Item>();
            Happy.Items = new List <News_Item>();
            Mad.Items.Add(MadPizza);
            Happy.Items.Add(HappyPizza);

            Photo AA = new Photo
            {
                PhotoPath = "/Img/uknownA.img"
            };

            Photo BB = new Photo
            {
                PhotoPath = "/Img/uknownB.img"
            };

            Photo CC = new Photo
            {
                PhotoPath = "/Img/uknownC.png"
            };

            Product_Photo AAA = new Product_Photo
            {
                Product = Ketchup,
                Photo   = AA
            };

            Product_Photo BBB = new Product_Photo
            {
                Product = Curry,
                Photo   = BB
            };

            Product_Photo CCC = new Product_Photo
            {
                Product = ChickenSticks,
                Photo   = CC
            };

            Recipe_Photo RP0 = new Recipe_Photo
            {
                Recipe = ChickenWings,
                Photo  = AA
            };

            Recipe_Photo RP1 = new Recipe_Photo
            {
                Recipe = ChickenWings,
                Photo  = BB
            };

            Recipe_Photo RP2 = new Recipe_Photo
            {
                Recipe = ChickenNoodles,
                Photo  = CC
            };

            Recipe_Photo RP3 = new Recipe_Photo
            {
                Recipe = ChickenNoodles,
                Photo  = AA
            };

            Photo_News PN0 = new Photo_News
            {
                Photo = AA,
                News  = MadPizza
            };

            Photo_News PN1 = new Photo_News
            {
                Photo = BB,
                News  = HappyPizza
            };

            Employee_Profile Henk = new Employee_Profile
            {
                Name = "Henk",
                Job  = "Sleeping",
                Profile_PhotoPath = "/images/Henk.png",
                CountryOrProvince = "Zuid-Holland",
                Region            = "Netherlands"
            };

            Employee_Profile Johan = new Employee_Profile
            {
                Name = "Johan",
                Job  = "Sales",
                Profile_PhotoPath = "/images/Johan.png",
                CountryOrProvince = "South-Africa",
                Region            = "Africa"
            };

            Employee_Profile Marit = new Employee_Profile
            {
                Name = "Marit",
                Job  = "ICT",
                Profile_PhotoPath = "/images/Marit.png"
            };

            Employee_Profile_Email EHenk = new Employee_Profile_Email
            {
                Email = "*****@*****.**"
            };

            Employee_Profile_Email EJohan = new Employee_Profile_Email
            {
                Email = "*****@*****.**"
            };

            Employee_Profile_Email EMarit = new Employee_Profile_Email
            {
                Email = "*****@*****.**"
            };

            Employee_Profile_Email EMarit2 = new Employee_Profile_Email
            {
                Email = "*****@*****.**",
            };

            EMarit.Employee  = Marit;
            EMarit2.Employee = Marit;
            EHenk.Employee   = Henk;
            EJohan.Employee  = Johan;
            Marit.Emails     = new List <Employee_Profile_Email>();
            Henk.Emails      = new List <Employee_Profile_Email>();
            Johan.Emails     = new List <Employee_Profile_Email>();
            Marit.Emails.Add(EMarit);
            Marit.Emails.Add(EMarit2);
            Henk.Emails.Add(EHenk);
            Johan.Emails.Add(EJohan);

            Employee_Profile_Phone_Number N0 = new Employee_Profile_Phone_Number
            {
                Number = "3160000000000"
            };

            Employee_Profile_Phone_Number N1 = new Employee_Profile_Phone_Number
            {
                Number = "3160000000001"
            };

            N0.Employee        = Henk;
            N1.Employee        = Henk;
            Henk.Phone_Numbers = new List <Employee_Profile_Phone_Number>();
            Henk.Phone_Numbers.Add(N0);
            Henk.Phone_Numbers.Add(N1);

            Subscriber Sleep = new Subscriber
            {
                Email = "*****@*****.**"
            };

            Subscriber Pizza = new Subscriber
            {
                Email = "*****@*****.**"
            };

            C.Branch_Categories.Add(Chicken);
            C.Branch_Categories.Add(Pork);
            C.Branch_Categories.Add(Fruit);
            C.Type_Categories.Add(ChickenSoup);
            C.Type_Categories.Add(ChickenEgg);
            C.Normal_Categories.Add(SaltChicken);
            C.Normal_Categories.Add(SweetChicken);
            C.Normal_Categories.Add(NoChicken);
            C.Normal_Categories.Add(GingerChicken);
            C.Recipes.Add(ChickenWings);
            C.Recipes.Add(ChickenNoodles);
            C.Recipes.Add(Spinach);
            C.TypeCategory_Recipes.Add(SpinachSoup);
            C.TypeCategory_Recipes.Add(ChickenRecipe);
            C.TypeCategory_Recipes.Add(ChickenRecipe2);
            C.Products.Add(ChickenSticks);
            C.Products.Add(Ketchup);
            C.Products.Add(Curry);
            C.Products.Add(Bread);
            C.NormalCategory_Products.Add(ZeroChickenGiven);
            C.NormalCategory_Products.Add(BreadChicken);
            C.NormalCategory_Products.Add(SaltyChicken);
            C.Product_Details.Add(PD0);
            C.Product_Details.Add(PD1);
            C.Text.Add(CurryText);
            C.Text.Add(KetchupText);
            C.Text.Add(Important);
            C.Text.Add(Important2);
            C.Product_Texts.Add(PT0);
            C.Product_Texts.Add(PT1);
            C.Product_Texts.Add(PT2);
            C.Recipe_Texts.Add(RT0);
            C.Recipe_Texts.Add(RT1);
            C.Recipe_Texts.Add(RT2);
            C.News_Items.Add(MadPizza);
            C.News_Items.Add(HappyPizza);
            C.Text_News.Add(TN0);
            C.Text_News.Add(TN1);
            C.Text_News.Add(TN2);
            C.Languages.Add(NL);
            C.Languages.Add(EN);
            C.Languages.Add(DE);
            C.News_Categories.Add(Mad);
            C.News_Categories.Add(Happy);
            C.Photos.Add(AA);
            C.Photos.Add(BB);
            C.Photos.Add(CC);
            C.Product_Photos.Add(AAA);
            C.Product_Photos.Add(BBB);
            C.Product_Photos.Add(CCC);
            C.Recipe_Photos.Add(RP0);
            C.Recipe_Photos.Add(RP1);
            C.Recipe_Photos.Add(RP2);
            C.Recipe_Photos.Add(RP3);
            C.Photo_News.Add(PN0);
            C.Photo_News.Add(PN1);
            C.Employee_Profiles.Add(Henk);
            C.Employee_Profiles.Add(Johan);
            C.Employee_Profiles.Add(Marit);
            C.Employee_Profile_Emails.Add(EHenk);
            C.Employee_Profile_Emails.Add(EJohan);
            C.Employee_Profile_Emails.Add(EMarit);
            C.Employee_Profile_Emails.Add(EMarit2);
            C.Employee_Profile_Phone_Numbers.Add(N0);
            C.Employee_Profile_Phone_Numbers.Add(N1);
            C.Subscribers.Add(Sleep);
            C.Subscribers.Add(Pizza);

            C.SaveChanges();
        }