예제 #1
0
        public ActionResult NewTransportLimitedPrice()
        {
            string strErrText;

            //生成国家下拉列表项
            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");

            //创建空Model
            TransportLimitedPriceViewModel model = new TransportLimitedPriceViewModel();

            return View(model);
        }
예제 #2
0
        public ActionResult NewTransportLimitedPrice(TransportLimitedPriceViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                TransportLimitedPrice data = new TransportLimitedPrice();
                data.PlanType = model.PlanType;
                data.StartCountry = model.StartCountry;
                data.StartProvince = model.StartProvince;
                data.StartCity = model.StartCity;
                data.DestCountry = model.DestCountry;
                data.DestProvince = model.DestProvince;
                data.DestCity = model.DestCity;
                data.CarType = model.CarType;
                data.MinTunnagesOrPiles = model.MinTunnagesOrPiles;
                data.MaxTunnagesOrPiles = model.MaxTunnagesOrPiles;
                data.StartTime = DateTime.Parse(model.StartTime);
                data.EndTime = DateTime.Parse(model.EndTime);
                data.TransportPrice = model.TransportPrice;
                data.TransportCharges = model.TransportCharges;

                //保存数据
                string strErrText;
                DDSystem dd = new DDSystem();
                if (dd.InsertTransportLimitedPrice(data, LoginAccountId, LoginStaffName, out strErrText))
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
예제 #3
0
        public ActionResult ModifyTransportLimitedPrice(string id)
        {
            string strErrText;

            //生成Model数据
            DDSystem dd = new DDSystem();
            TransportLimitedPrice data = dd.LoadTransportLimitedPrice(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            TransportLimitedPriceViewModel model = new TransportLimitedPriceViewModel();
            model.Id = data.Id;
            model.PlanType = data.PlanType;
            model.StartCountry = data.StartCountry;
            model.StartProvince = data.StartProvince;
            model.StartCity = data.StartCity;
            model.DestCountry = data.DestCountry;
            model.DestProvince = data.DestProvince;
            model.DestCity = data.DestCity;
            model.CarType = data.CarType;
            model.MinTunnagesOrPiles = data.MinTunnagesOrPiles;
            model.MaxTunnagesOrPiles = data.MaxTunnagesOrPiles;
            model.StartTime = data.StartTime.ToString("yyyy-MM-dd");
            model.EndTime = data.EndTime.ToString("yyyy-MM-dd");
            model.TransportPrice = data.TransportPrice;
            model.TransportCharges = data.TransportCharges;

            //生成起点国家下拉列表项
            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 s in listStartProvince
                                             select new SelectListItem
                                             {
                                                 Text = s.Name,
                                                 Value = s.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);

            //生成讫点国家下拉列表项
            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.DestCountry);

            //生成讫点省份下拉列表项
            List<Province> listDestProvince = null;
            if (!string.IsNullOrEmpty(model.DestCountry))
            {
                listDestProvince = dd.LoadProvincesByCountry(model.DestCountry, 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 s in listDestProvince
                                            select new SelectListItem
                                            {
                                                Text = s.Name,
                                                Value = s.Name
                                            });
            ViewData["DestProvinces"] = new SelectList(selectListDestProvince, "Value", "Text", model.DestProvince);

            //生成讫点城市下拉列表项
            List<City> listDestCity = null;
            if (!string.IsNullOrEmpty(model.DestProvince))
            {
                listDestCity = dd.LoadCitysByProvince(model.DestCountry, model.DestProvince, 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.DestCity);

            return View(model);
        }