Exemple #1
0
        public ActionResult NewCustomer()
        {
            string strErrText;

            //生成所属组织部门下拉列表项
            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");

            //生成国家下拉列表项
            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
            CustomerViewModel model = new CustomerViewModel();
            model.GrossWeightRate = "1";

            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());

            return View(model);
        }
Exemple #2
0
        public ActionResult NewCustomer(CustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Customer data = new Customer();
                data.Name = model.Name;
                data.FullName = model.FullName;
                data.WarningStock = model.WarningStock;
                data.StopStock = model.StopStock;
                data.SettlementExpression = model.SettlementExpression;
                data.ValuationMode = model.ValuationMode;
                data.GrossWeightRate = decimal.Parse(model.GrossWeightRate);
                data.OwnOrganId = model.OwnOrganId;
                data.Remark = model.Remark ?? string.Empty;

                List<CustomerTransportPrice> listTransportPrice = new List<CustomerTransportPrice>();
                if (model.TransportPrices != null)
                {
                    foreach (CustomerTransportPriceViewModel m in model.TransportPrices)
                    {
                        CustomerTransportPrice p = new CustomerTransportPrice();
                        p.CustomerId = m.CustomerId;
                        p.StartCountry = m.StartCountry;
                        p.StartProvince = m.StartProvince;
                        p.StartCity = m.StartCity;
                        p.DestCountry = m.DestCountry;
                        p.DestProvince = m.DestProvince;
                        p.DestCity = m.DestCity;
                        p.MinTunnagesOrPiles = m.MinTunnagesOrPiles;
                        p.MaxTunnagesOrPiles = m.MaxTunnagesOrPiles;
                        p.StartTime = DateTime.Parse(m.StartTime);
                        p.EndTime = DateTime.Parse(m.EndTime);
                        p.CarType = m.CarType;
                        p.TransportPrice = m.TransportPrice;
                        p.RiverCrossingCharges = m.RiverCrossingCharges;
                        listTransportPrice.Add(p);
                    }
                }

                List<CustomerForceFeePrice> listForceFeePrice = new List<CustomerForceFeePrice>();
                if (model.ForceFeePrices != null)
                {
                    foreach (CustomerForceFeePriceViewModel m in model.ForceFeePrices)
                    {
                        CustomerForceFeePrice p = new CustomerForceFeePrice();
                        p.CustomerId = m.CustomerId;
                        p.StartTime = DateTime.Parse(m.ForceFeePriceStartTime);
                        p.EndTime = DateTime.Parse(m.ForceFeePriceEndTime);
                        p.LoadingForceFeePrice = m.LoadingForceFeePrice;
                        p.UnloadingForceFeePrice = m.UnloadingForceFeePrice;
                        listForceFeePrice.Add(p);
                    }
                }

                List<CustomerStorageFeePrice> listStorageFeePrice = new List<CustomerStorageFeePrice>();
                if (model.StorageFeePrices != null)
                {
                    foreach (CustomerStorageFeePriceViewModel m in model.StorageFeePrices)
                    {
                        CustomerStorageFeePrice p = new CustomerStorageFeePrice();
                        p.CustomerId = m.CustomerId;
                        p.StartTime = DateTime.Parse(m.StorageFeePriceStartTime);
                        p.EndTime = DateTime.Parse(m.StorageFeePriceEndTime);
                        p.StorageFeePrice = m.StorageFeePrice;
                        listStorageFeePrice.Add(p);
                    }
                }

                //保存数据
                string strErrText;
                CustomerSystem customer = new CustomerSystem();
                if (customer.InsertCustomer(data, listTransportPrice, listForceFeePrice, listStorageFeePrice, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Exemple #3
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);
        }