public string getStockCardID(string itemCode)
 {
     StockCardEnt stCardEnt = new StockCardEnt();
     StockCard stCard=new StockCard();
     stCard.Item_Code=itemCode;
     string stCardId = stCardEnt.getStockCard(stCard).First().StockCard_ID;
     return stCardId;
 }
        public List<StockCard> getStockCard(StockCard sc)
        {
            var q = from s in ContextDB.StockCards
                    where (s.StockCard_ID == sc.StockCard_ID || sc.StockCard_ID == null)
                    && (s.Item_Code == sc.Item_Code || sc.Item_Code == null)
                    && (s.first_Supplier == sc.first_Supplier || sc.first_Supplier == null)
                    && (s.second_Supplier == sc.second_Supplier || sc.second_Supplier == null)
                    && (s.third_Supplier == sc.third_Supplier || sc.third_Supplier == null)
                    select s;

            return q.ToList<StockCard>();
        }
        public bool deleteStockCard(StockCard sc)
        {
            try
            {
                ContextDB.StockCards.DeleteObject(sc);
                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
        public bool updateStockCard(StockCard sc)
        {
            try
            {
                StockCard s =  (StockCard)getStockCard(sc).First();
                s.Item_Code = sc.Item_Code == null ? s.Item_Code : sc.Item_Code;
                s.first_Supplier = sc.first_Supplier == null ? s.first_Supplier : sc.first_Supplier;
                s.second_Supplier = sc.second_Supplier == null ? s.second_Supplier : sc.second_Supplier;
                s.third_Supplier = sc.third_Supplier == null ? s.third_Supplier : sc.third_Supplier;

                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
 //update stock card by item code
 public int updateStock(StockCard scm)
 {
     var rmRow = entity.StockCards.Where(x => x.Item_Code == scm.Item_Code).SingleOrDefault();
     rmRow = scm;
     int i = entity.SaveChanges();
     return i;
 }
 public void createStockCard(StockCard sc)
 {
     ContextDB.StockCards.AddObject(sc);
     ContextDB.SaveChanges();
     dalUtl.Increament_GenID(3);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the StockCards EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStockCards(StockCard stockCard)
 {
     base.AddObject("StockCards", stockCard);
 }
 /// <summary>
 /// Create a new StockCard object.
 /// </summary>
 /// <param name="stockCard_ID">Initial value of the StockCard_ID property.</param>
 public static StockCard CreateStockCard(global::System.String stockCard_ID)
 {
     StockCard stockCard = new StockCard();
     stockCard.StockCard_ID = stockCard_ID;
     return stockCard;
 }