コード例 #1
0
        protected virtual void CRSetup_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            CROpportunityProbability p = OpportunityProbabilities.Select();

            if (p == null)
            {
                p.StageCode   = "A";
                p.Probability = 60;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "L";
                p.Probability = 0;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "P";
                p.Probability = 10;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "Q";
                p.Probability = 20;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "R";
                p.Probability = 80;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "V";
                p.Probability = 40;
                OpportunityProbabilities.Insert(p);
                p.StageCode   = "W";
                p.Probability = 100;
                OpportunityProbabilities.Insert(p);
                OpportunityProbabilities.Cache.IsDirty = false;
            }
        }
コード例 #2
0
        public virtual void CROpportunityProbability_Probability_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CROpportunityProbability probability = e.Row as CROpportunityProbability;

            if (probability.SortOrder == null)
            {
                probability.SortOrder = probability.Probability;
            }
        }
コード例 #3
0
        public virtual void CROpportunityProbability_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CROpportunityProbability probability = e.Row as CROpportunityProbability;

            if (probability == null)
            {
                return;
            }
            bool allowEdit = sender.GetStatus(e.Row) == PXEntryStatus.Inserted || sender.GetStatus(e.Row) == PXEntryStatus.InsertedDeleted;

            PXUIFieldAttribute.SetEnabled <CROpportunityProbability.stageCode>(sender, probability, allowEdit);
        }
コード例 #4
0
        public virtual void CROpportunityProbability_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            CROpportunityProbability probability = e.Row as CROpportunityProbability;

            if (probability == null || OpportunityClass.Current == null)
            {
                return;
            }
            foreach (CROpportunityClassProbability link in PXSelect <CROpportunityClassProbability, Where <CROpportunityClassProbability.stageID, Equal <Required <CROpportunityProbability.stageCode> > > > .Select(this, probability.StageCode))
            {
                OpportunityClassActiveProbabilities.Delete(link);
            }
        }
コード例 #5
0
        public virtual void CROpportunityProbability_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            UpdateOpportunityClassProbability(sender, (CROpportunityProbability)e.Row);

            CROpportunityProbability oldProbability = e.OldRow as CROpportunityProbability;
            CROpportunityProbability newProbability = e.Row as CROpportunityProbability;

            if (newProbability == null || oldProbability == null)
            {
                return;
            }
            if (newProbability.Name != oldProbability.Name || newProbability.Probability != oldProbability.Probability || newProbability.SortOrder != oldProbability.SortOrder)
            {
                OpportunityProbabilities.Cache.RaiseExceptionHandling <CROpportunityProbability.stageCode>(newProbability, newProbability.StageCode, new PXSetPropertyException(Messages.StageWillBeChangedInEveryClass, PXErrorLevel.RowWarning));
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        protected virtual void CROpportunityClass_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            // init default list of opportunity stages
            CROpportunityProbability s = OpportunityProbabilities.Select();

            if (s == null)
            {
                InitOpportunityProbabilities();
            }

            // activate all stages for the first class
            int classesCount = OpportunityClass.Select().Count;

            if (classesCount == 1)
            {
                ActivateAllOpportunityClassProbabilities();
            }
        }
コード例 #8
0
        private void UpdateOpportunityClassProbability(PXCache sender, CROpportunityProbability probability)
        {
            if (OpportunityClass.Current == null)
            {
                return;
            }

            CROpportunityClassProbability link = PXSelect <CROpportunityClassProbability,
                                                           Where <CROpportunityClassProbability.classID, Equal <Current <CROpportunityClass.cROpportunityClassID> >,
                                                                  And <CROpportunityClassProbability.stageID, Equal <Required <CROpportunityProbability.stageCode> > > > > .
                                                 SelectWindowed(this, 0, 1, probability.StageCode);

            if (probability.IsActive == true && link == null)
            {
                CROpportunityClassProbability newLink = OpportunityClassActiveProbabilities.Insert();
                newLink.ClassID = OpportunityClass.Current.CROpportunityClassID;
                newLink.StageID = probability.StageCode;
                OpportunityClassActiveProbabilities.Update(newLink);
            }
            else if (probability.IsActive == false && link != null)
            {
                OpportunityClassActiveProbabilities.Delete(link);
            }
        }