public ActionResult OutWarehouse(string id) { string strErrText; //创建Model OutWarehouseBillViewModel model = new OutWarehouseBillViewModel(); if (id != null && id != string.Empty) { //读取出库单数据 StockSystem stock = new StockSystem(); OutWarehouseBill data = stock.LoadOutWarehouseBill(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } model.Id = data.Id; model.BillNo = data.BillNo; model.PlanId = data.PlanId; model.CustomerId = data.CustomerId; model.CustomerName = data.CustomerName; model.DeliveryNo = data.DeliveryNo; model.OutType = data.OutType; model.ReceiverName = data.ReceiverName; model.ReceiverCountry = data.ReceiverCountry; model.ReceiverProvince = data.ReceiverProvince; model.ReceiverCity = data.ReceiverCity; model.ReceiverAddress = data.ReceiverAddress; model.ReceiverContact = data.ReceiverContact; model.ReceiverContactTel = data.ReceiverContactTel; model.ReceiveType = data.ReceiveType; model.CarNo = data.CarNo; model.TrailerNo = data.TrailerNo; model.CarrierId = data.CarrierId; model.CarrierName = data.CarrierName; model.PayerId = data.PayerId; model.PayerName = data.PayerName; model.IsConsigning = data.IsConsigning; model.ConsignedDeliveryNo = data.ConsignedDeliveryNo; model.Warehouse = data.Warehouse; model.LoadingForceFeePrice = data.LoadingForceFeePrice; model.ForceFee = data.ForceFee; model.Remark = data.Remark; model.CreateTime = data.CreateTime.ToString("yyyy-MM-dd"); } else { model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); } model.Goods = new List<OutWarehouseBillGoodsViewModel>(); model.Goods.Add(new OutWarehouseBillGoodsViewModel()); //生成国家下拉列表项 DDSystem dd = new DDSystem(); List<Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListCountry = new List<SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countrys"] = new SelectList(selectListCountry, "Value", "Text", model.ReceiverCountry); //生成省份下拉列表项 List<Province> listState = null; if (!string.IsNullOrEmpty(model.ReceiverCountry)) { listState = dd.LoadProvincesByCountry(model.ReceiverCountry, LoginAccountId, LoginStaffName, out strErrText); if (listState == null) { throw new Exception(strErrText); } } else { listState = new List<Province>(); } List<SelectListItem> selectListState = new List<SelectListItem>(); selectListState.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListState.AddRange(from p in listState select new SelectListItem { Text = p.Name, Value = p.Name }); ViewData["Provinces"] = new SelectList(selectListState, "Value", "Text", model.ReceiverProvince); //生成城市下拉列表项 List<City> listCity = null; if (!string.IsNullOrEmpty(model.ReceiverProvince)) { listCity = dd.LoadCitysByProvince(model.ReceiverCountry, model.ReceiverProvince, LoginAccountId, LoginStaffName, out strErrText); if (listCity == null) { throw new Exception(strErrText); } } else { listCity = new List<City>(); } List<SelectListItem> selectListCity = new List<SelectListItem>(); selectListCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCity.AddRange(from ci in listCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["Citys"] = new SelectList(selectListCity, "Value", "Text", model.ReceiverCity); //生成仓库下拉列表项 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 OutWarehouse(OutWarehouseBillViewModel model) { if (ModelState.IsValid) { //检查承运单位 if (model.OutType == InnoSoft.LS.Resources.Options.DeliverGoods) { if (model.CarrierId == 0 || model.CarrierName == string.Empty) { return Json(InnoSoft.LS.Resources.Strings.NotEnterCarrierInfoWhenDeliverGoods); } } //创建数据 OutWarehouseBill bill = new OutWarehouseBill(); 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.OutType = model.OutType; bill.ReceiverName = model.ReceiverName; bill.ReceiverCountry = model.ReceiverCountry; bill.ReceiverProvince = model.ReceiverProvince; bill.ReceiverCity = model.ReceiverCity; bill.ReceiverAddress = model.ReceiverAddress; bill.ReceiverContact = model.ReceiverContact; bill.ReceiverContactTel = model.ReceiverContactTel; bill.ReceiveType = model.ReceiveType; bill.CarNo = model.CarNo; bill.TrailerNo = model.TrailerNo; bill.CarrierId = model.CarrierId; bill.CarrierName = model.CarrierName; bill.PayerId = model.PayerId; bill.PayerName = model.PayerName; bill.IsConsigning = model.IsConsigning; bill.ConsignedDeliveryNo = model.ConsignedDeliveryNo; bill.Warehouse = model.Warehouse; bill.LoadingForceFeePrice = model.LoadingForceFeePrice; bill.ForceFee = model.ForceFee; bill.Remark = model.Remark; bill.CreateTime = DateTime.Parse(model.CreateTime); List<OutWarehouseBillGoods> listGoods = new List<OutWarehouseBillGoods>(); foreach (OutWarehouseBillGoodsViewModel m in model.Goods) { OutWarehouseBillGoods g = new OutWarehouseBillGoods(); g.Id = m.Id; g.OutWarehouseBillId = m.OutWarehouseBillId; g.GoodsId = m.GoodsId; g.GoodsName = m.GoodsName; g.GoodsNo = m.GoodsNo; g.Brand = m.Brand; g.SpecModel = m.SpecModel; g.GWeight = m.GWeight; g.Grade = m.Grade; g.PieceWeight = m.PieceWeight; g.Packing = m.Packing; g.BatchNo = m.BatchNo; g.Location = m.Location; g.Packages = m.Packages; g.Tunnages = m.Tunnages; g.Piles = m.Piles; g.TenThousands = m.TenThousands; g.ProductionDate = m.ProductionDate; g.EnterWarehouseBillId = m.EnterWarehouseBillId; listGoods.Add(g); } string strErrText; StockSystem stock = new StockSystem(); if (bill.Id > 0) { if (stock.UpdateOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } else { if (stock.InsertOutWarehouseBill(bill, listGoods, LoginAccountId, LoginStaffName, out strErrText) > 0) { return Json(string.Empty); } else { return Json(strErrText); } } } return View(model); }
public ActionResult OutStockEndDifferences() { string strErrText; //创建Model OutWarehouseBillViewModel model = new OutWarehouseBillViewModel(); model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); model.Goods = new List<OutWarehouseBillGoodsViewModel>(); model.Goods.Add(new OutWarehouseBillGoodsViewModel()); //生成国家下拉列表项 DDSystem dd = new DDSystem(); List<Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListCountry = new List<SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countrys"] = new SelectList(selectListCountry, "Value", "Text", model.ReceiverCountry); //生成省份下拉列表项 List<Province> listState = null; if (!string.IsNullOrEmpty(model.ReceiverCountry)) { listState = dd.LoadProvincesByCountry(model.ReceiverCountry, LoginAccountId, LoginStaffName, out strErrText); if (listState == null) { throw new Exception(strErrText); } } else { listState = new List<Province>(); } List<SelectListItem> selectListState = new List<SelectListItem>(); selectListState.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListState.AddRange(from p in listState select new SelectListItem { Text = p.Name, Value = p.Name }); ViewData["Provinces"] = new SelectList(selectListState, "Value", "Text", model.ReceiverProvince); //生成城市下拉列表项 List<City> listCity = null; if (!string.IsNullOrEmpty(model.ReceiverProvince)) { listCity = dd.LoadCitysByProvince(model.ReceiverCountry, model.ReceiverProvince, LoginAccountId, LoginStaffName, out strErrText); if (listCity == null) { throw new Exception(strErrText); } } else { listCity = new List<City>(); } List<SelectListItem> selectListCity = new List<SelectListItem>(); selectListCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCity.AddRange(from ci in listCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["Citys"] = new SelectList(selectListCity, "Value", "Text", model.ReceiverCity); //生成仓库下拉列表项 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); }