/// <summary>
        /// Xóa sách khuyến mại trong chi tiết khuyến mại
        /// </summary>
        /// <param name="makm"></param>
        /// <param name="maSach"></param>
        public void deleteCTKM(int makm, int maSach)
        {
            CHITIETKM ctkm = db.CHITIETKMs.Find(makm, maSach);

            db.CHITIETKMs.Remove(ctkm);
            db.SaveChanges();
        }
        /// <summary>
        /// Sửa lại phần trăm khuyến mại cho sách
        /// </summary>
        /// <param name="makm">Mã khuyến mại</param>
        /// <param name="maSach">Mã sách</param>
        /// <param name="pTKM"></param>
        public void editCTKM(int makm, int maSach, int pTKM)
        {
            CHITIETKM ctkm = db.CHITIETKMs.Find(makm, maSach);

            ctkm.PTKM = pTKM;
            db.SaveChanges();
        }
Esempio n. 3
0
 public bool addPromotionDetail(CHITIETKM ctkm)
 {
     try
     {
         db.CHITIETKMs.Add(ctkm);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Thêm sách khuyến mại vào listCTKM chờ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ThemSachKM_Click(object sender, EventArgs e)
        {
            CHITIETKM ctkm = new CHITIETKM();

            ctkm.ID_SACH  = int.Parse(cbx_SachKM.SelectedValue.ToString());
            ctkm.PTKM     = Int32.Parse(txt_PtKM.Text.ToString());
            ctkm.ID_KM    = int.Parse(txt_MaKM.Text);
            ctkm.ISDELETE = false;
            listCTKM.Add(ctkm);
            txt_PtKM.ResetText();
            cbx_SachKM.ResetText();
            txt_TenKM.Enabled   = false;
            dgv_CTKM.DataSource = null;
            dgv_CTKM.DataSource = listCTKM;
        }
        public ActionResult Update(string makm, int masp)
        {
            CHITIETKM chitietkm = promotionDetailService.getOnePromotionDetail(makm, masp);

            PromotionDetailViewModel promotionDetailViewModel = new PromotionDetailViewModel();

            promotionDetailViewModel.MAKM = chitietkm.MAKM;

            promotionDetailViewModel.MASP = chitietkm.MASP;

            promotionDetailViewModel.PHANTRAMKM = (int)chitietkm.PHANTRAMKM;

            ViewBag.KHUYENMAI = chitietkm.KHUYENMAI.TENKM;
            ViewBag.SANPHAM   = chitietkm.SANPHAM.TENSP;

            return(View(promotionDetailViewModel));
        }
        public ActionResult Create(PromotionDetailViewModel ctkm)
        {
            if (ModelState.IsValid)
            {
                CHITIETKM chitietkm = new CHITIETKM();
                chitietkm.MAKM       = ctkm.MAKM;
                chitietkm.MASP       = ctkm.MASP;
                chitietkm.PHANTRAMKM = ctkm.PHANTRAMKM;

                if (promotionDetailService.addPromotionDetail(chitietkm))
                {
                    ViewBag.message = "Thêm mới chi tiết khuyến mãi thành công";
                }
            }
            ViewBag.KHUYENMAIx = promotionDetailService.getALLPromotion();
            ViewBag.SANPHAMx   = promotionDetailService.getAllProduct();
            return(View(ctkm));
        }
Esempio n. 7
0
 public bool updatePromotionDetail(CHITIETKM ctkm)
 {
     try
     {
         var result = db.CHITIETKMs.Find(ctkm.MAKM, ctkm.MASP);
         if (result != null)
         {
             result.PHANTRAMKM = ctkm.PHANTRAMKM;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public ActionResult Update(PromotionDetailViewModel ctkm)
        {
            if (ModelState.IsValid)
            {
                CHITIETKM chitietkm = new CHITIETKM();
                chitietkm.MAKM       = ctkm.MAKM;
                chitietkm.MASP       = ctkm.MASP;
                chitietkm.PHANTRAMKM = ctkm.PHANTRAMKM;

                if (promotionDetailService.updatePromotionDetail(chitietkm))
                {
                    return(RedirectToAction("Index", "PromotionDetail", promotionDetailService.getAllPromotionDetail()));
                }
            }
            CHITIETKM chitiet = promotionDetailService.getOnePromotionDetail(ctkm.MAKM, ctkm.MASP);

            ViewBag.KHUYENMAI = chitiet.KHUYENMAI.TENKM;
            ViewBag.SANPHAM   = chitiet.SANPHAM.TENSP;
            return(View(ctkm));
        }