示例#1
0
        public PartialViewResult _SanPham(int MaLoaiSanPham)
        {
            List <SanPham_LoaiSanPham> lstSP = SanPham_Service.SP_GetAllBy(MaLoaiSanPham);
            List <Combo_SanPham>       lstCB = Combo_Service.CB_GetAllBy(MaLoaiSanPham);

            TempData["sanPham"] = lstSP;
            TempData["comBo"]   = lstCB;
            return(PartialView());
        }
示例#2
0
 public PartialViewResult SanPham_ChiTiet(int MaMatHang, bool laSanPham)
 {
     if (laSanPham == false)
     {
         Combo_SanPham sp_cb = Combo_Service.SelectByPrimaryKey(MaMatHang);
         ViewBag.cbdetail = sp_cb;
     }
     else
     {
         SanPhamDAO sp = SanPham_Service.GetByID(MaMatHang);
         ViewBag.spdetail = sp;
     }
     return(PartialView());
 }
示例#3
0
        public PartialViewResult _Combo(int pageNumber = 1, int pageSize = 10, string keyText = "")
        {
            List <Combo_SanPham> list = new List <Combo_SanPham>();

            try
            {
                int totalEntries;
                list = Combo_Service.REL_GetAllBy(pageNumber, pageSize, keyText, out totalEntries);
                ViewBag.maxNumber  = Math.Ceiling(totalEntries / (double)pageSize);
                ViewBag.pageNumber = pageNumber;
                ViewBag.pageSize   = pageSize;
            }
            catch (Exception e)
            {
                throw e;
            }
            return(PartialView(list));
        }
示例#4
0
        public ActionResult Combo_ChiTiet(int ID = 0)
        {
            ViewBag.MaCombo = ID;
            Combo_SanPham combo_sanPham = new Combo_SanPham();

            if (ID != 0)
            {
                combo_sanPham = Combo_Service.SelectByPrimaryKey(ID);
            }
            String selectHtml = "";
            List <SanPham_TypeInsertCombo> dsSanPham = SanPham_Service.SelectAllForCombo();

            for (int i = 0; i < dsSanPham.Count; i++)
            {
                selectHtml += "<option value='" + dsSanPham[i].MaSanPham + "'>" + dsSanPham[i].TenSanPham + "</option>";
            }
            ViewBag.dsSanPham = dsSanPham;
            ViewBag.selectTag = selectHtml;
            return(View(combo_sanPham));
        }
示例#5
0
        public JsonResult addOrUpdateCombo(Combo_Insert obj, bool isUpdate)
        {
            AjaxResultModel Result = new AjaxResultModel();

            bool check = true;

            try
            {
                if (isUpdate)
                {
                    check = Combo_Service.Update(obj);
                }
                else
                {
                    check = Combo_Service.Insert(obj);
                }
                if (check)
                {
                    Result.Code    = 0;
                    Result.Message = "Thành công";
                }
                else
                {
                    Result.Code    = 1;
                    Result.Message = "Đã có lỗi xảy ra. Vui lòng thử lại.";
                }
            }
            catch (Exception e)
            {
                Result.Code    = 1;
                Result.Message = e.Message;
                //throw;
            }
            return(Json(new JsonResult()
            {
                Data = Result
            }));
        }
示例#6
0
        public bool GetSP(int MaMatHang, bool laSanPham, int soLuong)
        {
            if (Session["giohang"] == null)
            {
                Session["giohang"] = new List <GioHang>();
            }
            List <GioHang> giohang = Session["giohang"] as List <GioHang>;

            if (laSanPham == false)
            {
                if (giohang.FirstOrDefault(x => (x.cb != null && x.cb.MaCombo == MaMatHang)) == null)
                {
                    giohang.Add(new GioHang {
                        cb = Combo_Service.SelectByPrimaryKey(MaMatHang), SoLuong = soLuong
                    });
                }
                else
                {
                    GioHang item = giohang.FirstOrDefault(x => (x.cb != null && x.cb.MaCombo == MaMatHang));
                    item.SoLuong += soLuong;
                }
            }
            else
            {
                if (giohang.FirstOrDefault(x => (x.sp != null && x.sp.MaSanPham == MaMatHang)) == null)
                {
                    giohang.Add(new GioHang {
                        sp = SanPham_Service.GetByID(MaMatHang), SoLuong = soLuong
                    });
                }
                else
                {
                    GioHang item = giohang.FirstOrDefault(x => (x.sp != null && x.sp.MaSanPham == MaMatHang));
                    item.SoLuong += soLuong;
                }
            }
            return(true);
        }