public bool Insert(IEnumerable <Stock_TranferArInvoice> Items, Stock_DocumentRunning ItemRun)
        {
            try
            {
                var option = new TransactionOptions();
                option.IsolationLevel = IsolationLevel.ReadCommitted;
                //option.Timeout = TimeSpan.FromSeconds(5);
                using (var tx = new TransactionScope(TransactionScopeOption.Required, option))
                {
                    ItemRun.IncreaseNextNumber();

                    foreach (Stock_TranferArInvoice Item in Items)
                    {
                        Db.Insert(Item);
                        Db.SaveChanges();
                    }
                    Db_Run.Update(ItemRun);
                    Db_Run.SaveChanges();
                    tx.Complete();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(false);
            }
        }
Example #2
0
        public Stock_DocumentFormat Insert(Stock_DocumentFormat Item, Stock_DocumentRunning itemR)
        {
            var option = new TransactionOptions();

            option.IsolationLevel = IsolationLevel.ReadCommitted;
            //option.Timeout = TimeSpan.FromSeconds(5);
            using (var tx = new TransactionScope(TransactionScopeOption.Required, option))
            {
                Db.Insert(Item);
                Db.SaveChanges();

                itemR.Format_Id = Item.Format_Id;
                itemR.Menu_ID   = Item.Menu_ID;
                Db_Run.Insert(itemR);
                Db_Run.SaveChanges();
                tx.Complete();
                return(Item);
            }
        }
 public Stock_DocumentRunning Update(Stock_DocumentRunning Item)
 {
     Db.Update(Item);
     Db.SaveChanges();
     return(Item);
 }