/// <summary>
 /// Create a new Pending object.
 /// </summary>
 /// <param name="pendingID">Initial value of the PendingID property.</param>
 /// <param name="disbursementID">Initial value of the DisbursementID property.</param>
 /// <param name="dept_Code">Initial value of the Dept_Code property.</param>
 public static Pending CreatePending(global::System.Int32 pendingID, global::System.Int32 disbursementID, global::System.String dept_Code)
 {
     Pending pending = new Pending();
     pending.PendingID = pendingID;
     pending.DisbursementID = disbursementID;
     pending.Dept_Code = dept_Code;
     return pending;
 }
        public void pendingQuantityDisburse()
        {
            bool success = false;

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {

                    var data = (from m in team.Disbursements
                                  where m.Dispatch_Status == "pending"
                                  select m).ToList<Disbursement>();

                    foreach (var z in data)
                    {
                        Pending pd = new Pending()
                        {
                            DisbursementID = z.DisbursementID,
                            Dept_Code = z.Department,
                            Status = "UnFullFilled",
                            Date = DateTime.Now,
                            Pending_Status = "current"
                        };

                        team.Pendings.AddObject(pd);
                        team.SaveChanges();

                        int pendingId = pd.PendingID;
                        int disburseID = pd.DisbursementID;
                        string deptcode = pd.Dept_Code;

                        //var y = (from o in team.Pending_Items
                        //         where o.Department == deptcode
                        //        select o).AsEnumerable<Pending_Items>();

                        var y = (from o in team.DisbursementDetails
                                 where o.DisbursementID == disburseID
                                 &&
                                 o.Outstanding_Type == "pending"
                                 select o).ToList<DisbursementDetail>();

                        foreach (var bike in y)
                        {
                            Pending_Detail pending = new Pending_Detail()
                            {
                                PendingID = pendingId,
                                Item_Code = bike.Item_Code,
                                Quantity = bike.Pending_Qty,
                                Status = "UnFullFilled"

                            };

                            team.Pending_Detail.AddObject(pending);

                            team.SaveChanges();

                        }

                    }

                    team.SaveChanges();
                    transaction.Complete();
                    success = true;
                }
                catch (TransactionAbortedException e)
                {
                    e.Message.ToString();
                }

            }
            if (success)
            {
                team.AcceptAllChanges();
            }
            else
            {
                team.Dispose();
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Pendings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPendings(Pending pending)
 {
     base.AddObject("Pendings", pending);
 }