public virtual IEnumerable GenerateWeekCode(PXAdapter adapter)
        {
            if (CalendarWeekCodeGenerationOptions.AskExt() == WebDialogResult.OK)
            {
                if (ValidateEndGenerationDate(CalendarWeekCodeGenerationOptions.Current, CalendarWeekCodeGenerationOptions.Cache) &&
                    ValidateStartGenerationDate(CalendarWeekCodeGenerationOptions.Current, CalendarWeekCodeGenerationOptions.Cache))
                {
                    string message = PXMessages.LocalizeFormat(
                        TX.Messages.ASK_CONFIRM_CALENDAR_WEEKCODE_GENERATION,
                        CalendarWeekCodeGenerationOptions.Current.StartDate.Value.ToShortDateString(),
                        CalendarWeekCodeGenerationOptions.Current.EndDate.Value.ToShortDateString());

                    if (WebDialogResult.OK == CalendarWeekCodeRecords.Ask(
                            TX.WebDialogTitles.CONFIRM_CALENDAR_WEEKCODE_GENERATION,
                            message,
                            MessageButtons.OKCancel))
                    {
                        DateTime baseDate     = CalendarWeekCodeGenerationOptions.Current.DefaultStartDate.Value;
                        DateTime iteratorDate = CalendarWeekCodeGenerationOptions.Current.StartDate.Value;
                        DateTime stopDate     = CalendarWeekCodeGenerationOptions.Current.EndDate.Value;

                        CalendarWeekCodeMaint graphCalendarWeekCodeMaint = PXGraph.CreateInstance <CalendarWeekCodeMaint>();

                        PXLongOperation.StartOperation(
                            this,
                            delegate
                        {
                            while (iteratorDate <= stopDate)
                            {
                                FSWeekCodeDate fsWeekCodeRow = new FSWeekCodeDate();
                                fsWeekCodeRow.WeekCodeDate   = iteratorDate;

                                graphCalendarWeekCodeMaint.AutoCalcWeekCode(baseDate, fsWeekCodeRow);

                                graphCalendarWeekCodeMaint.CalendarWeekCodeRecords.Insert(fsWeekCodeRow);
                                iteratorDate = iteratorDate.AddDays(1);
                            }

                            graphCalendarWeekCodeMaint.Save.Press();
                        });
                    }
                }
                else
                {
                    throw new PXException(TX.Error.INVALID_WEEKCODE_GENERATION_OPTIONS);
                }
            }

            return(adapter.Get());
        }
Beispiel #2
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;
            }
        }
Beispiel #3
0
        public virtual IEnumerable Delete(PXAdapter adapter)
        {
            GLBudgetTree lineCopy = PXCache <GLBudgetTree> .CreateCopy(Details.Current);

            if (Details.Current.IsGroup == true && Details.Current.GroupID != Details.Current.ParentGroupID)
            {
                if (Details.Ask(Messages.BudgetTreeDeleteGroupTitle, Messages.BudgetTreeDeleteGroupMessage, MessageButtons.YesNo) == WebDialogResult.Yes)
                {
                    deleteRecords(Details.Current.GroupID);
                    Details.Cache.Delete(lineCopy);
                }
            }
            else
            {
                Details.Cache.Delete(lineCopy);
            }
            return(adapter.Get());
        }