protected virtual void CSBox_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { CSBox box = (CSBox)e.Row; var openShipments = PXSelectJoinGroupBy <SOShipment, InnerJoin <SOPackageDetail, On <SOPackageDetail.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, Where <SOPackageDetail.boxID, Equal <Required <CSBox.boxID> >, And <SOShipment.released, NotEqual <True> > >, Aggregate <GroupBy <SOShipment.shipmentNbr> > > .SelectWindowed(this, 0, 10, box.BoxID).RowCast <SOShipment>().ToList(); if (openShipments.Any()) { throw new PXException(Messages.BoxUsedInShipments, string.Join(", ", openShipments.Select(_ => _.ShipmentNbr).Distinct())); } var openOrders = PXSelectJoinGroupBy <SOOrder, InnerJoin <SOPackageInfo, On <SOPackageInfo.FK.Order> >, Where <SOPackageInfo.boxID, Equal <Required <CSBox.boxID> >, And <SOOrder.completed, NotEqual <True>, And <SOOrder.cancelled, NotEqual <True> > > >, Aggregate <GroupBy <SOOrder.orderType, GroupBy <SOOrder.orderNbr> > > > .SelectWindowed(this, 0, 10, box.BoxID).RowCast <SOOrder>().ToList(); if (openOrders.Any()) { var ordersString = new StringBuilder(); openOrders.ForEach(_ => ordersString.AppendFormat("{0} {1}, ", _.OrderType, _.OrderNbr)); ordersString.Remove(ordersString.Length - 2, 2); throw new PXException(Messages.BoxUsedInOrders, ordersString); } }
protected virtual void _(Events.FieldSelecting <POOrderPrepayment.statusText> e) { if (Base.Document.Current == null || e.Row == null) { return; } var query = new PXSelectJoinGroupBy <POOrderPrepayment, InnerJoin <APRegister, On <APRegister.docType, Equal <POOrderPrepayment.aPDocType>, And <APRegister.refNbr, Equal <POOrderPrepayment.aPRefNbr> > > >, Where <POOrderPrepayment.orderType, Equal <Current <POOrder.orderType> >, And <POOrderPrepayment.orderNbr, Equal <Current <POOrder.orderNbr> > > >, Aggregate <Sum <POOrderPrepayment.curyAppliedAmt, Sum <APRegister.curyDocBal> > > >(Base); using (new PXFieldScope(query.View, typeof(POOrderPrepayment.orderType), typeof(POOrderPrepayment.orderNbr), typeof(POOrderPrepayment.aPDocType), typeof(POOrderPrepayment.aPRefNbr), typeof(APRegister.docType), typeof(APRegister.refNbr), typeof(POOrderPrepayment.curyAppliedAmt), typeof(APRegister.curyDocBal))) { var prepaymentTotal = (PXResult <POOrderPrepayment, APRegister>)query.SelectWindowed(0, 1); e.ReturnValue = PXMessages.LocalizeFormatNoPrefix(Messages.StatusTotalPrepayments, Base.FormatQty(((POOrderPrepayment)prepaymentTotal)?.CuryAppliedAmt ?? 0), Base.FormatQty(((APRegister)prepaymentTotal)?.CuryDocBal ?? 0)); } }
protected virtual void MISC1099EFileFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { var rowfilter = e.Row as MISC1099EFileFilter; if (rowfilter == null) { return; } Records.SetProcessDelegate( delegate(List <MISC1099EFileProcessingInfo> list) { MISC1099EFileProcessing graph = CreateInstance <MISC1099EFileProcessing>(); graph.Process(list, rowfilter); }); if (rowfilter.Include == MISC1099EFileFilter.include.AllMarkedBranches) { List <string> uncheckedBranches = PXSelectJoinGroupBy <Branch, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <Branch.ledgerID> >, InnerJoin <AP1099History, On <Branch.branchID, Equal <AP1099History.branchID> > > >, Where2 < Where2 <Not <FeatureInstalled <FeaturesSet.branch> >, Or2 <IsSingleBranchCompany, Or <Ledger.defBranchID, IsNull, Or <Ledger.defBranchID, Equal <Branch.branchID> > > > >, And2 <Where <Branch.reporting1099, NotEqual <True>, Or <Branch.reporting1099, IsNull> >, And <MatchWithBranch <Branch.branchID> > > >, Aggregate <GroupBy <Branch.branchCD> > > .SelectWindowed(this, 0, 10) .RowCast <Branch>() .Select(branch => branch.BranchCD) .ToList(); uncheckedBranches.AddRange(PXSelectJoinGroupBy <Branch, InnerJoin <Ledger, On <Ledger.defBranchID, Equal <Branch.branchID> >, InnerJoin <BranchAlias, On <Ledger.ledgerID, Equal <BranchAlias.ledgerID> >, InnerJoin <AP1099History, On <BranchAlias.branchID, Equal <AP1099History.branchID> > > > >, Where2 <Where <Branch.reporting1099, NotEqual <True>, Or <Branch.reporting1099, IsNull> >, And <MatchWithBranch <Branch.branchID> > >, Aggregate <GroupBy <Branch.branchCD> > > .SelectWindowed(this, 0, 10) .RowCast <Branch>() .Select(branch => branch.BranchCD)); string branches = (uncheckedBranches.Count > 10 ? uncheckedBranches.GetRange(0, 10) : uncheckedBranches).JoinToString(", "); sender.RaiseExceptionHandling <MISC1099EFileFilter.include>(rowfilter, rowfilter.Include, !string.IsNullOrEmpty(branches) ? new PXSetPropertyException(Messages.Unefiled1099Branches, PXErrorLevel.Warning, branches) : null); } else { sender.RaiseExceptionHandling <MISC1099EFileFilter.include>(rowfilter, rowfilter.Include, null); } }
protected virtual void MISC1099EFileFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { MISC1099EFileFilter rowfilter = e.Row as MISC1099EFileFilter; if (rowfilter == null) { return; } Records.SetProcessDelegate( delegate(List <MISC1099EFileProcessingInfo> list) { MISC1099EFileProcessing graph = CreateInstance <MISC1099EFileProcessing>(); graph.Process(list, rowfilter); }); if (rowfilter.Include == MISC1099EFileFilter.include.AllMarkedOrganizations) { string unmarkedOrganizations = PXSelectJoinGroupBy <Organization, InnerJoin <Branch, On <Organization.organizationID, Equal <Branch.organizationID> > >, Where2 <Where <Organization.reporting1099, NotEqual <True>, Or <Organization.reporting1099, IsNull> >, And <MatchWithBranch <Branch.branchID> > >, Aggregate <GroupBy <Organization.organizationID> > > .SelectWindowed(this, 0, 10) .RowCast <Organization>() .Select(organization => organization.OrganizationCD) .JoinToString(", "); sender.RaiseExceptionHandling <MISC1099EFileFilter.include>(rowfilter, rowfilter.Include, !string.IsNullOrEmpty(unmarkedOrganizations) ? new PXSetPropertyException(Messages.Unefiled1099Organizations, PXErrorLevel.Warning, unmarkedOrganizations) : null); } else { sender.RaiseExceptionHandling <MISC1099EFileFilter.include>(rowfilter, rowfilter.Include, null); } }