private void detach_ESHOP_BASKETs(ESHOP_BASKET entity) { this.SendPropertyChanging(); entity.ESHOP_NEW = null; }
partial void DeleteESHOP_BASKET(ESHOP_BASKET instance);
partial void InsertESHOP_BASKET(ESHOP_BASKET instance);
partial void UpdateESHOP_BASKET(ESHOP_BASKET instance);
public bool Add_To_Cart(int News_id, object Guid, int quantity) { decimal _dPrice = 0; var _news = from a in db.ESHOP_NEWs where a.NEWS_ID == News_id select a; if (_news.ToList().Count > 0) { if (Utils.CIntDef(_news.ToList()[0].NEWS_FIELD3) == 0) return false; if (Utils.CDecDef(_news.ToList()[0].NEWS_PRICE1) == 0) { _dPrice = 0; } else { if (Utils.CDecDef(_news.ToList()[0].NEWS_PRICE2) != 0) { _dPrice = Utils.CDecDef(_news.ToList()[0].NEWS_PRICE2); } else { _dPrice = Utils.CDecDef(_news.ToList()[0].NEWS_PRICE1); } } } int _cus_id = 0; //string _sCode = News_id + "_" + clsFormat.ClearUnicode(Color) + "_" + Size; if (_dPrice != 0) { if (Check_Exist_Item(News_id, (Guid)Guid)) { //Nếu đã có sản phẩm trong giỏ hàng thì thêm 1 //ESHOP_BASKET _bas = db.ESHOP_BASKETs.Single(a => a.NEWS_ID == News_id); Guid _guid = (Guid)Guid; var _vBasket = db.GetTable<ESHOP_BASKET>().Where(a => a.NEWS_ID == News_id && a.CUSTOMER_OID == _guid); if (_vBasket.ToList().Count > 0) { _vBasket.ToList()[0].BASKET_QUANTITY += 1; db.SubmitChanges(); } } else { //Nếu chưa có sản phẩm trong giỏ hàng thì thêm sản phẩm mới vào đó ESHOP_BASKET _basket = new ESHOP_BASKET(); _basket.BASKET_PRICE = _dPrice; _basket.CUSTOMER_OID = (Guid)Guid; _basket.BASKET_PUBLISHDATE = DateTime.Now; _basket.BASKET_QUANTITY = Utils.CIntDef(quantity) != 0 ? quantity : 1; _basket.CUSTOMER_ID = _cus_id; _basket.NEWS_ID = News_id; db.ESHOP_BASKETs.InsertOnSubmit(_basket); db.SubmitChanges(); } return true; } return false; }