コード例 #1
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());
 }
コード例 #2
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);
        }