public bool Create(SanphamModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_item_create",
                                                                              "@masanpham", model.masanpham,
                                                                              "@tensanpham", model.tensanpham,
                                                                              "@mau", model.mau,
                                                                              "@dongia", model.dongia,
                                                                              "@content", model.content,
                                                                              "@manhasanxuat", model.manhasanxuat,
                                                                              "@maloai", model.maloai);
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public bool Update(SanphamModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "suasanpham",
                                                                              "@MASP", model.MASP,
                                                                              "@MACODE", model.MACODE,
                                                                              "@TENSP", model.TENSP,
                                                                              "@GIA", model.GIA,
                                                                              "@MAGIAMGIA", model.MAGIAMGIA,
                                                                              "@HINH", model.HINH,
                                                                              "@SOLUONGTON", model.SOLUONGTON,
                                                                              "@NGAYNHAP", model.NGAYNHAP,
                                                                              "@MOTA", model.MOTA,
                                                                              "@ANHIEN", model.ANHIEN,
                                                                              "@MALOAI", model.MALOAI
                                                                              );
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public JsonResult SeachWithname(string name)
        {
            SanphamModel       list = new SanphamModel();
            IQueryable <SPHAM> kq   = list.Searchwithname(name);
            var js = (from p in kq orderby p.MASP descending select new { p.MASP, p.TENSP, p.ANHDAIDIEN, p.GIA }).Take(5);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }
        public ActionResult themsp()
        {
            SanphamModel sp = new SanphamModel();

            ViewBag.HANGSX = new SelectList(sp.Gethangsanxuat(), "HANGSX", "TENHANG ");
            ViewBag.LOAISP = new SelectList(sp.Getloaisp(), "MALOAI", "TENLOAI");
            return(View());
        }
 protected void rptSanpham_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         SanphamModel sanpham = e.Item.DataItem as SanphamModel;
         if (sanpham != null)
         {
             Image imgSanpham = e.Item.FindControl("imgSanpham") as Image;
             if (imgSanpham != null)
             {
                 imgSanpham.ImageUrl = string.Format("~/{0}", sanpham.sHinhanh);
             }
             Literal           ltrGiaDangApdung = e.Item.FindControl("ltrGiaDangApdung") as Literal;
             SanphamController brlSanpham       = new SanphamController();
             if (ltrGiaDangApdung != null)
             {
                 decimal giaDangApdung = brlSanpham.GetGiaDangApdungByFKSanphamID(sanpham.PK_iSanphamID);
                 ltrGiaDangApdung.Text = giaDangApdung < 0 ? "Liên hệ" : giaDangApdung.ToString("C0");
             }
             Literal ltrLoaiSanpham = e.Item.FindControl("ltrLoaiSanpham") as Literal;
             if (ltrLoaiSanpham != null)
             {
                 int loaiSanphamID = sanpham.FK_iLoaiSanphamID;
                 if (loaiSanphamID > 0)
                 {
                     List <LoaiSanphamModel> glstLoaisanpham = brlSanpham.LoaiSanphamGetbyPK(loaiSanphamID);
                     if (glstLoaisanpham.Count > 0)
                     {
                         ltrLoaiSanpham.Text = glstLoaisanpham[0].sTenLoaiSanpham;
                     }
                 }
             }
             Literal ltrKhuyenmaiDangApdung = e.Item.FindControl("ltrKhuyenmaiDangApdung") as Literal;
             if (ltrKhuyenmaiDangApdung != null)
             {
                 int khuyenmaiDangapdung = Convert.ToInt32(brlSanpham.GetKhuyenmaiDangApdungByFKSanphamID(sanpham.PK_iSanphamID) * 100);
                 ltrKhuyenmaiDangApdung.Text = khuyenmaiDangapdung < 0 ? string.Empty : string.Format("{0}%", khuyenmaiDangapdung);
             }
             HyperLink hrefDieuChinhgia = e.Item.FindControl("hrefDieuChinhgia") as HyperLink;
             if (hrefDieuChinhgia != null)
             {
                 hrefDieuChinhgia.NavigateUrl = string.Format("~/DieuchinhGia.aspx?gsp={0}", sanpham.PK_iSanphamID);
             }
             HyperLink hrefDieuChinhKhuyenmai = e.Item.FindControl("hrefDieuChinhKhuyenmai") as HyperLink;
             if (hrefDieuChinhKhuyenmai != null)
             {
                 hrefDieuChinhKhuyenmai.NavigateUrl = string.Format("~/DieuchinhKhuyenmai.aspx?kmsp={0}", sanpham.PK_iSanphamID);
             }
             HyperLink hrefCongthuc = e.Item.FindControl("hrefCongthuc") as HyperLink;
             if (hrefCongthuc != null)
             {
                 hrefCongthuc.NavigateUrl = string.Format("~/Congthuc.aspx?ctsp={0}", sanpham.PK_iSanphamID);
             }
         } //sanpham
     }     //ItemType
 }
Esempio n. 6
0
        public ActionResult Addvendsearchpt(string ten, string loai, string hangsx, int?max, int?min, int?page, string typeview)
        {
            ViewBag.Theoten  = ten;
            ViewBag.Theoloai = loai;
            ViewBag.Theohang = hangsx;
            ViewBag.Giamax   = max;
            ViewBag.Giamin   = min;
            ViewBag.type     = typeview;
            SanphamModel       list = new SanphamModel();
            IQueryable <SPHAM> sp   = list.Searchaddvend(ten, loai, hangsx, max, min);

            return(Phantrang(sp, page));
        }
        public ActionResult Addsanpham([Bind(Include = "TENSP,LOAISP,HANGSX,GIA,MOTA,SOLUONG,ISNEW")] SPHAM sanpham, HttpPostedFileBase an)
        {
            SanphamModel spm = new SanphamModel();

            if (ModelState.IsValid)
            {
                string masp = spm.themsp(sanpham);
                UploadAnh(an, masp + "1");                //waring masp+1 not get picture up to list
            }
            ViewBag.HANGSX = new SelectList(spm.Gethangsanxuat(), "HANGSX", "TENHANG ");
            ViewBag.LOAISP = new SelectList(spm.Getloaisp(), "MALOAI", "TENLOAI");
            return(View("themsp", sanpham));
        }
Esempio n. 8
0
 public SanphamModel UpdateSP([FromBody] SanphamModel model)
 {
     if (model.HINH != null)
     {
         var arrData = model.HINH.Split(';');
         if (arrData.Length == 3)
         {
             var savePath = $@"{arrData[0]}";
             model.HINH = $"{savePath}";
             SaveFileFromBase64String(savePath, arrData[2]);
         }
     }
     _SanphamBusiness.Update(model);
     return(model);
 }
Esempio n. 9
0
 public bool Updatetinhtrangdh(string madh, int?tt)
 {
     if (tt == null)
     {
         return(false);
     }
     try {
         Shopbanhang db = new Shopbanhang();
         DONHANG     dh = db.DONHANGs.Find(madh);
         if (dh.TINHTRANGDH == 4 || dh.TINHTRANGDH == 3)
         {
             return(false);
         }
         if (dh.TINHTRANGDH == 1)
         {
             if (tt == 2 || tt == 3)
             {
                 foreach (var item in db.CTDONHANGs)
                 {
                     SanphamModel sp = new SanphamModel();
                     sp.UpdateSoluong(item.MASP, item.SOLUONG, false);
                 }
             }
         }
         if (dh.TINHTRANGDH == 2)
         {
             if (tt == 4)
             {
                 foreach (var item in db.CTDONHANGs)
                 {
                     SanphamModel sp = new SanphamModel();
                     sp.UpdateSoluong(item.MASP, item.SOLUONG, false);
                 }
             }
             if (tt == 1)
             {
                 return(false);
             }
         }
         string query = "update DONHANG set TINHTRANGDH = " + tt + " where MADONHANG ='" + madh + "'";
         db.Database.ExecuteSqlCommand(query);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 10
0
        public ActionResult Sanphammoinhat(int?skip)
        {
            SanphamModel       sp      = new SanphamModel();
            int                skipnum = (skip ?? 0);
            IQueryable <SPHAM> splist  = sp.SPMoiNhap();

            splist = splist.OrderBy(r => r.MASP).Skip(skipnum).Take(8);
            if (splist.Any())
            {
                return(PartialView("_ProductTabLoadMorePartial", splist));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
        public JsonResult sanpham()
        {
            SanphamModel sanpham = new SanphamModel();
            var          model   = sanpham.Getsp();

            return(this.Json(
                       new
            {
                data = (from obj in db.SPHAMs select new { MASP = obj.MASP, TENSP = obj.TENSP,
                                                           LOAISP = obj.LOAISP,
                                                           HANGSX = obj.HANGSX,
                                                           GIA = obj.GIA,
                                                           SOLUONG = obj.SOLUONG,
                                                           MOTA = obj.MOTA,
                                                           ANHDAIDIEN = obj.ANHDAIDIEN })
            }
                       , JsonRequestBehavior.AllowGet
                       ));
        }
Esempio n. 12
0
 public bool Update(SanphamModel model)
 {
     return(_res.Update(model));
 }
Esempio n. 13
0
 public bool Create(SanphamModel model)
 {
     return(_res.Create(model));
 }
 public SanphamModel Update([FromBody] SanphamModel model)
 {
     _itemBusiness.Update(model);
     return(model);
 }
 public SanphamModel CreateItem([FromBody] SanphamModel model)
 {
     _itemBusiness.Create(model);
     return(model);
 }