public void updateDisbursement(int departmentID, int disbursementID, int itemID, int updateQty) { var qry1 = context.Disbursement_Item.Where(x => x.DisbursementID == disbursementID && x.ItemID == itemID && x.Status.Equals("Pending")).ToList().FirstOrDefault(); qry1.Qty = updateQty; var req = context.Requisitions.Where(x => x.DepartmentID == departmentID && x.Status.Equals("Approved")).ToList(); foreach (var r in req) { var qry2 = context.Requisition_Item.Where(x => x.RequisitionID == r.RequisitionID && x.Status.Equals("Pending") && x.ItemID == itemID).ToList().FirstOrDefault(); if (qry2 != null) { if (updateQty == qry2.UnfulfilledQty) { qry2.UnfulfilledQty = 0; qry2.ReceivedQty = qry2.ReceivedQty + updateQty; qry2.Status = "Completed"; } else if (updateQty < qry2.UnfulfilledQty) { qry2.UnfulfilledQty = qry2.RequestedQty - updateQty; qry2.ReceivedQty = qry2.ReceivedQty + updateQty; qry2.Status = "Unfulfilled"; } } } context.SaveChanges(); }
//Update the stock table public void updateInstockTable(int itemID, string itemNumber, int stock) { var qry = context.Items.Where(x => x.ItemID == itemID && x.ItemNumber == itemNumber).FirstOrDefault(); Item i = (Item)qry; i.InStockQty = qry.InStockQty + stock; context.SaveChanges(); }
//2.. Approve Requisition public void approveRequisition(int reqID) { //Get the requisition object by req ID var qry = context.Requisitions.Where(r => r.RequisitionID == reqID).ToList().FirstOrDefault(); if (qry != null) { qry.Status = "Approved"; } context.SaveChanges(); }
//Assign Supervisor public void assignSupervisor(int employeeID, DateTime startDate, DateTime endDate) { var qry = context.Users.Where(u => u.EmployeeID == employeeID).ToList().FirstOrDefault(); if (qry != null) { if (qry.DelegatedRole.Equals("")) { qry.DelegatedRole = "Store Supervisor"; qry.StartDate = startDate; qry.EndDate = endDate; } } context.SaveChanges(); }
public int updateRetrievalBOsStatus(List <RetrievalBO> retrievalBOs, string statusPar) { string status = null; if (statusPar == "Unfullfill Orders") { status = "Unfulfilled"; } else if (statusPar == "New Orders") { status = "New"; } int changes; context = new ADTeam1Entities(); List <Requisition_Item> requisition_Items = context.Requisition_Item.Where(x => x.Status == status).ToList(); foreach (Requisition_Item r_Item in requisition_Items) { foreach (RetrievalBO retrievalBO in retrievalBOs) { if (r_Item.Item.ItemNumber == retrievalBO.ItemNumber) { r_Item.Item.InStockQty = r_Item.Item.InStockQty - (int)context.Requisition_Item.Where(x => x.Status == status && x.Requisition.Status == "Approved" && x.ItemID == r_Item.ItemID).Sum(x => x.ToRetrieveQty); r_Item.Status = retrievalBO.Status; r_Item.UnfulfilledQty = r_Item.UnfulfilledQty - r_Item.ToRetrieveQty; // r_Item.UnfulfilledQty = r_Item.RequestedQty - r_Item.ToRetrieveQty; r_Item.RetrievedQty = r_Item.ToRetrieveQty; r_Item.ToRetrieveQty = 0; } } } changes = context.SaveChanges(); return(changes); }
//For Change Representative Page //3.. Assign Department Rep public void assignDeptRep(int employeeID) { var qry = context.Users.Where(u => u.EmployeeID == employeeID).ToList().FirstOrDefault(); if (qry != null) { //qry.DelegatedRole = "Employee Rep"; if (qry.DelegatedRole.Equals("Employee Head")) { qry.DelegatedRole = "Employee RepHead"; } else { qry.DelegatedRole = "Employee Rep"; } } context.SaveChanges(); }
//Add purchase order into the table public void purchaseOrderList(Purchase purchase, List <Purchase_Item> purItem) { foreach (Purchase_Item p in purItem) { purchase.Purchase_Item.Add(p); } context.Purchases.Add(purchase); context.SaveChanges(); }
//Save all inventory adjustments lists to Inventory Adjustment Table public void saveInventoryItemList(Adjustment adjustment, List <Adjustment_Item> adjItem) { foreach (Adjustment_Item i in adjItem) { adjustment.Adjustment_Item.Add(i); } context.Adjustments.Add(adjustment); context.SaveChanges(); }
//Add to database public void addRequisitionList(Requisition requisition, List <Requisition_Item> rItem) { //Add many to many table data using entity framework foreach (Requisition_Item r in rItem) { requisition.Requisition_Item.Add(r); } context.Requisitions.Add(requisition); context.SaveChanges(); }
//Change Approved or Rejected of adjustment table public int ApprovedOrRejected(int num, int adjNum) { //num==1 mean approved var q = context.Adjustments.Where(x => x.AdjustmentID == adjNum).FirstOrDefault(); int flag = 0; Adjustment a = (Adjustment)q; if (num == 1) { a.Status = "Approved"; flag = context.SaveChanges(); } else if (num == 0) //mean Rejected { a.Status = "Rejected"; flag = context.SaveChanges(); } return(flag); }
//updatecollectionPoint public void update(int collectionPointID, int departmentID) { var qry = context.Departments.Where(x => x.DepartmentID == departmentID).FirstOrDefault(); Department c = (Department)qry; if (c.CollectionPointID != collectionPointID) { c.CollectionPointID = collectionPointID; } context.SaveChanges(); }
public int updateRetrievalBOs(List <RetrievalBO> retrievalBOs) { int changes; context = new ADTeam1Entities(); List <Requisition_Item> requisition_Items = context.Requisition_Item.ToList(); foreach (Requisition_Item r_Item in requisition_Items) { foreach (RetrievalBO retrievalBO in retrievalBOs) { if (r_Item.Requisition_ItemID == retrievalBO.RequisitionItemID) { r_Item.ToRetrieveQty = retrievalBO.ToRetrieve; } } } changes = context.SaveChanges(); return(changes); }
public int addDisbursementItem(List <RetrievalBO> retrievalBOs, string statusPar) { string status = null; if (statusPar == "Unfullfill Orders") { status = "Unfulfilled"; } else if (statusPar == "New Orders") { status = "New"; } int changes; context = new ADTeam1Entities(); List <Requisition_Item> requisition_Items = context.Requisition_Item.Where(x => x.Status == status).ToList(); List <Disbursement_Item> disbursement_Items = context.Disbursement_Item.ToList(); foreach (Requisition_Item r_Item in requisition_Items) { foreach (RetrievalBO retrievalBO in retrievalBOs) { if (r_Item.Item.ItemNumber == retrievalBO.ItemNumber) { Disbursement_Item d_Item = new Disbursement_Item(); d_Item.Disbursement = r_Item.Requisition.Department.Disbursements.FirstOrDefault(); d_Item.Item = r_Item.Item; d_Item.Qty = r_Item.ToRetrieveQty; d_Item.Status = "Pending"; context.Disbursement_Item.Add(d_Item); } } } changes = context.SaveChanges(); return(changes); }
//Add item to Items table public void addItem(Item i) { context.Items.Add(i); context.SaveChanges(); }