public ActionResult NewOtherPlan(OtherPlanViewModel model) { if (ModelState.IsValid) { //检查数据 if (model.Goods == null || model.Goods.Count == 0) { return Json(InnoSoft.LS.Resources.Strings.NotEnterGoods); } //创建数据 DeliverPlan data = new DeliverPlan(); data.PlanType = InnoSoft.LS.Resources.Options.OtherPlan; data.CustomerId = model.CustomerId; data.CustomerName = model.CustomerName; data.DeliveryNo = model.DeliveryNo; data.DeliverType = InnoSoft.LS.Resources.Options.DeliverGoods; data.ReceiverName = model.ReceiverName; data.ReceiverCountry = model.ReceiverCountry; data.ReceiverProvince = model.ReceiverProvince; data.ReceiverCity = model.ReceiverCity; data.ReceiverAddress = model.ReceiverAddress; data.ReceiverContact = model.ReceiverContact; data.ReceiverContactTel = model.ReceiverContactTel; data.ReceiveType = InnoSoft.LS.Resources.Options.PickUpDelivery; data.Warehouse = model.Warehouse; data.ArrivalTime = model.ArrivalTime; data.PayerId = model.CustomerId; data.PayerName = model.CustomerName; data.StartCountry = model.StartCountry; data.StartProvince = model.StartProvince; data.StartCity = model.StartCity; data.Remark = model.Remark; data.CreateTime = DateTime.Parse(model.CreateTime); List<DeliverPlanGoods> listGoods = new List<DeliverPlanGoods>(); if (model.Goods != null) { foreach (OtherPlanGoodsViewModel m in model.Goods) { DeliverPlanGoods g = new DeliverPlanGoods(); g.GoodsId = m.GoodsId; g.Packages = m.Packages; g.Tunnages = m.Tunnages; g.Piles = 0; listGoods.Add(g); } } //保存数据 string strErrText; PlanSystem plan = new PlanSystem(); if (plan.InsertDeliverPlan(data, listGoods, LoginAccountId, LoginStaffName, out strErrText) > 0) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }
public ActionResult ModifyOtherPlan(string id) { string strErrText; //读取计划数据 PlanSystem plan = new PlanSystem(); DeliverPlan data = plan.LoadDeliverPlan(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } //创建Model OtherPlanViewModel model = new OtherPlanViewModel(); model.Id = data.Id; model.CustomerId = data.CustomerId; model.CustomerName = data.CustomerName; model.DeliveryNo = data.DeliveryNo; 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.Warehouse = data.Warehouse; model.ArrivalTime = data.ArrivalTime; model.StartCountry = data.StartCountry; model.StartProvince = data.StartProvince; model.StartCity = data.StartCity; model.Remark = data.Remark; model.CreateTime = data.CreateTime.ToString("yyyy-MM-dd"); model.Goods = new List<OtherPlanGoodsViewModel>(); model.Goods.Add(new OtherPlanGoodsViewModel()); //生成讫点国家下拉列表项 DDSystem dd = new DDSystem(); List<Country> listDestCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listDestCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListDestCountry = new List<SelectListItem>(); selectListDestCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestCountry.AddRange(from c in listDestCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["DestCountrys"] = new SelectList(selectListDestCountry, "Value", "Text", model.ReceiverCountry); //生成讫点省份下拉列表项 List<Province> listDestProvince = null; if (!string.IsNullOrEmpty(model.ReceiverCountry)) { listDestProvince = dd.LoadProvincesByCountry(model.ReceiverCountry, LoginAccountId, LoginStaffName, out strErrText); if (listDestProvince == null) { throw new Exception(strErrText); } } else { listDestProvince = new List<Province>(); } List<SelectListItem> selectListDestProvince = new List<SelectListItem>(); selectListDestProvince.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestProvince.AddRange(from p in listDestProvince select new SelectListItem { Text = p.Name, Value = p.Name }); ViewData["DestProvinces"] = new SelectList(selectListDestProvince, "Value", "Text", model.ReceiverProvince); //生成讫点城市下拉列表项 List<City> listDestCity = null; if (!string.IsNullOrEmpty(model.ReceiverProvince)) { listDestCity = dd.LoadCitysByProvince(model.ReceiverCountry, model.ReceiverProvince, LoginAccountId, LoginStaffName, out strErrText); if (listDestCity == null) { throw new Exception(strErrText); } } else { listDestCity = new List<City>(); } List<SelectListItem> selectListDestCity = new List<SelectListItem>(); selectListDestCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestCity.AddRange(from ci in listDestCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["DestCitys"] = new SelectList(selectListDestCity, "Value", "Text", model.ReceiverCity); //生成起点国家下拉列表项 List<Country> listStartCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listStartCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListStartCountry = new List<SelectListItem>(); selectListStartCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartCountry.AddRange(from c in listStartCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["StartCountrys"] = new SelectList(selectListStartCountry, "Value", "Text", model.StartCountry); //生成起点省份下拉列表项 List<Province> listStartProvince = null; if (!string.IsNullOrEmpty(model.StartCountry)) { listStartProvince = dd.LoadProvincesByCountry(model.StartCountry, LoginAccountId, LoginStaffName, out strErrText); if (listStartProvince == null) { throw new Exception(strErrText); } } else { listStartProvince = new List<Province>(); } List<SelectListItem> selectListStartProvince = new List<SelectListItem>(); selectListStartProvince.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartProvince.AddRange(from p in listStartProvince select new SelectListItem { Text = p.Name, Value = p.Name }); ViewData["StartProvinces"] = new SelectList(selectListStartProvince, "Value", "Text", model.StartProvince); //生成起点城市下拉列表项 List<City> listStartCity = null; if (!string.IsNullOrEmpty(model.StartProvince)) { listStartCity = dd.LoadCitysByProvince(model.StartCountry, model.StartProvince, LoginAccountId, LoginStaffName, out strErrText); if (listStartCity == null) { throw new Exception(strErrText); } } else { listStartCity = new List<City>(); } List<SelectListItem> selectListStartCity = new List<SelectListItem>(); selectListStartCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartCity.AddRange(from ci in listStartCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["StartCitys"] = new SelectList(selectListStartCity, "Value", "Text", model.StartCity); return View(model); }
public ActionResult NewOtherPlan() { string strErrText; //创建空的Model OtherPlanViewModel model = new OtherPlanViewModel(); model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); model.Goods = new List<OtherPlanGoodsViewModel>(); model.Goods.Add(new OtherPlanGoodsViewModel()); //生成国家下拉列表项 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"); //生成空的省份下拉列表项 List<Province> listState = new List<Province>(); List<SelectListItem> selectListState = new List<SelectListItem>(); selectListState.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListState.AddRange(from s in listState select new SelectListItem { Text = s.Name, Value = s.Name }); ViewData["Provinces"] = new SelectList(selectListState, "Value", "Text"); //生成空的城市下拉列表项 List<City> 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"); return View(model); }
public ActionResult LoadOtherPlanDetails(string id) { string strErrText; //读取计划数据 PlanSystem plan = new PlanSystem(); DeliverPlan data = plan.LoadDeliverPlan(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } //创建Model OtherPlanViewModel model = new OtherPlanViewModel(); model.Id = data.Id; model.CustomerId = data.CustomerId; model.CustomerName = data.CustomerName; model.DeliveryNo = data.DeliveryNo; 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.Warehouse = data.Warehouse; model.ArrivalTime = data.ArrivalTime; model.StartCountry = data.StartCountry; model.StartProvince = data.StartProvince; model.StartCity = data.StartCity; model.Remark = data.Remark; model.CreateTime = data.CreateTime.ToString("yyyy-MM-dd"); return PartialView("OtherPlanDetails", model); }