コード例 #1
0
 internal vwProduct AddWarehouseItem(vwProduct item)
 {
     try
     {
         using (WarehouseDataBaseEntities context = new WarehouseDataBaseEntities())
         {
             tblProduct newProduct = new tblProduct();
             newProduct.ProductName   = item.ProductName;
             newProduct.ProductNumber = item.ProductNumber;
             newProduct.Amount        = item.Amount;
             newProduct.Price         = item.Price;
             newProduct.InStock       = item.InStock;
             context.tblProducts.Add(newProduct);
             context.SaveChanges();
             item.ID = newProduct.ID;
             return(item);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }