Пример #1
0
        public ActionResult Index( )
        {
            ShipperIndexViewModel vm = new ShipperIndexViewModel();

            ShipperSearchCondition ss = new ShipperSearchCondition();

            vm.ShipperSearchCondition = ss;

            //vm.PageIndex = 0;
            //vm.PageCount = 0;
            vm.ShowEditButton = true;

            //if (useSession.HasValue && useSession.Value)
            //{

            //if (Session["ShipperCRM_SearchCondition"] != null)
            //{
            //    vm.ShipperSearchCondition = (ShipperSearchCondition)Session["ShipperCRM_SearchCondition"];
            //    vm.PageIndex = Session["ShipperCRM_PageIndex"] != null ? (int)Session["ShipperCRM_PageIndex"] : 0;

            //bukan
            if (!string.IsNullOrEmpty(vm.ShipperSearchCondition.TransportMode))
            {
                IList <SelectListItem> selectedtransportModeTypes = new List <SelectListItem>();
                vm.ShipperSearchCondition.TransportMode.Split('|').Each((i, s) =>
                {
                    selectedtransportModeTypes.Add(new SelectListItem()
                    {
                        Text = s, Value = s
                    });
                });

                vm.SelectedTransportModes = selectedtransportModeTypes;
            }

            if (!string.IsNullOrEmpty(vm.ShipperSearchCondition.ProductType))
            {
                IList <SelectListItem> selectedProductTypes = new List <SelectListItem>();
                vm.ShipperSearchCondition.ProductType.Split('|').Each((i, s) =>
                {
                    selectedProductTypes.Add(new SelectListItem()
                    {
                        Text = s, Value = s
                    });
                });

                vm.SelectedProductTypes = selectedProductTypes;
            }

            //else
            //{
            //    vm.ShipperSearchCondition = new ShipperSearchCondition();
            //    vm.PageIndex = 0;
            //}

            var getCRMShippersByConditionResponse = new ShipperManagementService().GetShippersByCondition(new GetShippersByConditionRequest()
            {
                SearchCondition = vm.ShipperSearchCondition,
                PageSize        = UtilConstants.PAGESIZE,
                PageIndex       = vm.PageIndex,
            });

            if (getCRMShippersByConditionResponse.IsSuccess)
            {
                vm.ShipperCollection = getCRMShippersByConditionResponse.Result.ShipperCollection;
                vm.PageIndex         = getCRMShippersByConditionResponse.Result.PageIndex;
                vm.PageCount         = getCRMShippersByConditionResponse.Result.PageCount;
            }

            //else
            //{
            //    vm.ShipperSearchCondition = new ShipperSearchCondition();
            //}

            return(View(vm));
        }
Пример #2
0
        public ActionResult Index(ShipperIndexViewModel vm, int?PageIndex, string Action)
        {
            if (vm.PostedTransportModes != null && vm.PostedTransportModes.Any())
            {
                StringBuilder transportModeSB = new StringBuilder();
                vm.PostedTransportModes.Each((i, s) =>
                {
                    transportModeSB.Append(s).Append("|");
                });
                transportModeSB.Remove(transportModeSB.Length - 1, 1);
                vm.ShipperSearchCondition.TransportMode = transportModeSB.ToString();
            }

            if (vm.PostedProductTypes != null && vm.PostedProductTypes.Any())
            {
                StringBuilder postedProductTypesSB = new StringBuilder();
                vm.PostedProductTypes.Each((i, s) =>
                {
                    postedProductTypesSB.Append(s).Append("|");
                });
                postedProductTypesSB.Remove(postedProductTypesSB.Length - 1, 1);
                vm.ShipperSearchCondition.ProductType = postedProductTypesSB.ToString();
            }
            //查询导出
            var getCRMShippersByConditionRequest = new GetShippersByConditionRequest();

            if (Action == "查询" || Action == "Index")
            {
                getCRMShippersByConditionRequest.SearchCondition = vm.ShipperSearchCondition;
                getCRMShippersByConditionRequest.PageSize        = UtilConstants.PAGESIZE;
                getCRMShippersByConditionRequest.PageIndex       = PageIndex ?? 0;
            }
            else if (Action == "导出")
            {
                getCRMShippersByConditionRequest.SearchCondition = vm.ShipperSearchCondition;
                getCRMShippersByConditionRequest.PageSize        = 0;
                getCRMShippersByConditionRequest.PageIndex       = 0;
            }

            var getCRMShippersByConditionResponse = new ShipperManagementService().GetShippersByCondition(getCRMShippersByConditionRequest);


            if (getCRMShippersByConditionResponse.IsSuccess)
            {
                if (!string.IsNullOrEmpty(vm.ShipperSearchCondition.TransportMode))
                {
                    IList <SelectListItem> selectedtransportModeTypes = new List <SelectListItem>();
                    vm.ShipperSearchCondition.TransportMode.Split('|').Each((i, s) =>
                    {
                        selectedtransportModeTypes.Add(new SelectListItem()
                        {
                            Text = s, Value = s
                        });
                    });

                    vm.SelectedTransportModes = selectedtransportModeTypes;
                }

                if (!string.IsNullOrEmpty(vm.ShipperSearchCondition.ProductType))
                {
                    IList <SelectListItem> selectedProductTypes = new List <SelectListItem>();
                    vm.ShipperSearchCondition.ProductType.Split('|').Each((i, s) =>
                    {
                        selectedProductTypes.Add(new SelectListItem()
                        {
                            Text = s, Value = s
                        });
                    });

                    vm.SelectedProductTypes = selectedProductTypes;
                }

                vm.ShipperCollection = getCRMShippersByConditionResponse.Result.ShipperCollection;
                vm.PageIndex         = getCRMShippersByConditionResponse.Result.PageIndex;
                vm.PageCount         = getCRMShippersByConditionResponse.Result.PageCount;
                Session["ShipperCRM_SearchCondition"] = vm.ShipperSearchCondition;
                Session["ShipperCRM_PageIndex"]       = vm.PageIndex;

                if (Action == "导出")
                {
                    return(this.Export(getCRMShippersByConditionResponse.Result.ShipperCollection));
                }
            }

            return(View(vm));
        }