public ActionResult Index(WMS_CustomerListViewModel vm, int?PageIndex) { 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; if (vm.CustomerID != null) { CustomerIDNew = vm.CustomerID.ToString(); } else { 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 = PageIndex ?? 0 }); // var response = new WMS_CustomerService().GetCustomerByConditon(new GetWMS_CustomerByConditionRequest() { StorerKey = string.IsNullOrEmpty(vm.StorerKey) ? "" : vm.StorerKey, CustomerID = string.IsNullOrEmpty(vm.CustomerID.ToString()) ? "" : vm.CustomerID.ToString(), 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 = 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)); }
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)); }