/// <summary> /// Create a new DisbursementDetail object. /// </summary> /// <param name="disbursement_DetailID">Initial value of the Disbursement_DetailID property.</param> /// <param name="disbursementID">Initial value of the DisbursementID property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="pending_Qty">Initial value of the Pending_Qty property.</param> /// <param name="outstanding_Type">Initial value of the Outstanding_Type property.</param> /// <param name="item_Code">Initial value of the Item_Code property.</param> /// <param name="alloted">Initial value of the Alloted property.</param> public static DisbursementDetail CreateDisbursementDetail(global::System.Int32 disbursement_DetailID, global::System.Int32 disbursementID, global::System.Int32 quantity, global::System.Int32 pending_Qty, global::System.String outstanding_Type, global::System.String item_Code, global::System.Int32 alloted) { DisbursementDetail disbursementDetail = new DisbursementDetail(); disbursementDetail.Disbursement_DetailID = disbursement_DetailID; disbursementDetail.DisbursementID = disbursementID; disbursementDetail.Quantity = quantity; disbursementDetail.Pending_Qty = pending_Qty; disbursementDetail.Outstanding_Type = outstanding_Type; disbursementDetail.Item_Code = item_Code; disbursementDetail.Alloted = alloted; return disbursementDetail; }
/// <summary> /// Deprecated Method for adding a new object to the DisbursementDetails EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDisbursementDetails(DisbursementDetail disbursementDetail) { base.AddObject("DisbursementDetails", disbursementDetail); }
public void Disburse() { bool flag = false; using (TransactionScope trans = new TransactionScope()) { int id; List<int> disb_id = new List<int>(); try { var x = (from m in cntxt.DeptRequisitions where m.Status_Check == "current" select m).AsEnumerable<DeptRequisition>(); foreach (var d in x) { disb_id.Add(d.Dept_ReqID); var p = (from m in cntxt.Departments where m.Department_Code == d.Department_Code select m).First<Department>(); Disbursement db = new Disbursement { Disburse_Date = DateTime.Now, Status = "current", Department_ReqID = d.Dept_ReqID, Department = p.Department_Name, Dispatch_Status = "pending" }; cntxt.Disbursements.AddObject(db); cntxt.SaveChanges(); id = db.DisbursementID; var s = from m in cntxt.DepartmentViews where m.Department_Code == p.Department_Code select m; foreach (var item in s) { DisbursementDetail dbd = new DisbursementDetail { DisbursementID = id, Quantity = Convert.ToInt32(item.Requested_Quantity), Item_Code = item.Item_Code, Outstanding_Type = "pending", Alloted = 0 }; cntxt.DisbursementDetails.AddObject(dbd); cntxt.SaveChanges(); } } trans.Complete(); flag = true; } catch (TransactionException e) { e.Message.ToString(); } } if (flag) { cntxt.AcceptAllChanges(); } else { cntxt.Dispose(); } }