public bool delete(Good good) { using (GoodsDBEntities entity = new GoodsDBEntities()) { try { int id = Convert.ToInt32(good.id); GoodEntity g = entity.Good.Single(p => p.good_id == id); entity.Good.Remove(g); entity.SaveChanges(); return true; } catch { return false; } }; }
public bool edit(Good good) { using (GoodsDBEntities entity = new GoodsDBEntities()) { try { int id = Convert.ToInt32(good.id); GoodEntity g = entity.Good.Single(p => p.good_id == id); g.good_name = good.name; g.good_price = good.price; g.good_quantity = good.quantity; entity.SaveChanges(); return true; } catch { return false; } }; }
public bool create(Good good) { using (GoodsDBEntities entity = new GoodsDBEntities()) { try { GoodEntity g = new GoodEntity(); g.good_id = good.id; g.good_name = good.name; g.good_price = good.price; g.good_quantity = good.quantity; //entity.Good.Add(g); entity.Good.Add(g); entity.SaveChanges(); return true; } catch { return false; } }; }