/// <summary>
        /// Returns the priority of the Schedule depending on its Time Restrictions or Route information.
        /// </summary>
        public static Schedule.ScheduleGenerationPriority SetSchedulePriority(Schedule schedule, PXGraph graph)
        {
            var fsContractScheduleSet = PXSelectJoin <FSContractSchedule,
                                                      LeftJoin <
                                                          FSScheduleRoute,
                                                          On <FSScheduleRoute.scheduleID, Equal <FSContractSchedule.scheduleID> > >,
                                                      Where <
                                                          FSContractSchedule.entityID, Equal <Required <FSContractSchedule.entityID> > > >
                                        .Select(graph, schedule.EntityID);

            foreach (PXResult <FSContractSchedule, FSScheduleRoute> bqlResult in fsContractScheduleSet)
            {
                FSContractSchedule fsContractScheduleRow = (FSContractSchedule)bqlResult;
                FSScheduleRoute    fsScheduleRouteRow    = (FSScheduleRoute)bqlResult;

                if (fsContractScheduleRow.RestrictionMax == true || fsContractScheduleRow.RestrictionMin == true)
                {
                    return(Schedule.ScheduleGenerationPriority.TimeRestriction);
                }
                else if (fsScheduleRouteRow.DfltRouteID != null)
                {
                    return(Schedule.ScheduleGenerationPriority.Sequence);
                }
            }

            return(Schedule.ScheduleGenerationPriority.Nothing);
        }
        protected virtual void FSContractSchedule_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSContractSchedule fsContractScheduleRow = (FSContractSchedule)e.Row;

            SharedFunctions.ShowWarningScheduleNotProcessed(cache, fsContractScheduleRow);
        }
        protected virtual void _(Events.RowSelected <FSContractSchedule> e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSContractSchedule fsContractScheduleRow = (FSContractSchedule)e.Row;

            SharedFunctions.ShowWarningScheduleNotProcessed(e.Cache, fsContractScheduleRow);
        }
        public override void AddSchedule()
        {
            var graphServiceContractScheduleEntry    = PXGraph.CreateInstance <ServiceContractScheduleEntry>();
            FSContractSchedule fsContractScheduleRow = new FSContractSchedule()
            {
                CustomerID      = ServiceContractRecords.Current.CustomerID,
                EntityID        = ServiceContractRecords.Current.ServiceContractID,
                ScheduleGenType = ServiceContractRecords.Current.ScheduleGenType
            };

            graphServiceContractScheduleEntry.ContractScheduleRecords.Insert(fsContractScheduleRow);

            throw new PXRedirectRequiredException(graphServiceContractScheduleEntry, null)
                  {
                      Mode = PXBaseRedirectException.WindowMode.NewWindow
                  };
        }
Example #5
0
        /// <summary>
        /// Allows to calculate the <c>RefNbr</c> sequence when trying to insert a new register.
        /// </summary>
        protected override bool SetRefNbr(PXCache cache, object row)
        {
            FSContractSchedule fsContractScheduleRow = (FSContractSchedule)row;

            if (fsContractScheduleRow.EntityID == null)
            {
                return(false);
            }

            FSServiceContract fsServiceContractRow = ServiceContractCore.ServiceContract_View.Select(cache.Graph, fsContractScheduleRow.EntityID);

            if (fsServiceContractRow == null)
            {
                return(false);
            }

            FSContractSchedule fsContractScheduleRow_tmp = PXSelectReadonly <FSContractSchedule,
                                                                             Where <
                                                                                 FSContractSchedule.entityID, Equal <Current <FSContractSchedule.entityID> >,
                                                                                 And <FSContractSchedule.entityType, Equal <FSContractSchedule.entityType.Contract> > >,
                                                                             OrderBy <
                                                                                 Desc <FSContractSchedule.scheduleID> > >
                                                           .SelectWindowed(cache.Graph, 0, 1);

            string refNbr = string.Empty;

            if (fsContractScheduleRow_tmp != null &&
                fsContractScheduleRow_tmp.RefNbr != null)
            {
                refNbr = fsContractScheduleRow_tmp.RefNbr;
            }

            if (refNbr.LastIndexOf("<NEW>") != -1)
            {
                refNbr = string.Empty;
            }

            fsContractScheduleRow.RefNbr = SharedFunctions.GetNextRefNbr(fsServiceContractRow.RefNbr, refNbr);

            return(true);
        }