public ActionResult Index(StoreTableRequest request) { var OrderList = this.StoreService.GetOrderList(new OrderRequest()); this.ViewBag.OrederType = new SelectList(OrderList, "dt_id", "name"); var result = this.StoreService.GetStoreList(request); //foreach(StoreTable st in result) //{ // DictionaryTree dt = new DictionaryTree(); // dt.dt_id = st.DictionaryProperty.leaf_id.Value; // dt.name = this.StoreService.GetParentNameByLeafID(dt.dt_id); // st.DictionaryProperty.DictionaryTree = dt; //} return(View(result)); }
/// <summary> /// 获取库存信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public IEnumerable <StoreTable> GetStoreList(StoreTableRequest request = null) { request = request ?? new StoreTableRequest(); using (var dbContext = new StoreDbContext()) { IQueryable <StoreTable> store = dbContext.StoreTable.Include("DictionaryProperty.DictionaryTree"); if (!string.IsNullOrEmpty(request.orderType) && request.orderType != "00000000-0000-0000-0000-000000000000") { store = store.Where(d => d.DictionaryProperty.leaf_id == new Guid(request.orderType)); } if (!string.IsNullOrEmpty(request.clmc)) { store = store.Where(d => d.DictionaryProperty.clmc.Contains(request.clmc)); } return(store.OrderByDescending(u => u.CreateTime).ToPagedList(request.PageIndex, request.PageSize)); } }
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()); }
public ActionResult Index(StoreTableRequest request) { if (request.export == "export")//导出EXCEL { request.PageSize = 10000000; var ibrAll = this.StoreService.GetStoreList(request); DataTable dt = new DataTable(); dt.Columns.Add("客户名称"); dt.Columns.Add("订单类别"); dt.Columns.Add("材料名称"); dt.Columns.Add("品名"); dt.Columns.Add("门幅"); dt.Columns.Add("基数/米"); dt.Columns.Add("库存量"); foreach (StoreTable storeItem in ibrAll) { DataRow dr = dt.NewRow(); dr["客户名称"] = storeItem.DictionaryProperty.DictionaryTree.parent_name; dr["订单类别"] = storeItem.DictionaryProperty.DictionaryTree.name; dr["材料名称"] = storeItem.DictionaryProperty.clmc; dr["品名"] = storeItem.DictionaryProperty.pm; dr["门幅"] = storeItem.DictionaryProperty.mf; dr["基数/米"] = storeItem.DictionaryProperty.js; dr["库存量"] = storeItem.number; dt.Rows.Add(dr); } byte[] excelByte = this.StoreService.DataTable2Excel(dt, "出入库记录"); using (MemoryStream ms = new MemoryStream()) { return(File(excelByte, "application/ms-excel", "库存记录.xls")); } } var OrderList = this.StoreService.GetOrderList(new OrderRequest()); this.ViewBag.OrederType = new SelectList(OrderList, "dt_id", "name"); var result = this.StoreService.GetStoreList(request); return(View(result)); }
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 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()); }