public IQueryable <Product> Sort(IQueryable <Product> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "productName": query = sortCol.Type == "desc" ? query.OrderBy(o => o.ProductName) : query.OrderByDescending(o => o.ProductName); break; case "barCode": query = sortCol.Type == "desc" ? query.OrderBy(o => o.BarCode) : query.OrderByDescending(o => o.BarCode); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public IQueryable <AppMenu> Sort(IQueryable <AppMenu> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "order": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Order) : query.OrderByDescending(o => o.Order); break; case "code": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Code) : query.OrderByDescending(o => o.Code); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public IQueryable <Branch> Sort(IQueryable <Branch> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "name": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Name) : query.OrderByDescending(o => o.Name); break; case "createTime": query = sortCol.Type == "desc" ? query.OrderBy(o => o.CreateTime) : query.OrderByDescending(o => o.CreateTime); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public SortCol GetSort() { var sortCol = new SortCol() { Field = HttpContext.Request.Query["field"], Type = HttpContext.Request.Query["type"], }; return(sortCol); }
public IQueryable <Measure> Sort(IQueryable <Measure> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "measureName": query = sortCol.Type == "desc" ? query.OrderBy(o => o.MeasureName) : query.OrderByDescending(o => o.MeasureName); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public IQueryable <Location> Sort(IQueryable <Location> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "localBarCode": query = sortCol.Type == "desc" ? query.OrderBy(o => o.LocalBarCode) : query.OrderByDescending(o => o.LocalBarCode); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public IQueryable <InStorage> Sort(IQueryable <InStorage> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "orderNum": query = sortCol.Type == "desc" ? query.OrderBy(o => o.OrderNum) : query.OrderByDescending(o => o.OrderNum); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public IQueryable <ProductCategory> Sort(IQueryable <ProductCategory> query, SortCol sortCol) { switch (sortCol.Field) { case "id": query = sortCol.Type == "desc" ? query.OrderBy(o => o.Id) : query.OrderByDescending(o => o.Id); break; case "cateName": query = sortCol.Type == "desc" ? query.OrderBy(o => o.CateName) : query.OrderByDescending(o => o.CateName); break; default: query = query.OrderByDescending(o => o.Id); break; } return(query); }
public ConnectionsViewModel(EntityReference parentRecordId, string[] connectToTypes, int pageSize, FetchQuerySettings view) { Connections = new EntityDataViewModel(pageSize, typeof(Connection), true); if (view != null) { _viewFetchXml = QueryParser.GetFetchXmlParentFilter(view, "record1id"); // Set initial sort _defaultSortCol = new SortCol(view.OrderByAttribute, !view.OrderByDesending); } ParentRecordId.SetValue(parentRecordId); ObservableConnection connection = new ObservableConnection(connectToTypes); connection.Record2Id.SetValue(parentRecordId); ConnectionEdit = (Observable <ObservableConnection>)ValidatedObservableFactory.ValidatedObservable(connection); Connections.OnDataLoaded.Subscribe(Connections_OnDataLoaded); ConnectionEdit.GetValue().OnSaveComplete += ConnectionsViewModel_OnSaveComplete; ObservableConnection.RegisterValidation(Connections.ValidationBinder); AllowAddNew = Knockout.DependentObservable <bool>(AllowAddNewComputed); }
public ColSorter(int Col) { this._sortColumn = (SortCol) Col; }
public async Task <ResponseModel <MeasureViewModel> > GetList(MeasureFilters filters, SortCol sortCol, AccountViewModel account) { var query = _context.Measure.Where(o => o.CompanyId == account.CompanyId); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <MeasureViewModel>().ToListAsync(); ResponseModel <MeasureViewModel> result = new ResponseModel <MeasureViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <ProductViewModel> > GetList(ProductFilters filters, SortCol sortCol , AccountViewModel account, string type = "管理") { var query = _context.Product.Where(o => o.IsDelete == 0 && o.CompanyId == account.CompanyId); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <ProductViewModel>().ToListAsync(); if (type == "报表") { foreach (var vm in vms) { var productNum = vm.Id.ToString(); vm.LocalProductNum = _context.LocalProduct.Where(o => o.ProductNum == productNum && o.CompanyId == account.CompanyId).Select(o => o.Num).Sum(); vm.InStorageNum = _context.InStorDetail.Where(o => o.ProductNum == productNum) .Select(o => (int)o.PutRealNum).Sum(); vm.OutStorageNum = _context.OutStoDetail.Where(o => o.ProductNum == productNum) .Select(o => (int)o.PutRealNum).Sum(); vm.BadReportNum = _context.BadReportDetail.Where(o => o.ProductNum == productNum).Select(o => o.Num).Sum(); } } ResponseModel <ProductViewModel> result = new ResponseModel <ProductViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public override void Sort(SortColData sorting) { _sortColumn = new SortCol(sorting.SortCol.Field, sorting.SortAsc); Refresh(); }
private void SortBy(SortCol col, List <object> data) { // From SlickGrid : an extra reversal for descending sort keeps the sort stable // (assuming a stable native sort implementation, which isn't true in some cases) if (col.Ascending == false) { data.Reverse(); } data.Sort(delegate(object a, object b) { object l = ((Dictionary <string, object>)a)[col.AttributeName]; object r = ((Dictionary <string, object>)b)[col.AttributeName]; decimal result = 0; string typeName = ""; if (l != null) { typeName = l.GetType().Name; } else if (r != null) { typeName = r.GetType().Name; } if (l != r) { switch (typeName.ToLowerCase()) { case "string": l = l != null ? ((string)l).ToLowerCase() : null; r = r != null ? ((string)r).ToLowerCase() : null; if ((bool)Script.Literal("{0}<{1}", l, r)) { result = -1; } else { result = 1; } break; case "date": if ((bool)Script.Literal("{0}<{1}", l, r)) { result = -1; } else { result = 1; } break; case "number": decimal ln = l != null ? ((decimal)l) : 0; decimal rn = r != null ? ((decimal)r) : 0; result = (ln - rn); break; case "money": decimal lm = l != null ? ((Money)l).Value : 0; decimal rm = r != null ? ((Money)r).Value : 0; result = (lm - rm); break; case "optionsetvalue": int?lo = l != null ? ((OptionSetValue)l).Value : 0; lo = lo != null ? lo : 0; int?ro = r != null ? ((OptionSetValue)r).Value : 0; ro = ro != null ? ro : 0; result = (decimal)(lo - ro); break; case "entityreference": string le = (l != null) && (((EntityReference)l).Name != null) ? ((EntityReference)l).Name : ""; string re = r != null && (((EntityReference)r).Name != null) ? ((EntityReference)r).Name : ""; if ((bool)Script.Literal("{0}<{1}", le, re)) { result = -1; } else { result = 1; } break; } } return((int)result); }); if (col.Ascending == false) { data.Reverse(); } }
public async Task <ResponseModel <InStorageViewModel> > GetListReport(InStorageFilters filters, SortCol sortCol , AccountViewModel acoount) { var query = _context.InStorage.Where(o => o.IsDelete == 0 && o.CompanyId == acoount.CompanyId) .Select(o => new InStorage() { OrderNum = o.OrderNum, Num = o.Num, CreateTime = o.CreateTime.Date }); query = Search(query, filters); var orderNums = await query.Select(o => o.OrderNum).ToListAsync(); var _query = query.GroupBy(o => o.CreateTime).Select(o => new InStorageViewModel() { CreateTime = o.Key, Num = o.Count() }); var vms = await _query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit).ToListAsync(); foreach (var vm in vms) { var details = _context.InStorDetail.Where(o => orderNums.Contains(o.OrderNum) && o.CreateTime > vm.CreateTime && o.CreateTime < vm.CreateTime.AddDays(1)).ToList(); vm.CreateTimeStr = vm.CreateTime.ToString("yyyy-MM-dd"); vm.Num = details.Sum(o => (double)o.PutRealNum); vm.Price = details.Sum(o => o.InPrice); } ResponseModel <InStorageViewModel> result = new ResponseModel <InStorageViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <InStorageViewModel> > GetListSupReport(InStorageFilters filters, SortCol sortCol , AccountViewModel acoount) { var query = _context.InStorage.Where(o => o.IsDelete == 0 && o.CompanyId == acoount.CompanyId); query = Search(query, filters); var _query = query.GroupBy(o => o.SupName).Select(o => new InStorageViewModel() { SupName = o.Key, Num = o.Count() }); var vms = await _query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit).ToListAsync(); ResponseModel <InStorageViewModel> result = new ResponseModel <InStorageViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <InStorageViewModel> > GetList(InStorageFilters filters, SortCol sortCol , AccountViewModel acoount) { var query = _context.InStorage.Where(o => o.IsDelete == 0 && o.CompanyId == acoount.CompanyId); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <InStorageViewModel>().ToListAsync(); foreach (var vm in vms) { vm.RealNum = _context.InStorDetail.Where(o => o.OrderNum == vm.OrderNum).Sum(o => o.RealNum); vm.PutNum = (double)_context.InStorDetail.Where(o => o.OrderNum == vm.OrderNum).Sum(o => o.PutRealNum); } ResponseModel <InStorageViewModel> result = new ResponseModel <InStorageViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <LocalProductViewModel> > GetList(LocalProductFilters filters, SortCol sortCol, AccountViewModel account) { var query = _context.LocalProduct.Where(o => o.CompanyId == account.CompanyId); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <LocalProductViewModel>().ToListAsync(); var barCodes = vms.Select(o => o.BarCode).ToList(); var products = _context.Product.Where(o => barCodes.Contains(o.BarCode)).ToList(); foreach (var vm in vms) { var product = products.FirstOrDefault(o => o.BarCode == vm.BarCode); if (product == null) { continue; } if (vm.Num < product.MinNum) { vm.Status = "下限预警"; } else if (vm.Num > product.MaxNum) { vm.Status = "上限预警"; } else { vm.Status = "正常"; } } ResponseModel <LocalProductViewModel> result = new ResponseModel <LocalProductViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <AppMenuViewModel> > GetList(AppmenuFilters filters, SortCol sortCol) { var query = _accessManagementContext.AppMenu.Where(o => o.Id != 0); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <AppMenuViewModel>().ToListAsync(); ResponseModel <AppMenuViewModel> result = new ResponseModel <AppMenuViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }
public async Task <ResponseModel <BadReportDetailViewModel> > GetListReport(BadReportFilters filters, SortCol sortCol , AccountViewModel acoount) { var query = _context.BadReport.Where(o => o.IsDelete == 0 && o.CompanyId == acoount.CompanyId) .Select(o => new BadReport() { OrderNum = o.OrderNum, Num = o.Num, CreateTime = o.CreateTime.Date }); query = Search(query, filters); var orderNums = await query.Select(o => o.OrderNum).ToListAsync(); var details = _context.BadReportDetail.Where(o => orderNums.Contains(o.OrderNum)).ToList(); var _query = details.GroupBy(o => o.ProductNum).Select(o => new BadReportDetailViewModel() { ProductNum = o.Key, Num = o.Count() }); var vms = _query.Skip((filters.Page - 1) * filters.Limit).Take(filters.Limit).ToList(); foreach (var vm in vms) { var detail = details.FirstOrDefault(o => o.ProductNum == vm.ProductNum); vm.ProductName = detail.ProductName; vm.BarCode = detail.BarCode; vm.Num = details.Where(o => o.ProductNum == vm.ProductNum).Sum(o => o.Num); } ResponseModel <BadReportDetailViewModel> result = new ResponseModel <BadReportDetailViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }