public ActionResult EnterWarehouse(string id) { string strErrText; //创建Model EnterWarehouseBillViewModel model = new EnterWarehouseBillViewModel(); if (id != null && id != string.Empty) { //读取入库单数据 StockSystem stock = new StockSystem(); EnterWarehouseBill bill = stock.LoadEnterWarehouseBill(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (bill == null) { throw new Exception(strErrText); } model.Id = bill.Id; model.BillNo = bill.BillNo; model.PlanId = bill.PlanId; model.CustomerId = bill.CustomerId; model.CustomerName = bill.CustomerName; model.DeliveryNo = bill.DeliveryNo; model.EnterType = bill.EnterType; model.IsConsigning = bill.IsConsigning; model.Warehouse = bill.Warehouse; model.UnloadingForceFeePrice = bill.UnloadingForceFeePrice; model.ForceFee = bill.ForceFee; model.StorageFeePrice = bill.StorageFeePrice; model.HasDrayage = bill.HasDrayage; model.Remark = bill.Remark; model.CreateTime = bill.CreateTime.ToString("yyyy-MM-dd"); } else { model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); } model.Goods = new List<EnterWarehouseBillGoodsViewModel>(); model.Goods.Add(new EnterWarehouseBillGoodsViewModel()); //生成入库类别下拉列表项 List<SelectListItem> selectListEnterType = new List<SelectListItem>(); selectListEnterType.Add(new SelectListItem { Text = InnoSoft.LS.Resources.Options.DeliverInStorage, Value = InnoSoft.LS.Resources.Options.DeliverInStorage }); selectListEnterType.Add(new SelectListItem { Text = InnoSoft.LS.Resources.Options.AllocateInStorage, Value = InnoSoft.LS.Resources.Options.AllocateInStorage }); ViewData["EnterTypes"] = new SelectList(selectListEnterType, "Value", "Text", model.EnterType); //生成仓库下拉列表项 DDSystem dd = new DDSystem(); List<Warehouse> listWarehouse = dd.LoadWarehouses(LoginAccountId, LoginStaffName, out strErrText); if (listWarehouse == null) { throw new Exception(strErrText); } List<SelectListItem> selectListWarehouse = new List<SelectListItem>(); selectListWarehouse.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListWarehouse.AddRange(from w in listWarehouse select new SelectListItem { Text = w.Name, Value = w.Name }); ViewData["Warehouses"] = new SelectList(selectListWarehouse, "Value", "Text", model.Warehouse); return View(model); }
public ActionResult EnterWarehouse(EnterWarehouseBillViewModel model) { if (ModelState.IsValid) { //创建数据 EnterWarehouseBill bill = new EnterWarehouseBill(); bill.Id = model.Id; bill.BillNo = model.BillNo; bill.PlanId = model.PlanId; bill.CustomerId = model.CustomerId; bill.CustomerName = model.CustomerName; bill.DeliveryNo = model.DeliveryNo; bill.EnterType = model.EnterType; bill.IsConsigning = model.IsConsigning; bill.Warehouse = model.Warehouse; bill.UnloadingForceFeePrice = model.UnloadingForceFeePrice; bill.ForceFee = model.ForceFee; bill.StorageFeePrice = model.StorageFeePrice; bill.HasDrayage = model.HasDrayage; bill.Remark = model.Remark; bill.CreateTime = DateTime.Parse(model.CreateTime); List<EnterWarehouseBillGoods> listGoods = new List<EnterWarehouseBillGoods>(); foreach (EnterWarehouseBillGoodsViewModel m in model.Goods) { EnterWarehouseBillGoods g = new EnterWarehouseBillGoods(); g.Id = m.Id; g.CustomerId = model.CustomerId; g.CustomerName = model.CustomerName; g.GoodsId = m.GoodsId; g.GoodsNo = m.GoodsNo; g.GoodsName = m.GoodsName; g.Brand = m.Brand; g.SpecModel = m.SpecModel; g.GWeight = m.GWeight; g.Grade = m.Grade; g.BatchNo = m.BatchNo; g.Packing = m.Packing; g.Warehouse = model.Warehouse; g.Location = m.Location; g.Packages = m.Packages; g.PieceWeight = m.PieceWeight; g.Tunnages = m.Tunnages; g.Piles = m.Piles; g.TenThousands = m.TenThousands; g.ProductionDate = m.ProductionDate; g.ShipmentBillGoodsIds = m.ShipmentBillGoodsIds; g.EnterWarehouseBillId = m.EnterWarehouseBillId; g.DeliveryNo = model.DeliveryNo; g.CreateTime = DateTime.Parse(model.CreateTime); listGoods.Add(g); } //保存数据 string strErrText; StockSystem stock = new StockSystem(); if (bill.Id == 0) { long nEnterWarehouseBillId = stock.InsertEnterWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText); if (nEnterWarehouseBillId > 0) { //读取入库单号 bill = stock.LoadEnterWarehouseBill(nEnterWarehouseBillId, LoginAccountId, LoginStaffName, out strErrText); if (bill == null) { var ret = new { EnterWarehouseBillNo = string.Empty, ErrorText = strErrText }; return Json(ret); } else { var ret = new { EnterWarehouseBillNo = bill.BillNo, ErrorText = string.Empty }; return Json(ret); } } else { var ret = new { EnterWarehouseBillNo = string.Empty, ErrorText = strErrText }; return Json(ret); } } else { if (stock.UpdateEnterWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { var ret = new { EnterWarehouseBillNo = bill.BillNo, ErrorText = string.Empty }; return Json(ret); } else { var ret = new { EnterWarehouseBillNo = string.Empty, ErrorText = strErrText }; return Json(ret); } } } return View(model); }
public ActionResult EnterStockEndDifferences() { //创建Model EnterWarehouseBillViewModel model = new EnterWarehouseBillViewModel(); model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); model.Goods = new List<EnterWarehouseBillGoodsViewModel>(); model.Goods.Add(new EnterWarehouseBillGoodsViewModel()); return View(model); }