public virtual void CROpportunityProbability_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { if (!e.ExternalCall) { return; } CROpportunityProbability probability = e.Row as CROpportunityProbability; if (probability == null) { return; } // checking if the opportunities with such class exist Standalone.CROpportunity opp = PXSelect <Standalone.CROpportunity, Where <Standalone.CROpportunity.stageID, Equal <Required <CROpportunityProbability.stageCode> > > > . SelectWindowed(this, 0, 1, probability.StageCode); if (opp != null) { throw new PXException(Messages.StageCannotBeDeleted, probability.Name); } // checking if another classes with such state exists List <string> classesWithActiveProbability = new List <string>(); foreach (CROpportunityClassProbability activeProbabilityInAnotherClass in PXSelect <CROpportunityClassProbability, Where <CROpportunityClassProbability.stageID, Equal <Required <CROpportunityProbability.stageCode> >, And <CROpportunityClassProbability.classID, NotEqual <Current <CROpportunityClass.cROpportunityClassID> > > > > . Select(this, probability.StageCode)) { classesWithActiveProbability.Add(activeProbabilityInAnotherClass.ClassID); } if (classesWithActiveProbability.Count > 0) { throw new PXException(Messages.StageIsActiveInClasses, string.Join(", ", classesWithActiveProbability)); } // ask before deleting stage - because it is used in every class if (OpportunityProbabilities.Ask(Messages.Warning, Messages.StageWillBeDeletedFromAllClasses, MessageButtons.YesNo, MessageIcon.Warning) != WebDialogResult.Yes) { e.Cancel = true; } }
private void VisibilityHandler(PXCache sender, CRQuote row) { Standalone.CROpportunity opportunity = PXSelect <Standalone.CROpportunity, Where <Standalone.CROpportunity.opportunityID, Equal <Required <Standalone.CROpportunity.opportunityID> > > > .Select(Base, row.OpportunityID).FirstOrDefault(); if (opportunity != null) { bool allowUpdate = row.IsDisabled != true && opportunity.MajorStatus != OpportunityMajorStatusesAttribute._CLOSED; Base.Caches[typeof(CRQuote)].AllowUpdate = allowUpdate; Base.Caches[typeof(CRQuote)].AllowInsert = Base.Caches[typeof(CRQuote)].AllowDelete = opportunity.MajorStatus != OpportunityMajorStatusesAttribute._CLOSED; foreach (var type in new[] { typeof(CROpportunityDiscountDetail), typeof(CROpportunityProducts), typeof(CRTaxTran), typeof(CRAddress), typeof(CRContact) }) { Base.Caches[type].AllowInsert = Base.Caches[type].AllowUpdate = Base.Caches[type].AllowDelete = allowUpdate; } Base.Caches[typeof(CopyQuoteFilter)].AllowUpdate = true; Base.Caches[typeof(RecalcDiscountsParamFilter)].AllowUpdate = true; Base.Actions[nameof(Base.Approval.Submit)] .SetVisible(row.Status == CRQuoteStatusAttribute.Draft); Base.actionsFolder .SetVisible(nameof(Base.Approval.Approve), Base.Actions[nameof(Base.Approval.Approve)].GetVisible()); Base.actionsFolder .SetVisible(nameof(Base.Approval.Reject), Base.Actions[nameof(Base.Approval.Reject)].GetVisible()); Base.Actions[nameof(EditQuote)] .SetVisible(row.Status != CRQuoteStatusAttribute.Draft); Base.Actions[nameof(Base.Approval.Submit)] .SetEnabled(row.Status == CRQuoteStatusAttribute.Draft && opportunity.MajorStatus != OpportunityMajorStatusesAttribute._CLOSED); Base.Actions[nameof(Base.Approval.Approve)] .SetEnabled(row.Status == CRQuoteStatusAttribute.PendingApproval); Base.Actions[nameof(Base.Approval.Reject)] .SetEnabled(row.Status == CRQuoteStatusAttribute.PendingApproval); Base.Actions[nameof(EditQuote)] .SetEnabled(row.Status != CRQuoteStatusAttribute.Draft); Base.Actions[nameof(Base.SendQuote)] .SetEnabled((row.Status == CRQuoteStatusAttribute.Approved || row.Status == CRQuoteStatusAttribute.Sent) && !String.IsNullOrEmpty(row.OpportunityID)); Base.Actions[nameof(Base.PrintQuote)] .SetEnabled((row.Status == CRQuoteStatusAttribute.Approved || row.Status == CRQuoteStatusAttribute.Sent) && !String.IsNullOrEmpty(row.OpportunityID)); Base.Actions[nameof(Base.CopyQuote)] .SetEnabled(Base.Caches[typeof(CRQuote)].AllowInsert); Base.Actions[nameof(Discount.GraphRecalculateDiscountsAction)] .SetEnabled((row.Status == CRQuoteStatusAttribute.Draft) && !String.IsNullOrEmpty(row.OpportunityID)); PXUIFieldAttribute.SetEnabled <CRQuote.subject>(sender, row, true); PXUIFieldAttribute.SetEnabled <CRQuote.status>(sender, row, false); } }