Ejemplo n.º 1
0
        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);
        }