protected virtual void _(Events.RowSelecting <ARInvoice> e) { if (e.Row?.IsUnderCorrection != true) { return; } PXView view = new SelectFrom <ARRegisterAlias> .Where <ARRegisterAlias.origDocType.IsEqual <ARInvoice.docType.FromCurrent> .And <ARRegisterAlias.origRefNbr.IsEqual <ARInvoice.refNbr.FromCurrent> .And <Where2 <ARRegisterAlias.isCorrection.IsEqual <True>, Or <ARRegisterAlias.isCancellation.IsEqual <True> .And <ARRegisterAlias.released.IsNotEqual <True> > > > > > > .View.ReadOnly(Base).View; using (new PXConnectionScope()) using (new PXFieldScope(view, typeof(ARRegisterAlias.docType), typeof(ARRegisterAlias.refNbr), typeof(ARRegisterAlias.isCancellation))) { var correction = (ARRegisterAlias)view.SelectSingleBound(new[] { e.Row }); e.Row.CorrectionDocType = correction?.DocType; e.Row.CorrectionRefNbr = correction?.RefNbr; e.Row.IsUnderCancellation = correction?.IsCancellation == true; } }
public IEnumerable detailsView() { //var lastFinPeriod = DateTime.Now.AddMonths(-1).ToString("yyyyMM"); var filter = MasterViewFilter.Current?.FinPeriodID; if (filter == null) { filter = ((DateTime)Accessinfo.BusinessDate).AddMonths(-1).ToString("yyyyMM"); } PXSelectBase <LCMValuation> command = new SelectFrom <LCMValuation> .View.ReadOnly(this); var result = new PXDelegateResult(); foreach (PXResult <LCMValuation> row in command.Select()) { if (((LCMValuation)row).FinPeriodID == filter) { result.Add(row); } } return(result); }
public (Token, string) Parse(string input) { // Get ident pieces var firstChar = new SelectFrom { new Alpha(), new Char('_') }.Parse(input); var followingChars = new Maybe( new Many( new SelectFrom { new Alpha(), new Char('_'), new Digit() } ) ).Parse(firstChar.Item2); // Combine var ident = firstChar.Item1; if (followingChars.Item1.type != TokenType.Failure) { ident += followingChars.Item1; } ident.type = TokenType.Ident; // No keywords as identifiers if (ParserSettings.Keywords.Contains(ident.source)) { throw new UnexpectedTypeException(Types()); } return(ident, followingChars.Item2); }
public WhereInSubqueryClause(ScopedAttribute attribute, SelectFrom subSelect, bool negate = false) { _attribute = attribute; _attrName = attribute.ColumnName; _subSelect = subSelect; _negate = negate; }
public void ConfirmFormCityDidntExist() { SelectFrom.Click(); InpSelectFrom.SendKeys(Guid.NewGuid().ToString()); Assert.AreEqual(SelectFormResultItem.Text, "Совпадений не найдено"); }
public IWebElement SelectFromCity(string cityName) { SelectFrom.Click(); InpSelectCity.SendKeys(cityName); return(SelectFormResultItem); }
public void OnReleaseComplete(ICADocument doc, OnReleaseCompleteDelegate baseMethod) { CAAdj cAAdj = doc as CAAdj; if (TWNGUIValidation.ActivateTWGUI(Base) == true && cAAdj != null && cAAdj.Released == true && cAAdj.AdjTranType == CATranType.CAAdjustment) { TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>(); PXSelectBase <TWNManualGUIBank> ViewManGUIBank = new SelectFrom <TWNManualGUIBank> .Where <TWNManualGUIBank.adjRefNbr.IsEqual <@P.AsString> > .View(Base); foreach (TWNManualGUIBank manualGUIBank in ViewManGUIBank.Cache.Cached) { if (PXCache <Tax> .GetExtension <TaxExt>(Tax.PK.Find(Base, manualGUIBank.TaxID)).UsrTWNGUI.Equals(false)) { continue; } using (PXTransactionScope ts = new PXTransactionScope()) { rp.CreateGUITrans(new STWNGUITran() { VATCode = manualGUIBank.VATInCode, GUINbr = manualGUIBank.GUINbr, GUIStatus = TWNGUIStatus.Used, BranchID = Base.CATranCashTrans_Ordered.Current.BranchID, GUIDirection = TWNGUIDirection.Receipt, GUIDate = manualGUIBank.GUIDate, GUITitle = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank, typeof(APRegister.vendorID).Name, manualGUIBank.VendorID, typeof(Vendor.acctName).Name), TaxZoneID = manualGUIBank.TaxZoneID, TaxCategoryID = manualGUIBank.TaxCategoryID, TaxID = manualGUIBank.TaxID, TaxNbr = manualGUIBank.TaxNbr, OurTaxNbr = manualGUIBank.OurTaxNbr, NetAmount = manualGUIBank.NetAmt, TaxAmount = manualGUIBank.TaxAmt, AcctCD = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank, typeof(APRegister.vendorID).Name, manualGUIBank.VendorID, typeof(Vendor.acctCD).Name), AcctName = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank, typeof(APRegister.vendorID).Name, manualGUIBank.VendorID, typeof(Vendor.acctName).Name), DeductionCode = manualGUIBank.Deduction, Remark = manualGUIBank.Remark, OrderNbr = manualGUIBank.AdjRefNbr }); ts.Complete(Base); } } } baseMethod(doc); }
public void SelectCity(string cityName) { SelectFrom.Click(); InpSelectFrom.SendKeys(cityName); Assert.AreEqual(SelectFormResultItem.Text, cityName); SelectFormResultItem.Click(); }
public override IProgramPart VisitBasicSelect(FSQLParser.BasicSelectContext context) { var attributes = Visit(context.attributes) as ProgramPartList <ScopedAttribute>; var source = Visit(context.sources) as Source; var whereClause = context.where != null?Visit(context.where) as WhereClauseBase : new NullWhereClause(); var select = new SelectFrom(attributes, source, whereClause); return(select); }
public void Select() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>(); var gen = b.GetSqlText(); var spec = "SELECT * FROM [WH].[DeliveryNote] AS [T0]"; Assert.Equal(spec, gen); }
public void Join() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>().Join <Supplier>((d, s) => d.SupplierId == s.Id); var gen = b.GetSqlText(); var spec = "SELECT * FROM [WH].[DeliveryNote] AS [T0] INNER JOIN [WH].[Supplier] AS [T1] ON ([T0].[SupplierId] = [T1].[Id])"; Assert.Equal(spec, gen); }
public void SelectProjection() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>().Select(d => new { TotalAmount = d.TotalAmount, SupplierName = d.Number }); var gen = b.GetSqlText(); var spec = "SELECT [T0].[TotalAmount] AS TotalAmount, [T0].[Number] AS SupplierName FROM [WH].[DeliveryNote] AS [T0]"; Assert.Equal(spec, gen); }
public void Where() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>().Where(d => d.TotalAmount > 100 && d.Year == "2017"); var gen = b.GetSqlText(); var spec = "SELECT * FROM [WH].[DeliveryNote] AS [T0] WHERE (([T0].[TotalAmount] > @SqlParam0) AND ([T0].[Year] = @SqlParam1))"; Assert.Equal(spec, gen); }
public TokenParserResults Parse(ParseArgs <SelectStatement> parseArgs) { var selectStatement = parseArgs.Statement; var args = parseArgs.StatementArgs; var results = new TokenParserResults(); var words = ParserUtils.GetWords(args).ToList(); if (words.Any()) { var columns = ParserUtils.SplitTokens(words); foreach (var wordList in columns) { SelectFromBase selectFrom = null; var startWord = wordList[0]; if (wordList.Count > 3) { results.Errors.Add(new SqlStatementError("Unknown tokens", 0)); return(results); } else if (wordList.Count == 3) { if (wordList[1] != "as") { results.Errors.Add(new SqlStatementError("Expecting 'As' keyword", 0)); return(results); } selectFrom = new SelectFrom(startWord, wordList[2]); } else if (wordList.Count == 2) { selectFrom = new SelectFrom(startWord, wordList[1]); } else { selectFrom = new SelectFrom(startWord); } if (selectFrom != null) { selectStatement.From.Add(selectFrom); } } } return(results); }
public void SelectWithDefaultSchema() { Modeling.ResetModeling(); Modeling.DefaultSchema = "DBO"; Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>(); var gen = b.GetSqlText(); var spec = "SELECT * FROM [DBO].[DeliveryNote] AS [T0]"; Assert.Equal(spec, gen); }
public void OrderBy() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>() .OrderBy(d => d.SupplierId).ThenByDescending(d => d.Date); var gen = b.GetSqlText(); var spec = "SELECT * FROM [WH].[DeliveryNote] AS [T0] ORDER BY [T0].[SupplierId] ASC, [T0].[Date] DESC"; Assert.Equal(spec, gen); }
public void GroupBy() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>() .GroupBy(d => new { d.SupplierId, d.Year }) .Select(g => new { Supplier = g.SupplierId, Year = g.Year, TotalAmount = DbFunctions.Sum(g.TotalAmount) }); var gen = b.GetSqlText(); var spec = "SELECT [T0].[SupplierId] AS Supplier, [T0].[Year] AS Year, SUM([T0].[TotalAmount]) AS TotalAmount FROM [WH].[DeliveryNote] AS [T0] GROUP BY [T0].[SupplierId], [T0].[Year]"; Assert.Equal(spec, gen); }
public (Token, string) Parse(string input) { var defKeyword = new Word("def").Parse(input); var sp1 = new SkipWhitespace().Parse(defKeyword.Item2); var fnKeyword = new Word("fn").Parse(sp1.Item2); var sp2 = new SkipWhitespace().Parse(fnKeyword.Item2); var name = new Ident().Parse(sp2.Item2); var sp8 = new SkipWhitespace().Parse(name.Item2); var lpar = new Char('(').Parse(sp8.Item2); var sp3 = new SkipWhitespace().Parse(lpar.Item2); var argList = new Maybe(new TypeArgList()).Parse(sp3.Item2); var sp4 = new SkipWhitespace().Parse(argList.Item2); var rpar = new Char(')').Parse(sp4.Item2); var sp5 = new SkipWhitespace().Parse(rpar.Item2); var retType = new SelectFrom { new TypeName(), new Word("void") }.Parse(sp5.Item2); var sp6 = new SkipWhitespace().Parse(retType.Item2); var newLine = new Many(new Char('\n')).Parse(sp6.Item2); var stmts = new Maybe( new Many( new Create(TokenType.Node) { new SkipWhitespace(), new Statement(), new SkipWhitespace(), new Many(new Char('\n')) } ) ).Parse(newLine.Item2); var sp7 = new SkipWhitespace().Parse(stmts.Item2); var endKeyword = new Word("end").Parse(sp7.Item2); var funcDef = defKeyword.Item1 + fnKeyword.Item1 + name.Item1 + lpar.Item1; if (argList.Item1.type != TokenType.Failure) { funcDef += argList.Item1; } funcDef += rpar.Item1; if (stmts.Item1.type != TokenType.Failure) { funcDef += stmts.Item1; } funcDef += endKeyword.Item1; funcDef.type = TokenType.FuncDef; return(funcDef, endKeyword.Item2); }
protected virtual void _(Events.FieldDefaulting <INRelatedInventory, INRelatedInventory.rank> e) { var relation = e.Row?.Relation; if (relation == null) { return; } INRelatedInventory maxRankedRelation = new SelectFrom <INRelatedInventory> .Where <INRelatedInventory.inventoryID.IsEqual <InventoryItem.inventoryID.FromCurrent> .And <INRelatedInventory.relation.IsEqual <@P.AsString> > > .OrderBy <INRelatedInventory.rank.Desc> .View(Base).SelectWindowed(0, 1, relation); e.NewValue = (maxRankedRelation?.Rank ?? 0) + 1; }
public (Token, string) Parse(string input) { // Member access pieces var name = new Ident().Parse(input); var colon = new Char(':').Parse(name.Item2); var member = new SelectFrom { new MemberAcc(), new Ident() }.Parse(colon.Item2); // Combine var memberAcc = name.Item1 + colon.Item1 + member.Item1; memberAcc.type = TokenType.MemberAccess; return(memberAcc, member.Item2); }
public (Token, string) Parse(string input) { // Parse float items var sign = new Maybe( new SelectFrom { new Char('+'), new Char('-') } ).Parse(input); var natNum = new SelectFrom { new Create(TokenType.Float) { new Many(new Digit()), new Char('.'), new Many(new Digit()) }, new Create(TokenType.Float) { new Char('.'), new Many(new Digit()) }, new Create(TokenType.Float) { new Many(new Digit()), new Char('.') } }.Parse(sign.Item2); var expon = new Maybe( new Create(TokenType.Node) { new Char('e'), new Integer() } ).Parse(natNum.Item2); // Combine var flt = natNum.Item1; if (sign.Item1.type != TokenType.Failure) { flt = sign.Item1 + flt; } if (expon.Item1.type != TokenType.Failure) { flt += expon.Item1; } flt.type = TokenType.Float; return(flt, expon.Item2); }
protected virtual ICollection <INCostStatus> LoadCostStatuses(INUpdateStdCostRecord stdCostRecord) { var cmd = new SelectFrom <INCostStatus> .InnerJoin <INItemSite> .On <INCostStatus.FK.CostItemSite .And <INCostStatus.inventoryID.IsEqual <INUpdateStdCostRecord.inventoryID.FromCurrent> > > .Where <INCostStatus.costSiteID.IsEqual <INUpdateStdCostRecord.siteID.FromCurrent> .Or <INUpdateStdCostRecord.stdCostOverride.FromCurrent.IsEqual <False> .And <INUpdateStdCostRecord.pendingStdCostReset.FromCurrent.IsEqual <False> .And <INItemSite.stdCostOverride.IsEqual <False> .And <INItemSite.pendingStdCostReset.IsEqual <False> > > > > >(); var view = TypedViews.GetView(cmd, false); var costStatuses = view.SelectMultiBound(new object[] { stdCostRecord }).RowCast <INCostStatus>().ToArray(); return(costStatuses.Select(x => (Layer: x, Site: INSite.PK.Find(this, x.CostSiteID))) .OrderBy(x => x.Site.BranchID) .Select(x => x.Layer).ToArray()); }
public void JoinWithMultipleSelect() { ExpressionsTests.SetModeling(); Configuration.SetDialect(new TestDialect()); var b = new SelectFrom <DeliveryNote>() .Join <Supplier>((d, s) => d.SupplierId == s.Id) .Select((d, s) => d.Number + s.Name) .GroupBy((d, s) => d.Number + s.Name) .Join <User>((s, u) => s.CreatedBy == u.Id) .Select((s, u) => new { UserName = u.Name }) .Select((s, u) => DbFunctions.Count(u.Name)) .GroupBy((s, u) => u.Name) .OrderBy((s, u) => u.Name) .Having((s, u) => DbFunctions.Count(u.Name) > 1); var gen = b.GetSqlText(); var spec = "SELECT ([T0].[Number] + [T1].[Name]), [T2].[Name] AS UserName, COUNT([T2].[Name]) FROM [WH].[DeliveryNote] AS [T0] INNER JOIN [WH].[Supplier] AS [T1] ON ([T0].[SupplierId] = [T1].[Id]) INNER JOIN [LoB].[SecurityProfile] AS [T2] ON ([T1].[CreatedBy_Id] = [T2].[Id]) GROUP BY ([T0].[Number] + [T1].[Name]), [T2].[Name] HAVING (COUNT([T2].[Name]) > @SqlParam0) ORDER BY [T2].[Name] ASC"; Assert.Equal(spec, gen); }
protected virtual void MarkAs(PXCache cache, CRActivity row, Guid UserID, int status) { if (IsImport || row.NoteID == null) { return; } var epviewSelect = new SelectFrom <EPView> .Where <EPView.noteID.IsEqual <@P.AsGuid> .And <EPView.userID.IsEqual <@P.AsGuid> > > .View(this); EPView epview = epviewSelect .Select(row.NoteID, UserID) .FirstOrDefault(); bool dirty = EPViews.Cache.IsDirty; if (epview == null) { var epView = EPViews.Cache.Insert( new EPView { NoteID = row.NoteID, UserID = UserID, Status = status, } ); EPViews.Cache.PersistInserted(epView); epviewSelect.View.Clear(); EPViews.Cache.SetStatus(epView, PXEntryStatus.Notchanged); } else if (status != epview.Status) { epview.Status = status; EPViews.Cache.PersistUpdated(epview); } EPViews.Cache.IsDirty = dirty; }
protected virtual IEnumerable <INItemSiteHistDay> GetLastRows(INSiteStatus siteStatus, decimal deadStockQty, INItemSiteHistDay currentRow) { const int MaxRows = 1000; var getRows = new SelectFrom <INItemSiteHistDay> .Where <INItemSiteHistDay.siteID.IsEqual <@P.AsInt> .And <INItemSiteHistDay.inventoryID.IsEqual <@P.AsInt> > .And <INItemSiteHistDay.subItemID.IsEqual <@P.AsInt> > .And <INItemSiteHistDay.sDate.IsLess <@P.AsDateTime> > .And <INItemSiteHistDay.qtyDebit.IsGreater <decimal0> > > .OrderBy <INItemSiteHistDay.sDate.Desc> .View.ReadOnly(this); DateTime?lastDate = currentRow.SDate; decimal deadStockQtyCounter = deadStockQty; yield return(currentRow); while (lastDate != null && deadStockQtyCounter > 0m) { // Acuminator disable once PX1015 IncorrectNumberOfSelectParameters It's acuminator issue: see jira ATR-600 PXResultset <INItemSiteHistDay> rows = getRows.SelectWindowed(0, MaxRows, siteStatus.SiteID, siteStatus.InventoryID, siteStatus.SubItemID, lastDate); lastDate = null; foreach (var row in rows) { INItemSiteHistDay newRow = row; yield return(newRow); lastDate = newRow.SDate; deadStockQtyCounter -= newRow.QtyDebit ?? 0m; if (deadStockQtyCounter <= 0m) { break; } } } }
public (Token, string) Parse(string input) { var mutKeyword = new Maybe(new Word("mut")).Parse(input); var sp1 = new SkipWhitespace().Parse(mutKeyword.Item2); var baseTypeName = new SelectFrom { new Create(TokenType.TypeName) { new Word("fn"), new SkipWhitespace(), new Char('('), new SkipWhitespace(), new TypeList(), new SkipWhitespace(), new Char(')'), new SkipWhitespace(), new TypeName() }, new Word("int"), new Word("float"), new Word("str"), new Ident(), new Create(TokenType.TypeName) { new Char('('), new SkipWhitespace(), new TypeName(), new SkipWhitespace(), new Char(')') }, new Create(TokenType.TypeName) { new Char('['), new SkipWhitespace(), new TypeName(), new SkipWhitespace(), new Char(']') } }.Parse(sp1.Item2); var typeName = baseTypeName.Item1; if (mutKeyword.Item1.type != TokenType.Failure) { typeName = mutKeyword.Item1 + typeName; } typeName.type = TokenType.TypeName; return(typeName, baseTypeName.Item2); }
public (Token, string) Parse(string input) { var stmt = new SelectFrom { new Declaration(), new Assignment(), new Return(), new Expr() }.Parse(input); var secondary = new Maybe( new Create(TokenType.Node) { new SkipWhitespace(), new Char(';'), new SkipWhitespace(), new Statement() } ).Parse(stmt.Item2); var finalStmt = stmt.Item1; if (secondary.Item1.type != TokenType.Failure) { finalStmt += secondary.Item1; finalStmt.type = TokenType.Statement; } return(finalStmt, secondary.Item2); }
public virtual IEnumerable Storages() { var result = new PXDelegateResult(); result.IsResultSorted = true; result.IsResultTruncated = Filter.Current.ExpandByLotSerialNbr == false; PXSelectBase <StoragePlaceStatus> byLocationSelect = new SelectFrom <StoragePlaceStatus> .Where < StoragePlaceFilter.siteID.FromCurrent.NoDefault.IsEqual <StoragePlaceStatus.siteID> .And <StoragePlaceStatus.qty.IsGreater <Zero> > .And < Not <FeatureInstalled <FeaturesSet.wMSCartTracking> > .Or <StoragePlaceFilter.showLocations.FromCurrent.NoDefault.IsEqual <True> > .And <StoragePlaceStatus.isCart.IsEqual <False> > .Or <StoragePlaceFilter.showCarts.FromCurrent.NoDefault.IsEqual <True> > .And <StoragePlaceStatus.isCart.IsEqual <True> > > > .AggregateTo < GroupBy <StoragePlaceStatus.siteCD>, GroupBy <StoragePlaceStatus.storageCD>, GroupBy <StoragePlaceStatus.isCart>, GroupBy <StoragePlaceStatus.active>, GroupBy <StoragePlaceStatus.inventoryCD>, GroupBy <StoragePlaceStatus.subItemID>, Sum <StoragePlaceStatus.qty> > .OrderBy < StoragePlaceStatus.isCart.Asc, StoragePlaceStatus.siteCD.Asc, StoragePlaceStatus.storageCD.Desc, StoragePlaceStatus.active.Desc, StoragePlaceStatus.inventoryCD.Asc, StoragePlaceStatus.subItemID.Asc, StoragePlaceStatus.qty.Desc> .View(this); if (Filter.Current.StorageID != null) { byLocationSelect.WhereAnd <Where <StoragePlaceFilter.storageID.FromCurrent.IsEqual <StoragePlaceStatus.storageID> > >(); } if (Filter.Current.InventoryID != null) { byLocationSelect.WhereAnd <Where <StoragePlaceFilter.inventoryID.FromCurrent.IsEqual <StoragePlaceStatus.inventoryID> > >(); } if (Filter.Current.SubItemID != null) { byLocationSelect.WhereAnd <Where <StoragePlaceFilter.subItemID.FromCurrent.IsEqual <StoragePlaceStatus.subItemID> > >(); } int startRow = PXView.StartRow; int totalRows = 0; var byLocation = Filter.Current.ExpandByLotSerialNbr == true ? byLocationSelect.SelectMain() : byLocationSelect.View.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows).RowCast <StoragePlaceStatus>().ToArray(); if (byLocation.Length > 0 && Filter.Current.ExpandByLotSerialNbr == true) { PXSelectBase <StoragePlaceStatusExpanded> byLotSerialSelect = new SelectFrom <StoragePlaceStatusExpanded> .Where < StoragePlaceFilter.siteID.FromCurrent.NoDefault.IsEqual <StoragePlaceStatusExpanded.siteID> .And <StoragePlaceStatusExpanded.qty.IsGreater <Zero> > > .AggregateTo < GroupBy <StoragePlaceStatusExpanded.siteCD>, GroupBy <StoragePlaceStatusExpanded.storageCD>, GroupBy <StoragePlaceStatusExpanded.active>, GroupBy <StoragePlaceStatusExpanded.inventoryCD>, GroupBy <StoragePlaceStatusExpanded.subItemID>, GroupBy <StoragePlaceStatusExpanded.lotSerialNbr>, Sum <StoragePlaceStatusExpanded.qty> > .OrderBy < StoragePlaceStatusExpanded.siteCD.Asc, StoragePlaceStatusExpanded.storageCD.Desc, StoragePlaceStatusExpanded.active.Desc, StoragePlaceStatusExpanded.inventoryCD.Asc, StoragePlaceStatusExpanded.subItemID.Asc, StoragePlaceStatusExpanded.lotSerialNbr.Asc, StoragePlaceStatusExpanded.qty.Desc> .View(this); if (Filter.Current.StorageID != null) { byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.storageID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.storageID> > >(); } if (Filter.Current.InventoryID != null) { byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.inventoryID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.inventoryID> > >(); } if (Filter.Current.SubItemID != null) { byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.subItemID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.subItemID> > >(); } if (Filter.Current.LotSerialNbr != null) { byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.lotSerialNbr.FromCurrent.IsEqual <StoragePlaceStatusExpanded.lotSerialNbr> > >(); } var byLotSerial = byLotSerialSelect .SelectMain() .Select( r => new StoragePlaceStatus { SplittedIcon = r.SplittedIcon, SiteID = r.SiteID, SiteCD = r.SiteCD, LocationID = r.LocationID, CartID = null, StorageID = r.StorageID, StorageCD = r.StorageCD, Descr = r.Descr, IsCart = false, Active = r.Active, InventoryID = r.InventoryID, InventoryCD = r.InventoryCD, SubItemID = r.SubItemID, LotSerialNbr = r.LotSerialNbr, ExpireDate = r.ExpireDate, Qty = r.Qty, BaseUnit = r.BaseUnit }) .ToArray(); if (byLotSerial.Length > 0) { int locationIdx = 1; int lotSerIdx = 0; StoragePlaceStatus current = byLocation[0]; result.Add(current); while (locationIdx < byLocation.Length || lotSerIdx < byLotSerial.Length) { if (locationIdx >= byLocation.Length || lotSerIdx < byLotSerial.Length && current.SiteID == byLotSerial[lotSerIdx].SiteID && current.StorageID == byLotSerial[lotSerIdx].StorageID && current.InventoryID == byLotSerial[lotSerIdx].InventoryID && current.SubItemID == byLotSerial[lotSerIdx].SubItemID) { result.Add(byLotSerial[lotSerIdx]); lotSerIdx++; } else { current = byLocation[locationIdx]; result.Add(current); locationIdx++; } } } else { result.AddRange(byLocation); } } else { result.AddRange(byLocation); } PXView.StartRow = 0; return(result); }