Ejemplo n.º 1
0
        public ActionResult ModifyCustomer(string id)
        {
            string strErrText;

            //生成Model数据
            CustomerSystem customer = new CustomerSystem();
            Customer data = customer.LoadCustomer(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            CustomerViewModel model = new CustomerViewModel();
            model.Id = data.Id;
            model.Name = data.Name;
            model.FullName = data.FullName;
            model.WarningStock = data.WarningStock;
            model.StopStock = data.StopStock;
            model.SettlementExpression = data.SettlementExpression;
            model.ValuationMode = data.ValuationMode;
            model.GrossWeightRate = data.GrossWeightRate.ToString("#0.######");
            model.OwnOrganId = data.OwnOrganId;
            model.Remark = data.Remark;

            model.TransportPrices = new List<CustomerTransportPriceViewModel>();
            model.TransportPrices.Add(new CustomerTransportPriceViewModel());

            model.ForceFeePrices = new List<CustomerForceFeePriceViewModel>();
            model.ForceFeePrices.Add(new CustomerForceFeePriceViewModel());

            model.StorageFeePrices = new List<CustomerStorageFeePriceViewModel>();
            model.StorageFeePrices.Add(new CustomerStorageFeePriceViewModel());

            //生成所属组织部门下拉列表项
            OrganizationSystem organ = new OrganizationSystem();
            List<Organization> listOrgan = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText);
            if (listOrgan == null)
            {
                throw new Exception(strErrText);
            }
            Organization root = listOrgan.Find(delegate(Organization o) { return o.ParentId == 0; });
            List<SelectListItem> selectListOrgan = new List<SelectListItem>();
            selectListOrgan.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListOrgan.AddRange(from o in listOrgan
                                     where o.ParentId == root.Id
                                     select new SelectListItem
                                     {
                                         Text = o.Name,
                                         Value = o.Id.ToString()
                                     });
            ViewData["OwnOrgans"] = new SelectList(selectListOrgan, "Value", "Text", model.OwnOrganId.ToString());

            //生成国家下拉列表项
            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);
        }
Ejemplo n.º 2
0
        public ActionResult CustomerNewPaperPlan()
        {
            string strErrText;

            //创建空的Model
            PaperPlanViewModel model = new PaperPlanViewModel();
            model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd");

            model.Goods = new List<PaperPlanGoodsViewModel>();
            model.Goods.Add(new PaperPlanGoodsViewModel());

            //设置客户信息和付款单位信息
            if (LoginAccountType == InnoSoft.LS.Resources.Options.Customer)
            {
                model.CustomerId = LoginOrganId;
                model.CustomerName = LoginOrganName;
                model.PayerId = model.CustomerId;
                model.PayerName = model.CustomerName;

                //读取客户所属办事处数据
                CustomerSystem customer = new CustomerSystem();
                Customer dataCustomer = customer.LoadCustomer(model.CustomerId, LoginAccountId, LoginStaffName, out strErrText);
                if (dataCustomer == null)
                {
                    throw new Exception(strErrText);
                }
                OrganizationSystem organ = new OrganizationSystem();
                Organization dataOrgan = organ.LoadOrganization(dataCustomer.OwnOrganId, LoginAccountId, LoginStaffName, out strErrText);
                if (dataOrgan == null)
                {
                    throw new Exception(strErrText);
                }
                model.StartCountry = dataOrgan.CountryName;
                model.StartProvince = dataOrgan.ProvinceName;
                model.StartCity = dataOrgan.CityName;
            }

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

            //生成空的讫点省份下拉列表项
            List<Province> 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");

            //生成空的讫点城市下拉列表项
            List<City> 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");

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