// // GET: /Supply/Details/5 public ViewResult Details(int id) { SupplyChain supplychain = db.SupplyChains.Find(id); return(View(supplychain)); }
private List <SupplyChain> SupplyChainBuilder(string itemCode, List <ItemFlow> ItemFlows, int bomLevel, List <SupplyChain> supplyChains) { var qItemFlow = ItemFlows.Where(i => Utilities.StringEq(i.Item, itemCode)).ToList(); List <string> locList = this.LocSort(qItemFlow); foreach (var loc in locList) { if (loc == null) { continue; } var q2 = qItemFlow.Where(i => Utilities.StringEq(i.LocFrom, loc)).ToList <ItemFlow>(); foreach (var itemFlow in q2) { SupplyChain supplyChain = new SupplyChain(); supplyChain.BomLevel = bomLevel; supplyChain.ItemFlow = itemFlow; supplyChain.Item = itemFlow.Item; supplyChain.Loc = itemFlow.LocFrom; supplyChains.Add(supplyChain); } } return(supplyChains); }
public void GeneratePlanning(IList <ItemFlowPlan> itemFlowPlans) { IList <ItemFlowPlan> itemFlowPlanList = new List <ItemFlowPlan>(); foreach (ItemFlowPlan itemFlowPlan in itemFlowPlans) { if (itemFlowPlan.PlanType != BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE) { continue; } SupplyChain supplyChain = SupplyChainMgr.GenerateSupplyChain(itemFlowPlan.Flow, itemFlowPlan.FlowDetail); if (supplyChain != null && supplyChain.SupplyChainDetails != null && supplyChain.SupplyChainDetails.Count > 0) { itemFlowPlan.ItemFlowPlanDetails = ItemFlowPlanDetailMgr.GetItemFlowPlanDetailView(itemFlowPlan, true); itemFlowPlanList.Add(itemFlowPlan); IList <SupplyChainDetail> supplyChainDetailList = supplyChain.SupplyChainDetails; this.RunPlanning(itemFlowPlanList, supplyChainDetailList, itemFlowPlan, supplyChainDetailList[0].Id); } } foreach (ItemFlowPlan saveItemFlowPlan in itemFlowPlanList) { if (saveItemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS || saveItemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP) { this.SaveItemFlowPlan(saveItemFlowPlan); } } }
public SupplyChain GenerateSupplyChain(Flow flow, FlowDetail flowDetail) { SupplyChain supplyChain = new SupplyChain(); supplyChain.Flow = flow; supplyChain.FlowDetail = flowDetail; SupplyChainDetail supplyChainDetail = new SupplyChainDetail(); supplyChainDetail.SupplyChain = supplyChain; supplyChainDetail.Id = 1; supplyChainDetail.ParentId = 0; supplyChainDetail.Flow = flow; supplyChainDetail.FlowDetail = flowDetail; supplyChainDetail.LocationTo = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo; supplyChainDetail.QuantityPer = 1; IList <SupplyChainDetail> supplyChainDetailList = new List <SupplyChainDetail>(); supplyChainDetailList.Add(supplyChainDetail); this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail); supplyChain.AddRangeSupplyChainDetail(supplyChainDetailList); return(supplyChain); }
public void ShowTreeView(object sender) { string flowCode = ((object[])sender)[0].ToString(); string itemCode = ((object[])sender)[1].ToString(); if (TheFlowMgr.LoadFlow(flowCode) == null) { ShowErrorMessage("Common.Business.Warn.FlowInvalid"); return; } if (TheItemMgr.LoadItem(itemCode) == null) { ShowErrorMessage("Common.Business.Warn.ItemInvalid"); return; } supplyChain = TheSupplyChainMgr.GenerateSupplyChain(flowCode, itemCode)[0]; supplyChainDetailList = supplyChain.SupplyChainDetails; if (supplyChainDetailList != null && supplyChainDetailList.Count > 0) { MyOrgNode RootNode = new MyOrgNode(); GenChildOrgNode(RootNode); OrgChartTreeView.Node = RootNode; } }
/// <summary> /// Build supply chain by finished good itemcode /// </summary> /// <param name="itemCode"></param> /// <param name="ItemFlows"></param> /// <returns></returns> public List <SupplyChain> BuildSupplyChain(string itemCode, List <ItemFlow> ItemFlows) { if (itemCode == null || ItemFlows == null || ItemFlows.Count == 0) { return(null); } List <SupplyChain> supplyChains = new List <SupplyChain>(); int bomLevel = 0; var query = ItemFlows.Where(i => Utilities.StringEq(i.Item, itemCode)).ToList(); List <string> locList = this.LocSort(query); foreach (var loc in locList) { var q2 = query.Where(i => Utilities.StringEq(i.LocTo, loc)).ToList(); foreach (var itemFlow in q2) { SupplyChain supplyChain = new SupplyChain(); supplyChain.BomLevel = bomLevel; supplyChain.ItemFlow = itemFlow; supplyChain.Item = itemFlow.Item; supplyChain.Loc = itemFlow.LocFrom; supplyChains.Add(supplyChain); } } return(supplyChains); }
public ActionResult DeleteConfirmed(int id) { SupplyChain supplychain = db.SupplyChains.Find(id); db.SupplyChains.Remove(supplychain); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResult GetItems(int?id) { db.Configuration.ProxyCreationEnabled = false; SupplyChain spitem = db.SupplyChains.Find(id); return(new JsonResult { Data = spitem, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
// // GET: /Supply/Edit/5 public ActionResult Edit(int id) { SupplyChain supplychain = db.SupplyChains.Find(id); ViewBag.WID = new SelectList(db.ActiveWines, "WID", "WineTitle", supplychain.WID); ViewBag.GroupID = new SelectList(db.Groups, "GroupID", "GroupName", supplychain.GroupID); ViewBag.TrustStatusID = new SelectList(db.TrustStatus, "TrustStatusID", "TrustStatusName", supplychain.TrustStatusID); return(View(supplychain)); }
public JsonResult DeleteSPchain(int?Id) { SupplyChain sp = db.SupplyChains.Find(Id); db.SupplyChains.Remove(sp); db.SaveChanges(); return(new JsonResult { Data = "Deleted", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private static void AddTransactionToSupplyChain(SupplyChain chain, Transaction transaction) { if (chain.Transaction.ToOwner == transaction.FromOwner) { var childChain = new SupplyChain(transaction); chain.AddChild(childChain); } else { foreach (var childChain in chain.Children) { AddTransactionToSupplyChain(childChain, transaction); } } }
public ActionResult Create(SupplyChain supplychain) { supplychain.contactPic = "~/Content/5.jpg"; if (ModelState.IsValid) { db.SupplyChains.Add(supplychain); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.WID = new SelectList(db.ActiveWines, "WID", "WineTitle", supplychain.WID); ViewBag.GroupID = new SelectList(db.Groups, "GroupID", "GroupName", supplychain.GroupID); ViewBag.TrustStatusID = new SelectList(db.TrustStatus, "TrustStatusID", "TrustStatusName", supplychain.TrustStatusID); return(View(supplychain)); }
public JsonResult EditSPchain(SupplyChain sp) { var s = db.SupplyChains.Where(k => k.Id == sp.Id).FirstOrDefault(); if (s != null) { s.Name = sp.Name; db.SaveChanges(); return(new JsonResult { Data = "Updated", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(new JsonResult { Data = "Failed", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public static SupplyChain Make(List <Transaction> transactions) { transactions = transactions.OrderBy(t => t.OrderTime).ToList(); SupplyChain supplyChain = null; foreach (var transaction in transactions) { if (supplyChain == null) { supplyChain = new SupplyChain(transaction); } else { AddTransactionToSupplyChain(supplyChain, transaction); } } return(supplyChain); }
public ActionResult AddSPchain(SupplyChain sp) { //sp = db.SupplyChains.Where(t => t.Id == Id).FirstOrDefault(); db.SupplyChains.Add(sp); try { db.SaveChanges(); } catch (Exception error) { return(new JsonResult { Data = error, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } string message = "SUCCESS"; return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Edit(SupplyChain supplychain) { if (ModelState.IsValid) { db.Entry(supplychain).State = EntityState.Modified; db.Entry(supplychain).Property(x => x.contactPic).IsModified = false; try { db.SaveChanges(); } catch (Exception e) { var ee = e; } return(RedirectToAction("Index")); } ViewBag.WID = new SelectList(db.ActiveWines, "WID", "WineTitle", supplychain.WID); ViewBag.GroupID = new SelectList(db.Groups, "GroupID", "GroupName", supplychain.GroupID); ViewBag.TrustStatusID = new SelectList(db.TrustStatus, "TrustStatusID", "TrustStatusName", supplychain.TrustStatusID); return(View(supplychain)); }
// // GET: /Supply/Delete/5 public ActionResult Delete(int id) { SupplyChain supplychain = db.SupplyChains.Find(id); return(View(supplychain)); }