public ActionResult PromotionSetStatusEnable(int id) { tbl_promotion tic = getOnePromotion(id); tic.status = !tic.status; UpdateModel(tic); data.SubmitChanges(); return(RedirectToAction("PromotionView")); }
public ActionResult PromotionDetail(int id) { var listPromotionDetail = getListPromotionDetailById(id); tbl_promotion tic = getOnePromotion(id); ViewBag.id = tic.Id; ViewBag.name = tic.Tenkhuyenmai; ViewBag.ngaykhuyenmai = tic.ngaykhuyenmai; ViewBag.ngayketthuc = tic.ngayketthuc; return(View(URLHelper.URL_ADMIN_PROMOTION_M, listPromotionDetail)); }
public ActionResult PromotionDetail(string id, string timkiem, int?page) { int pageNum = page ?? 1; int pageSize = 10; ViewBag.alias = id; string tukhoa = timkiem; if (String.IsNullOrEmpty(tukhoa)) { tukhoa = ""; } ViewBag.tukhoa = tukhoa; List <tbl_promotion_detail> CT_SP = (from k in db.tbl_promotion_details from s in db.tbl_promotions from p in db.tbl_Products where s.alias.Equals(id) && s.Id == k.Idkm && k.Idsp == p.ID && p.TenSP.Contains(tukhoa) orderby k.Id descending select k).ToList(); tbl_promotion pro = db.tbl_promotions.SingleOrDefault(n => n.alias.Equals(id)); List <DataHelper.PromotionAddItemModel> CT_SP_CO_LUON_TEN_SP = new List <DataHelper.PromotionAddItemModel>(); foreach (tbl_promotion_detail promotionDetail in CT_SP) { DataHelper.PromotionAddItemModel model = new DataHelper.PromotionAddItemModel(); model.name = DataHelper.ProductHelper.getInstance().getProductById(db, promotionDetail.Idsp).TenSP; model.price = promotionDetail.Giaban.Value; model.pricepd = promotionDetail.Giakhuyenmai.Value; model.proid = promotionDetail.Idsp; model.kh = promotionDetail.KhuyenMai.Value; model.gift = promotionDetail.Gift; model.quantity = promotionDetail.quantity.Value; model.image = DataHelper.ProductHelper.getInstance().getProductById(db, promotionDetail.Idsp).UrlHinh; model.alias = DataHelper.ProductHelper.getInstance().getProductById(db, promotionDetail.Idsp).alias; CT_SP_CO_LUON_TEN_SP.Add(model); } return(View(CT_SP_CO_LUON_TEN_SP.ToPagedList(pageNum, pageSize))); }
public ActionResult promotionCreate(FormCollection form, String btnAdd, HttpPostedFileBase fileUpload) { if (btnAdd != null) { //Delete checked items string checkedList = form["chk[]"]; if (!String.IsNullOrEmpty(checkedList)) { string[] arrayStringCheckedList = checkedList.Split(new char[] { ',' }); for (int i = 0; i < arrayStringCheckedList.Length; i++) { try { // data.tbl_Products.DeleteOnSubmit(getOneItem(Int32.Parse(arrayStringCheckedList[i]))); data.SubmitChanges(); ViewBag.AlertSuccess = "Xoá thành công!"; } catch (Exception e) { ViewBag.AlertError = "Không xoá được"; } } } } tbl_promotion tic = new tbl_promotion(); var name = form["name"]; var price = form["price"]; var price2 = form["price2"]; var detail = form["detail"]; var sold_amount = form["soldamount"]; tic.alias = DataHelper.GeneralHelper.getInstance().getAliasFromPromotionName(data, name); List <DataHelper.PromotionAddItemModel> list = getProduct(); bool err = false; if (String.IsNullOrEmpty(name)) { err = true; ViewData["Error"] += "Vui lòng nhập tên khuyến mãi!\n"; } tic.Tenkhuyenmai = name; tic.status = true; tic.ngaytao = DateTime.Now; tic.ngaykhuyenmai = Convert.ToDateTime(price); tic.ngayketthuc = Convert.ToDateTime(price2); tic.Noidung = detail; if (form["chkClearImg"] != null) { tic.AnhBia = ""; } else if (fileUpload != null) { var fileName = Path.GetFileName(DateTime.Now.Millisecond + fileUpload.FileName); var path = Path.Combine(Server.MapPath(URLHelper.URL_IMAGE_PATH), fileName); if (!System.IO.File.Exists(path)) { fileUpload.SaveAs(path); } tic.AnhBia = fileName; } if (err == false) { data.tbl_promotions.InsertOnSubmit(tic); data.SubmitChanges(); foreach (var item in list) { tbl_promotion_detail ctkm = new tbl_promotion_detail(); ctkm.Idkm = item.modelid; ctkm.Idsp = item.proid; ctkm.quantity = item.quantity; ctkm.Giaban = (decimal)item.price; ctkm.Giakhuyenmai = (decimal)item.pricepd; ctkm.Gift = item.gift; data.tbl_promotion_details.InsertOnSubmit(ctkm); } return(RedirectToAction("promotionView")); } else { return(View(URLHelper.URL_ADMIN_PROMOTION_M, new Tuple <tbl_promotion, List <tbl_Product> >(tic, getAllItem()))); } }