예제 #1
0
        public Response <GetWMS_CustomerByConditionResponse> GetCustomerByConditon(GetWMS_CustomerByConditionRequest request)
        {
            Response <GetWMS_CustomerByConditionResponse> response = new Response <GetWMS_CustomerByConditionResponse>()
            {
                Result = new GetWMS_CustomerByConditionResponse()
            };

            if (request == null)
            {
                ArgumentNullException ex = new ArgumentNullException("GetWMS_CustomerByConditon request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }

            try
            {
                WMS_CustomerAccessor accessor = new WMS_CustomerAccessor();
                int rowCount;
                response.Result.Customer  = accessor.WMS_GetCustomerByConditon(request.CustomerID, request.StorerKey, request.Contact1, request.PhoneNum, request.Company, request.PageIndex, request.PageSize, out rowCount);
                response.Result.PageIndex = request.PageIndex;
                response.Result.PageCount = rowCount % request.PageSize == 0 ? rowCount / request.PageSize : rowCount / request.PageSize + 1;
                response.IsSuccess        = true;
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.ErrorCode = ErrorCode.Technical;
            }

            return(response);
        }
예제 #2
0
        public ActionResult Index(int?customerType)
        {
            GetWMS_CustomerByConditionRequest vmNew = new GetWMS_CustomerByConditionRequest();

            var CustomerListAll = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Where(t => t.StoreType == 2 || t.StoreType == 3);
            var CustomerListID  = CustomerListAll.Select(t => t.CustomerID);
            var CustomerList    = CustomerListAll.Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });

            ViewBag.CustomerList = CustomerList;
            if (base.UserInfo.UserType == 0)
            {
                vmNew.CustomerID = base.UserInfo.CustomerOrShipperID.ToString();
            }
            else if (base.UserInfo.UserType == 2)
            {
                var customerIDs = ApplicationConfigHelper.GetApplicationCustomer().Where(m => m.UserID == base.UserInfo.ID).Select(c => c.ID);
                if (customerIDs != null && customerIDs.Count() == 1)
                {
                    vmNew.CustomerID = customerIDs.First().ToString();
                }
            }

            IEnumerable <SelectListItem> WarehouseList = null;

            if (vmNew.CustomerID == null)
            {
                WarehouseList = ApplicationConfigHelper.GetCacheInfo().Where(c => c.UserID == base.UserInfo.ID && CustomerListID.Contains(c.CustomerID.Value)).Select(t => new { WarehouseID = t.WarehouseName, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseName.ToString(), Text = c.WarehouseName
                }).Distinct();
            }
            else
            {
                WarehouseList = ApplicationConfigHelper.GetCacheInfo().Where(c => (c.CustomerID.ToString() == vmNew.CustomerID && c.UserID == base.UserInfo.ID)).Select(t => new { WarehouseID = t.WarehouseName, WarehouseName = t.WarehouseName }).Distinct()
                                .Select(c => new SelectListItem()
                {
                    Value = c.WarehouseName.ToString(), Text = c.WarehouseName
                });
            }

            ViewBag.AreaList = ApplicationConfigHelper.GetAllProjectCustomersWarehouse_Area().Select(a => new { a.AreaName }).Distinct().Select(c => new SelectListItem()
            {
                Value = c.AreaName, Text = c.AreaName
            });
            if (WarehouseList.Count() == 1)
            {
            }
            ViewBag.WarehouseList = WarehouseList;
            GetWMS_CustomerByConditionRequest request = new GetWMS_CustomerByConditionRequest();
            WMS_CustomerListViewModel         vm      = new WMS_CustomerListViewModel();

            if (vmNew.CustomerID != null)
            {
                vm.CustomerID = long.Parse(vmNew.CustomerID);
            }



            IEnumerable <SelectListItem> cuslist = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Where(c => c.State && (c.StoreType == 2 || c.StoreType == 3)).Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });

            string CustomerIDNew = null;

            foreach (var item in cuslist)
            {
                CustomerIDNew += item.Value.ToString() + ",";
            }
            var response = new WMS_CustomerService().GetCustomerByConditon(new GetWMS_CustomerByConditionRequest()
            {
                StorerKey = string.IsNullOrEmpty(vm.StorerKey) ? "" : vm.StorerKey, CustomerID = CustomerIDNew, Contact1 = string.IsNullOrEmpty(vm.Contact1) ? "" : vm.Contact1, PhoneNum = string.IsNullOrEmpty(vm.PhoneNum1) ? "" : vm.PhoneNum1, Company = string.IsNullOrEmpty(vm.Company) ? "" : vm.Company, PageSize = UtilConstants.PAGESIZE, PageIndex = 0
            });

            if (response.IsSuccess)
            {
                vm.Customer  = response.Result.Customer;
                vm.PageIndex = response.Result.PageIndex;
                vm.PageCount = response.Result.PageCount;
                vm.StorerID  = cuslist;
            }
            else
            {
                ViewBag.Message = "查询失败!";
            }
            return(View(vm));
        }