public Stock_Item GetItembyItemCode(string ic)
        {
            var q = (from r in edm.Stock_Item where r.Item_Code == ic select r);
            Stock_Item s = new Stock_Item();
            s = q.First<Stock_Item>();

            return s;
        }
        public Stock_Item GetItembyDesc(string desc)
        {
            var q = (from r in edm.Stock_Item where r.Description == desc select r);
            Stock_Item s = new Stock_Item();
            s = q.First<Stock_Item>();

            return s;
        }
        public string AddNewStockItem(string item_code, int categoryId, string desc, int reorder_level, int reorder_qty, string unit, int qty)
        {
            Stock_Item item = new Stock_Item();
            item.Item_Code = item_code;
            item.CategoryID = categoryId;
            item.Description = desc;
            item.Reorder_Level = reorder_level;
            item.Reorder_Qty = reorder_qty;
            item.Unit_of_Measure = unit;
            item.Quantity = qty;
            //item.Quantity = qty;

            edm.AddToStock_Item(item);
            edm.SaveChanges();

            return "Adding new Item is successful.";
        }
 private void FillStockItemList()
 {
     StockItemBLL stockItembll = new StockItemBLL();
     Stock_Item stockitem = new Stock_Item();
     var itemList = stockItembll.GetStockItem();
     ddlItemName.DataSource = itemList;
     ddlItemName.DataTextField = "Description";
     ddlItemName.DataValueField = "Item_Code";
     ddlItemName.DataBind();
 }
 public string GetItemCode(Stock_Item i)
 {
     var q = (from r in edm.Stock_Item where r.Description == i.Description select r.Item_Code);
     string ans = q.ToString();
     return ans;
 }
 /// <summary>
 /// Create a new Stock_Item object.
 /// </summary>
 /// <param name="item_Code">Initial value of the Item_Code property.</param>
 /// <param name="categoryID">Initial value of the CategoryID property.</param>
 /// <param name="reorder_Level">Initial value of the Reorder_Level property.</param>
 /// <param name="reorder_Qty">Initial value of the Reorder_Qty property.</param>
 /// <param name="unit_of_Measure">Initial value of the Unit_of_Measure property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 public static Stock_Item CreateStock_Item(global::System.String item_Code, global::System.Int32 categoryID, global::System.Int32 reorder_Level, global::System.Int32 reorder_Qty, global::System.String unit_of_Measure, global::System.Int32 quantity)
 {
     Stock_Item stock_Item = new Stock_Item();
     stock_Item.Item_Code = item_Code;
     stock_Item.CategoryID = categoryID;
     stock_Item.Reorder_Level = reorder_Level;
     stock_Item.Reorder_Qty = reorder_Qty;
     stock_Item.Unit_of_Measure = unit_of_Measure;
     stock_Item.Quantity = quantity;
     return stock_Item;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Stock_Item EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStock_Item(Stock_Item stock_Item)
 {
     base.AddObject("Stock_Item", stock_Item);
 }
 public void UpdateStock(string code, int quant)
 {
     Stock_Item st = new Stock_Item();
     var stock = (from m in cntxt.Stock_Item
                  where m.Item_Code == code
                  select m).First<Stock_Item>();
     stock.Quantity = stock.Quantity - quant;
     StockHistory sh = new StockHistory()
     {
         Item_Code = stock.Item_Code,
         Description = stock.Description,
         Quantity = -quant,
         UpdateDate = DateTime.Now,
         UpdateBy = 1000   //session
     };
     cntxt.StockHistories.AddObject(sh);
     cntxt.SaveChanges();
 }