Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Product_Promotion product_Promotion = db.Product_Promotion.Find(id);

            db.Product_Promotion.Remove(product_Promotion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "PromotionId,ProductId,Gift")] Product_Promotion product_Promotion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product_Promotion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", product_Promotion.ProductId);
     ViewBag.ProductId = new SelectList(db.Promotions, "PromotionId", "PromotionName", product_Promotion.ProductId);
     return(View(product_Promotion));
 }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "PromotionId,ProductId,Gift")] Product_Promotion product_Promotion)
        {
            if (ModelState.IsValid)
            {
                db.Product_Promotion.Add(product_Promotion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId   = new SelectList(db.Products, "ProductId", "ProduceCode", product_Promotion.ProductId);
            ViewBag.PromotionId = new SelectList(db.Promitions, "PromotionId", "PromotionName", product_Promotion.PromotionId);
            return(View(product_Promotion));
        }
Beispiel #4
0
        // GET: Admin/Product_Promotion/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Promotion product_Promotion = db.Product_Promotion.Find(id);

            if (product_Promotion == null)
            {
                return(HttpNotFound());
            }
            return(View(product_Promotion));
        }
Beispiel #5
0
        // GET: Admin/Product_Promotion/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product_Promotion product_Promotion = db.Product_Promotion.Find(id);

            if (product_Promotion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", product_Promotion.ProductId);
            ViewBag.ProductId = new SelectList(db.Promotions, "PromotionId", "PromotionName", product_Promotion.ProductId);
            return(View(product_Promotion));
        }
Beispiel #6
0
 private Product_Promotion EmptyIfNull(Product_Promotion p1)
 {
     p1.ma_gia_san_pham     = (p1.ma_gia_san_pham == null) ? "" : p1.ma_gia_san_pham;
     p1.loai_km             = string.IsNullOrEmpty(p1.loai_km.ToString()) ? 0 : p1.loai_km;
     p1.tien_km             = string.IsNullOrEmpty(p1.tien_km.ToString()) ? 0 : p1.tien_km;
     p1.phan_tram_km        = string.IsNullOrEmpty(p1.phan_tram_km.ToString()) ? 0 : p1.phan_tram_km;
     p1.gia_sau_km          = string.IsNullOrEmpty(p1.gia_sau_km.ToString()) ? 0 : p1.gia_sau_km;
     p1.so_ngay_km          = string.IsNullOrEmpty(p1.so_ngay_km.ToString()) ? 0 : p1.so_ngay_km;
     p1.ngay_bat_dau        = string.IsNullOrEmpty(p1.ngay_bat_dau.ToString()) ? DateTime.Parse("1900-01-01") : p1.ngay_bat_dau;
     p1.ngay_ket_thuc       = string.IsNullOrEmpty(p1.ngay_ket_thuc.ToString()) ? DateTime.Parse("1900-01-01") : p1.ngay_ket_thuc;
     p1.nguoi_duyet         = (p1.nguoi_duyet == null) ? "" : p1.nguoi_duyet;
     p1.ngay_duyet          = string.IsNullOrEmpty(p1.ngay_duyet.ToString()) ? DateTime.Parse("1900-01-01") : p1.ngay_duyet;
     p1.nguoi_xuat_ban      = (p1.nguoi_xuat_ban == null) ? "" : p1.nguoi_xuat_ban;
     p1.ngay_xuat_ban       = string.IsNullOrEmpty(p1.ngay_xuat_ban.ToString()) ? DateTime.Parse("1900-01-01") : p1.ngay_xuat_ban;
     p1.trang_thai_duyet    = (p1.trang_thai_duyet == null) ? "" : p1.trang_thai_duyet;
     p1.trang_thai_xuat_ban = (p1.trang_thai_xuat_ban == null) ? "" : p1.trang_thai_xuat_ban;
     p1.trang_thai          = (p1.trang_thai == null) ? "" : p1.trang_thai;
     return(p1);
 }
Beispiel #7
0
 public ActionResult Upsert(Product_Promotion item)
 {
     if (asset.Create || asset.Update)
     {
         string result = "";
         try
         {
             List <Product_Promotion> lstProdPromotion = new List <Product_Promotion>();
             lstProdPromotion.Add(item);
             result = new Product_Promotion_DAO().UpSert(lstProdPromotion, currentUser.UserName, "Insert");
             if (result == "true")
             {
                 if (item.id == 0)// 0 insert, 1 update
                 {
                     return(Json(new { success = true, type = 0 }));
                 }
                 else
                 {
                     return(Json(new { success = true, type = 1 }));
                 }
             }
             else
             {
                 return(Json(new { success = false, message = result }));
             }
         }
         catch (Exception e)
         {
             return(Json(new { success = false, message = "Có lỗi file upload" + e.Message }));
         }
     }
     else
     {
         return(Json(new { success = false, message = "Bạn không có quyền." }));
     }
 }