public ActionResult InBoundEdit(FormCollection collection) { var model = new StoreTable(); //this.TryUpdateModel<StoreTable>(model); InBoundRecord ibr = new InBoundRecord(); if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { Guid proid = new Guid(collection["clID"]); int temp = 0; if (!int.TryParse(collection["InBoundCount"], out temp)) { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); return(PartialView()); } model.number = int.Parse(collection["InBoundCount"]); DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); model.store_item_id = dp.dpid; //插入数据到入库记录表 ibr.inbound_id = dp.dpid; ibr.rkid = Guid.NewGuid(); ibr.number = model.number; ibr.boundtype = "入库"; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); ///入库 this.StoreService.InsertStoreItem(model); } return(this.RefreshParent()); }
public ActionResult StoreEdit(string id, FormCollection collection) { StoreTable st = this.StoreService.GetStoreItem(new Guid(id)); st.number = decimal.Parse(collection["number"]); InBoundRecord ibr = new InBoundRecord(); //插入数据到入库记录表 ibr.inbound_id = st.store_item_id; ibr.rkid = Guid.NewGuid(); ibr.number = st.number; ibr.boundtype = "库存修改"; ibr.khmc = this.StoreService.GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); this.StoreService.OutBoundItem(st); return(this.RefreshParent()); }
public ActionResult Create(FormCollection collection) { if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { StoreTableRequest request = new StoreTableRequest(); request.PageSize = 1000; request.Gid = new Guid(collection["DictionaryProperty.dpid"]); int OutProductNumber; if (!int.TryParse(collection["OutBoundCount"], out OutProductNumber)) { var model = new StoreTable(); return(View("OutBoundEdit", model)); } //OutProductNumber = int.Parse(collection["OutBoundCount"]); //出库订单件数 var result = this.StoreService.GetStoreList(request); Guid tempid = new Guid(); foreach (StoreTable st in result) { if (st.DictionaryProperty.leaf_id == request.Gid) { st.number = st.number - (st.DictionaryProperty.js.Value * Convert.ToDecimal(OutProductNumber)); InBoundRecord ibr = new InBoundRecord(); //插入数据到入库记录表 ibr.inbound_id = st.store_item_id; ibr.rkid = Guid.NewGuid(); ibr.number = st.number; ibr.boundtype = "出库材料"; ibr.khmc = this.StoreService.GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); tempid = st.DictionaryProperty.leaf_id.Value; //出库 this.StoreService.OutBoundItem(st); } } //插入到出库记录表 OutBoundRecord obr = new OutBoundRecord(); obr.ckid = Guid.NewGuid(); obr.node_id = tempid; obr.number = OutProductNumber; this.StoreService.InsertOutBoundRecord(obr); } return(this.RefreshParent()); }
/// <summary> /// 插入库存操作记录 /// </summary> /// <param name="ibr"></param> public void InsertInboundRecord(InBoundRecord ibr) { using (var dbContext = new StoreDbContext()) { StoreTable st = dbContext.StoreTable.Include("DictionaryProperty.DictionaryTree").Where(u => u.store_item_id == ibr.inbound_id).FirstOrDefault(); if (st == null) { ibr.before_number = 0; } else { ibr.before_number = st.number; ibr.khmc = GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value); } dbContext.Insert <InBoundRecord>(ibr); } }
public ActionResult ReturnOrder(FormCollection collection) { if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { StoreTableRequest request = new StoreTableRequest(); request.PageSize = 1000; request.Gid = new Guid(collection["DictionaryProperty.dpid"]); int OutProductNumber = int.Parse(collection["OutBoundCount"]); //出库订单件数 var result = this.StoreService.GetStoreList(request); //获取订单下所有材料 StoreTreeNameRequests stnRequest = new StoreTreeNameRequests(); stnRequest.PageSize = 1000; stnRequest.treeID = request.Gid; var clResultList = this.StoreService.GetNodeProperty(stnRequest); //循环材料列表,如果在StoreTable中存在更新其数量,如果不在插入数据 foreach (DictionaryProperty dp in clResultList) { StoreTable st = new StoreTable(); st.number = 0; st.number = st.number + (dp.js.Value * Convert.ToDecimal(OutProductNumber)); st.store_item_id = dp.dpid; InBoundRecord ibr = new InBoundRecord(); //插入数据到入库记录表 ibr.inbound_id = st.store_item_id; ibr.rkid = Guid.NewGuid(); ibr.number = dp.js.Value * Convert.ToDecimal(OutProductNumber); ibr.boundtype = "还库材料"; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); this.StoreService.InsertStoreItem(st); } } return(this.RefreshParent()); }
public ActionResult InBoundEdit(FormCollection collection) { var model = new StoreTable(); var inBoundCounts = collection["InBoundCounts"]; //this.TryUpdateModel<StoreTable>(model); InBoundRecord ibr = new InBoundRecord(); if (bool.Parse(collection["pllr"].Split(',')[0])) { //批量添加材料 //var tempdpids = TempData["dpids"]; string dpids = collection["cllb"]; string[] arrTemp = dpids.Split(','); string[] arrCountTemp = inBoundCounts.Split(','); for (int i = 1; i < arrTemp.Length; i++) { decimal temp = 0; if (!decimal.TryParse(arrCountTemp[i - 1], out temp)) { temp = 0; } var modelTemp = new StoreTable(); InBoundRecord ibrTemp = new InBoundRecord(); Guid proid = new Guid(arrTemp[i]); modelTemp.number = temp; DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); modelTemp.store_item_id = dp.dpid; //插入数据到入库记录表 ibrTemp.inbound_id = dp.dpid; ibrTemp.rkid = Guid.NewGuid(); ibrTemp.number = modelTemp.number; ibrTemp.boundtype = "入库"; ibrTemp.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibrTemp); ///入库 this.StoreService.InsertStoreItem(modelTemp); } return(this.RefreshParent()); } if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { Guid proid = new Guid(collection["clID"]); decimal temp = 0; if (!decimal.TryParse(collection["InBoundCount"], out temp)) { temp = 0; } model.number = temp; DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); model.store_item_id = dp.dpid; //插入数据到入库记录表 ibr.inbound_id = dp.dpid; ibr.rkid = Guid.NewGuid(); ibr.number = model.number; ibr.boundtype = "入库"; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); ///入库 this.StoreService.InsertStoreItem(model); } return(this.RefreshParent()); }
public ActionResult Create(FormCollection collection) { if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { StoreTableRequest request = new StoreTableRequest(); request.PageSize = 10000; request.Gid = new Guid(collection["DictionaryProperty.dpid"]); int OutProductNumber; if (!int.TryParse(collection["OutBoundCount"], out OutProductNumber)) { var model = new StoreTable(); return(View("OutBoundEdit", model)); } var lydw = collection["employment"]; /// var result = this.StoreService.GetStoreList(request); Guid tempid = new Guid();//订单ID,出库记录表用 //获取订单下所有材料 StoreTreeNameRequests stnRequest = new StoreTreeNameRequests(); stnRequest.PageSize = 1000; stnRequest.treeID = request.Gid; var dpLists = this.StoreService.GetNodeProperty(stnRequest); foreach (DictionaryProperty dp in dpLists) { var storeItem = this.StoreService.ExistDPInStore(dp); tempid = dp.leaf_id.Value; //判断store里是否有dp if (storeItem == null) { StoreTable st = new StoreTable(); st.number = 0; st.number = st.number - (dp.js.Value * Convert.ToDecimal(OutProductNumber)); st.store_item_id = dp.dpid; InBoundRecord ibr = new InBoundRecord(); //插入数据到入库记录表 ibr.inbound_id = st.store_item_id; ibr.rkid = Guid.NewGuid(); ibr.number = dp.js.Value * Convert.ToDecimal(OutProductNumber); ibr.boundtype = "出库材料"; ibr.employment = lydw; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); //出库 this.StoreService.InsertStoreItem(st); } else//有StoreItem { storeItem.number = storeItem.number - (dp.js.Value * Convert.ToDecimal(OutProductNumber)); InBoundRecord ibr = new InBoundRecord(); //插入数据到入库记录表 ibr.inbound_id = storeItem.store_item_id; ibr.rkid = Guid.NewGuid(); ibr.number = dp.js.Value * Convert.ToDecimal(OutProductNumber); ibr.boundtype = "出库材料"; ibr.employment = lydw; ibr.khmc = this.StoreService.GetParentNameByLeafID(storeItem.DictionaryProperty.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); //出库 this.StoreService.OutBoundItem(storeItem); } // } //插入到出库记录表 OutBoundRecord obr = new OutBoundRecord(); obr.ckid = Guid.NewGuid(); obr.node_id = tempid; obr.employment = lydw; obr.number = OutProductNumber; this.StoreService.InsertOutBoundRecord(obr); } return(this.RefreshParent()); }