public int NhapKho(KhoHang kh) { try { KhoHang k = db.KhoHangs.SingleOrDefault(n => n.idsanpham == kh.idsanpham && n.size == kh.size); if(k!= null) { k.soluong = k.soluong + kh.soluong; db.SubmitChanges(); } else { db.KhoHangs.InsertOnSubmit(kh); db.SubmitChanges(); } } catch { return -1; } return 1; }
public int UpdateKhoHang(KhoHang kh) { try { KhoHang k = db.KhoHangs.SingleOrDefault(n => n.idsanpham == kh.idsanpham && n.size == kh.size); k.soluong = k.soluong - kh.soluong; db.SubmitChanges(); } catch { return -1; } return 1; }
partial void DeleteKhoHang(KhoHang instance);
partial void UpdateKhoHang(KhoHang instance);
partial void InsertKhoHang(KhoHang instance);
private void detach_KhoHangs(KhoHang entity) { this.SendPropertyChanging(); entity.Product = null; }
private void attach_KhoHangs(KhoHang entity) { this.SendPropertyChanging(); entity.Product = this; }