public ActionResult Edit(ShipmaneAllViewModel sa, int page) { //記錄目前頁數,若是空值就給1 TempData["savepage"] = page; var oh = db.OrderHeaders.Find(sa.OrderID); oh.ShippingID = sa.ShippingID; db.Entry(oh).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { page = TempData["savepage"] })); }
public ActionResult UpdateStockQTY(int stockID, int stockQTY, int minStock) { try { ProductStock _PS = db.ProductStocks.Find(stockID); _PS.StockID = stockID; _PS.ProductID = _PS.ProductID; _PS.ProductSizeID = _PS.ProductSizeID; _PS.ProductColorID = _PS.ProductColorID; _PS.StockQTY = stockQTY; _PS.MinStock = minStock; _PS.CreateDate = _PS.CreateDate; db.Entry(_PS).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new { State = true, Message = "庫存量改動成功!!", })); } catch (Exception ex) { return(Json(new { State = false, Message = ex.ToString(), })); } }
public IHttpActionResult PutMiddle(int id, CategoryMiddle _categoryMiddle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != _categoryMiddle.CategoryMID) { return(BadRequest()); } db.Entry(_categoryMiddle).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CategoryMiddleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(Shipping sp) { db.Entry(sp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { page = TempData["savepage"] })); }
public ActionResult Edit(CategoryMiddle cate) { db.Entry(cate).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { page = TempData["savepage"] })); }
public ActionResult Edit(int pcid, int phid) { if (phid == 0) { return(Json(new { Status = false, Message = "圖檔未選取 !", })); } try { ProductColor pc = db.ProductColors.Find(pcid); pc.PhotoID = phid; db.Entry(pc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { return(Json(new { Status = false, Message = ex.ToString(), })); } return(Json(new { Status = true, photoid = phid })); }
public ActionResult Edit(int psid, int stockqty, int minqty) { try { ProductStock pc = db.ProductStocks.Find(psid); pc.StockQTY = stockqty; pc.MinStock = minqty; db.Entry(pc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception ex) { return(Json(new { Status = false, Message = ex.ToString(), })); } return(Json(new { Status = true, })); }
public ActionResult Edit(StockListViewModel sl) { ProductStock ps = db.ProductStocks.Where(x => x.StockID == sl.StockID).FirstOrDefault(); ps.StockQTY = ps.StockQTY + sl.AddQTY; db.Entry(ps).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("StockList", "AddStock", new { area = "Backend", page = TempData["savepage"] })); }
public ActionResult Edit(CategorySViewModel csm) { CategorySmall cs = db.CategorySmalls.Find(csm.CategorySID); cs.CategorySName = csm.CategorySName; db.Entry(cs).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { page = TempData["savepage"], catemid = csm.CategoryMID })); }
public ActionResult ChangeQty(int id, int cid, int sid, int qty) { List <CartItem> cart; int uid = int.Parse(Request.Cookies["upid"].Value); var sameitem = db.Carts.Where(c => c.UserID == uid && c.ProductID == id && c.ProductColorID == cid && c.ProductSizeID == sid).First(); sameitem.Quantity = qty; db.Entry(sameitem).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); cart = ProductMethod.Cart(uid); return(Json(cart, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(ActivityEditModel form) { var _av = db.Activities.Find(form.ActivityID); _av.ActivityName = form.ActivityName; _av.BeginDate = form.BeginDate; _av.EndDate = form.EndDate; _av.ActivityID = form.ActivityID; _av.DiscountID = form.DiscountID; db.Entry(_av).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit", new { id = form.ActivityID })); }
public ActionResult Edit(ActivityViewModel avm, int?page) { var av = db.Activities.Find(avm.ActivityID); av.ActivityName = avm.ActivityName; av.BeginDate = avm.BeginDate; av.EndDate = avm.EndDate; av.ActivityID = avm.ActivityID; av.DiscountID = avm.DiscountID; db.Entry(av).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); TempData["savepage"] = page ?? 1; return(RedirectToAction("Edit", new { id = avm.ActivityID, page = TempData["savepage"] })); }
public ActionResult Edit(ProductMaintainViewModel _form) { Product _P = new Product(); _P.ProductID = _form.ProductID; _P.ProductName = _form.ProductName; _P.Desctiption = _form.Desctiption; _P.UnitPrice = _form.UnitPrice; _P.CategorySID = _form.CategorySID; _P.SupplierID = (int)_form.SupplierID; _P.ProductInDate = _form.ProductInDate; _P.ProductOutDate = _form.ProductOutDate; db.Entry(_P).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ProductViewModel pvm, int?page) { //記錄目前頁數,若是空值就給1 TempData["savepage"] = page ?? 1; var pd = db.Products.Find(pvm.ProductID); pd.ProductName = pvm.ProductName; pd.Desctiption = pvm.Desctiption; pd.CategorySID = pvm.CategorySID; pd.SupplierID = pvm.SupplierID; pd.UnitPrice = pvm.UnitPrice; pd.ProductInDate = pvm.ProductInDate; pd.ProductOutDate = pvm.ProductOutDate; db.Entry(pd).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { catesid = pvm.CategorySID, page = TempData["savepage"] })); }
//加入購物車 public ActionResult AddCart(CartItem item) { List <CartItem> cart; item.ProductName = db.Products.Find(item.ProductID).ProductName; item.ColorName = db.Colors.Find(item.ColorID).ColorName; item.SizeName = db.Sizes.Find(item.SizeID).SizeName; //會員 if (Session["IsLogin"] != null || Request.Cookies["IsLogin"] != null) { int uid = int.Parse(Request.Cookies["upid"].Value); int pcid = db.ProductColors.Where(c => c.ProductID == item.ProductID && c.ColorID == item.ColorID).First().ProductColorID; int psid = db.ProductSizes.Where(c => c.ProductID == item.ProductID && c.SizeID == item.SizeID).First().ProductSizeID; var sameitem = db.Carts.Where(c => c.UserID == uid && c.ProductID == item.ProductID && c.ProductColorID == pcid && c.ProductSizeID == psid).ToList(); //購物車內已有相同款式商品 if (sameitem.Count() > 0) { sameitem.First().Quantity += item.OrderQTY; db.Entry(sameitem.First()).State = System.Data.Entity.EntityState.Modified; } //購物車內無相同款式 else { Cart cartitem = new Cart() { UserID = uid, ProductID = item.ProductID, ProductColorID = pcid, ProductSizeID = psid, Quantity = item.OrderQTY, UnitPrice = item.UnitPrice }; db.Carts.Add(cartitem); } db.SaveChanges(); //把db.cart內容回傳cart> cart = ProductMethod.Cart(uid); return(Json(cart, JsonRequestBehavior.AllowGet)); } //非會員 else { ////已有購物車(非購買第一件商品) //if (Session["cart"] != null) //{ // cart = (List<CartItem>)Session["cart"]; // var incart = cart.Where(c => c.ProductID == item.ProductID && c.ColorID == item.ColorID && c.SizeID == item.SizeID).ToList(); // //購物車內已有相同款式商品 // if (incart.Count() > 0) // { // incart.First().OrderQTY += item.OrderQTY; // } // //購物車內無相同款式 // else // { // cart.Add(item); // } // Session.Add("cart", cart); //} ////尚未產生購物車(購買第一項商品) //else //{ // //建立購物車 // cart = new List<CartItem>(); // //加入商品 // cart.Add(item); // Session.Add("cart", cart); //} return(Json("notmember", JsonRequestBehavior.AllowGet)); } }
public ActionResult Upload(HttpPostedFileBase uploadfile) { if (Request.Files["uploadfile"].ContentLength > 0) { string extension = System.IO.Path.GetExtension(uploadfile.FileName); if (extension == ".xls" || extension == ".xlsx") { string fileLocation = Server.MapPath("~/Content/") + Request.Files["uploadfile"].FileName; if (System.IO.File.Exists(fileLocation)) // 驗證檔案是否存在 { System.IO.File.Delete(fileLocation); } Request.Files["uploadfile"].SaveAs(fileLocation); // 存放檔案到伺服器上 // 建立一個工作簿 XSSFWorkbook excel; // 檔案讀取 using (FileStream files = new FileStream(fileLocation, FileMode.Open, FileAccess.Read)) { excel = new XSSFWorkbook(files); // 將剛剛的Excel 讀取進入到工作簿中 } // Excel 的哪一個活頁簿,有兩種方式可以取得活頁簿 ISheet sheet = excel.GetSheetAt(0); // 在第幾個活頁簿,饅頭建議使用,畢竟我們不知道使用者會把活頁部取神麼名字,先抓地一個在說!(從0開始計算) for (int row = 1; row <= sheet.LastRowNum; row++) // 使用For 走訪所有的資料列 { if (sheet.GetRow(row) != null) // 驗證是不是空白列 { Color _npoi = new Color(); for (int c = 0; c <= sheet.GetRow(row).LastCellNum; c++) // 使用For 走訪資料欄 { switch (c) { case 0: _npoi.ColorID = sheet.GetRow(row).GetCell(c).RowIndex; break; case 1: _npoi.ColorName = sheet.GetRow(row).GetCell(c).StringCellValue; break; case 2: _npoi.R = Convert.ToInt32 (sheet.GetRow(row).GetCell(c).NumericCellValue); break; case 3: _npoi.G = Convert.ToInt32 (sheet.GetRow(row).GetCell(c).NumericCellValue); break; case 4: _npoi.B = Convert.ToInt32 (sheet.GetRow(row).GetCell(c).NumericCellValue); break; } } db.Entry(_npoi).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } } } return(this.RedirectToAction("Index")); }
public void Update(Product _product) { db.Entry(_product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Update(Shipping _shipping) { db.Entry(_shipping).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Update(Size _size) { db.Entry(_size).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Update(Color _color) { db.Entry(_color).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Update(Supplier _supplier) { db.Entry(_supplier).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }