Esempio n. 1
0
 public List<Good> findAll()
 {
     using(GoodsDBEntities entity = new GoodsDBEntities()){
         return entity.Good.Select(e => new Good
         {
             id = e.good_id,
             name = e.good_name,
             price = e.good_price.Value,
             quantity = e.good_quantity.Value
         }).ToList();
     };
 }
Esempio n. 2
0
 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;
         }
     };
 }
Esempio n. 3
0
 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;
         }
     };
 }
Esempio n. 4
0
 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;
         }
     };
 }
Esempio n. 5
0
 public Good findById(string id)
 {
     using (GoodsDBEntities entity = new GoodsDBEntities())
     {
         int nid = Convert.ToInt32(id);
         return entity.Good.Where(e => e.good_id == nid).Select(e => new Good
         {
             id = e.good_id,
             name = e.good_name,
             price = e.good_price.Value,
             quantity = e.good_quantity.Value
         }).First();
     };
 }