Пример #1
0
 public void Prefetch(PXGraph parameter)
 {
     _lookup =
         PXSelectOrderBy <TCategory, OrderBy <Asc <INCategory.parentID, Asc <INCategory.sortOrder> > > >
         .Select(parameter)
         .RowCast <TCategory>()
         .ToLookup(r => r.ParentID);
 }
Пример #2
0
    void RenderSiteMap()
    {
        DivGraphs.Visible = true;
        IEnumerable <SiteMap> siteMap = Select <SiteMap>(PXSelectOrderBy <SiteMap, OrderBy <Asc <SiteMap.screenID> > > .Select(new PXGraph()));

        IList <string>        lookup = ToLookup(siteMap);
        IEnumerable <SiteMap> hidden = GetHiddenScreens(lookup);

        HtmlTableBuilder b = new HtmlTableBuilder();

        b.Table = TableGraphs;

        foreach (SiteMap rowSiteMap in Concat(siteMap, hidden))
        {
            b.AddRow();

            b.AddCellHref(rowSiteMap.ScreenID, rowSiteMap.Url);
            b.AddCell(rowSiteMap.Graphtype);

            bool isTypeFound = false;
            if (!String.IsNullOrEmpty(rowSiteMap.Graphtype))
            {
                Type t = BuildManager.GetType(rowSiteMap.Graphtype, false);
                if (t != null)
                {
                    try
                    {
                        string apiGraphName = ServiceManager.GetGraphNameFromType(t);
                        isTypeFound = true;

                        try
                        {
                            //WsdlSchemaBuilder.CreateGraph(t);

                            //Activator.CreateInstance(t);
                            string graphUrl = GetUrl("graph", apiGraphName);
                            b.AddCellHref("Graph" + apiGraphName, graphUrl);
                        }
                        catch
                        {
                            b.AddCell("Graph" + apiGraphName + " - login?");
                        }
                    }
                    catch (ArgumentException) {}
                    catch (KeyNotFoundException) { }
                }
            }
            if (!isTypeFound)
            {
                b.AddCell(null);
                b.Row.Style.Add("display", "none");
            }



            b.AddCell(rowSiteMap.Title);
        }
    }
Пример #3
0
 public static FinPeriod FindLastPeriod(PXGraph graph, bool aClosedOrActive)
 {
     return(aClosedOrActive ? (PXSelect <FinPeriod,
                                         Where <FinPeriod.closed, Equal <True>,
                                                Or <FinPeriod.active, Equal <True> > >,
                                         OrderBy <Desc <FinPeriod.finPeriodID> >
                                         > .SelectWindowed(graph, 0, 1)) : (
                PXSelectOrderBy <FinPeriod, OrderBy <Desc <FinPeriod.finPeriodID> >
                                 > .SelectWindowed(graph, 0, 1)));
 }
		protected virtual void RUTROTWorkType_Position_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
		{
			RUTROTWorkType row = (RUTROTWorkType)e.Row;
			if (row == null)
			{
				return;
			}
			RUTROTWorkType latest = PXSelectOrderBy<RUTROTWorkType, OrderBy<Desc<RUTROTWorkType.position>>>.SelectWindowed(this, 0, 1);
			e.NewValue = latest.Position + 1;
		}
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = CurrentFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID, Greater <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1)
                                            ?? PXSelectOrderBy <FinPeriod,
                                                                OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);

            filter.FinPeriodID = nextperiod?.FinPeriodID;
            return(adapter.Get());
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            AccountByYearFilter filter     = CurrentFilter;
            FinYear             nextperiod = PXSelect <FinYear,
                                                       Where <FinYear.year, Greater <Current <AccountByYearFilter.finYear> > >,
                                                       OrderBy <Asc <FinYear.year> > > .SelectWindowed(this, 0, 1)
                                             ?? PXSelectOrderBy <FinYear,
                                                                 OrderBy <Asc <FinYear.year> > > .SelectWindowed(this, 0, 1);

            filter.FinYear = nextperiod?.Year;
            return(adapter.Get());
        }
Пример #7
0
        protected virtual IEnumerable translationHistoryRecords()
        {
            PXSelectBase <TranslationHistory> cmd;

            TranslationEnqFilter filter = Filter.Current as TranslationEnqFilter;

            this.TranslationHistoryRecords.Cache.AllowInsert = false;
            this.TranslationHistoryRecords.Cache.AllowDelete = false;
            this.TranslationHistoryRecords.Cache.AllowUpdate = false;

            TranslationHistoryRecords.Cache.Clear();

            cmd = new PXSelectOrderBy <TranslationHistory,
                                       OrderBy <Desc <TranslationHistory.finPeriodID,
                                                      Desc <TranslationHistory.translDefId,
                                                            Asc <TranslationHistory.referenceNbr> > > > >(this);

            if (filter.TranslDefId != null)
            {
                cmd.WhereAnd <Where <TranslationHistory.translDefId, Equal <Current <TranslationEnqFilter.translDefId> > > >();
            }

            if (filter.FinPeriodID != null)
            {
                cmd.WhereAnd <Where <TranslationHistory.finPeriodID, Equal <Current <TranslationEnqFilter.finPeriodID> > > >();
            }


            if (filter.Released == false)
            {
                cmd.WhereAnd <Where <TranslationHistory.status, NotEqual <TranslationReleased> > >();
            }

            if (filter.Unreleased == false)
            {
                cmd.WhereAnd <Where <TranslationHistory.status, NotEqual <TranslationUnReleased> > >();
            }

            if (filter.Voided == false)
            {
                cmd.WhereAnd <Where <TranslationHistory.status, NotEqual <TranslationVoided> > >();
            }


            foreach (PXResult <TranslationHistory> thist in cmd.Select())
            {
                yield return(thist);
            }
        }
        protected virtual void EPSetup_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPSetup row = e.Row as EPSetup;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <EPSetup.offBalanceAccountGroupID>(cache, row, row.PostToOffBalance == true);
                if (row.CustomWeek == true)
                {
                    EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

                    PXUIFieldAttribute.SetEnabled <EPSetup.customWeek>(cache, row, lastWeek == null);
                }
            }
        }
        private void InitializePropertyValueView(PXGraph graph)
        {
            //Init PXVirtual Static constructor
            typeof(PropertyValue).GetCustomAttributes(typeof(PXVirtualAttribute), false);

            var propertiesSelect = new PXSelectOrderBy <PropertyValue,
                                                        OrderBy <Asc <PropertyValue.order> > >(graph,
                                                                                               new PXSelectDelegate(() => graph.Caches[typeof(PropertyValue)].Cached.Cast <PropertyValue>().Where(item => item.Hidden != true)));

            graph.Views.Add(PropertiesViewName, propertiesSelect.View);
            if (View.Cache.Fields.Any(o => o.EndsWith("_Attributes")) && !graph.Views.Caches.Contains(typeof(CS.CSAnswers)))
            {
                graph.Views.Caches.Add(typeof(CS.CSAnswers));
            }
        }
        protected virtual void EPCustomWeek_StartDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            EPCustomWeek row = (EPCustomWeek)e.Row;

            if (row == null)
            {
                return;
            }
            // EPCustomWeek lastWeek = PXSelectOrderBy<EPCustomWeek, OrderBy<Desc<EPCustomWeek.weekID>>>.Select(this); //TODO: why dont worked?
            EPCustomWeek lastWeek = PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.year, Desc <EPCustomWeek.number> > > > .SelectSingleBound(this, new object[] { });

            if (lastWeek != null && lastWeek.EndDate != null)
            {
                e.NewValue = GetBeginOfDate(lastWeek.EndDate.Value.AddDays(1d));
            }
        }
Пример #11
0
        protected virtual byte[] CreateExportContents(IEnumerable <DocumentDetails> documents)
        {
            bool isRut = documents.First().Rutrot.RUTROTType == RUTROTTypes.RUT;
            List <RUTROTWorkType> availableWorkTypes = new List <RUTROTWorkType>();

            foreach (RUTROTWorkType workType in PXSelectOrderBy <RUTROTWorkType, OrderBy <Asc <RUTROTWorkType.rUTROTType, Asc <RUTROTWorkType.position> > > > .Select(this))
            {
                if (RUTROTHelper.IsUpToDateWorkType(workType, DateTime.Now))
                {
                    availableWorkTypes.Add(workType);
                }
            }
            var exporter = isRut ? new RUTExport(availableWorkTypes) : new ROTExport(availableWorkTypes);

            return(exporter.Export(documents));
        }
        protected virtual void EPSetup_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPSetup row = e.Row as EPSetup;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <EPSetup.useReceiptAccountForTips>(cache, row, row.NonTaxableTipItem.HasValue);
                PXUIFieldAttribute.SetEnabled <EPSetup.offBalanceAccountGroupID>(cache, row, row.PostingOption == EPPostOptions.PostToOffBalance);
                if (row.CustomWeek == true)
                {
                    EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

                    PXUIFieldAttribute.SetEnabled <EPSetup.customWeek>(cache, row, lastWeek == null);
                }
            }
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            InventoryTranSumEnqFilter filter = Filter.Current as InventoryTranSumEnqFilter;
            FinPeriod nextperiod             = PXSelect <FinPeriod,
                                                         Where <FinPeriod.finPeriodID,
                                                                Greater <Current <InventoryTranSumEnqFilter.finPeriodID> > >,
                                                         OrderBy <Asc <FinPeriod.finPeriodID> >
                                                         > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);
            }
            filter.FinPeriodID = nextperiod.FinPeriodID;
            return(adapter.Get());
        }
Пример #14
0
        protected virtual void EPSetup_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var row = e.Row as EPSetup;

            if (row == null || e.Operation == PXDBOperation.Delete)
            {
                return;
            }
            if (row.PostingOption == EPPostOptions.PostToOffBalance && row.OffBalanceAccountGroupID == null)
            {
                if (cache.RaiseExceptionHandling <EPSetup.offBalanceAccountGroupID>(e.Row, row.OffBalanceAccountGroupID, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <EPSetup.offBalanceAccountGroupID>(cache))))
                {
                    throw new PXRowPersistingException(typeof(EPSetup.offBalanceAccountGroupID).Name, row.OffBalanceAccountGroupID, ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <EPSetup.offBalanceAccountGroupID>(cache));
                }
            }
            if (row.CustomWeek == true)
            {
                DateTime?firstUsing = GetFirstActivityDate();
                DateTime?lastUsing  = GetLasttUsingWeek();

                if (firstUsing != null && lastUsing != null)
                {
                    EPCustomWeek firstWeek = PXSelectOrderBy <EPCustomWeek, OrderBy <Asc <EPCustomWeek.weekID> > > .SelectWindowed(this, 0, 1);

                    EPCustomWeek lastWeek = PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectWindowed(this, 0, 1);

                    foreach (EPCustomWeek week in CustomWeek.Cache.Inserted)
                    {
                        if (lastWeek == null)
                        {
                            lastWeek = week;
                        }

                        if (week.WeekID > lastWeek.WeekID)
                        {
                            lastWeek = week;
                        }
                    }

                    if (firstWeek == null || firstUsing < firstWeek.StartDate || lastWeek == null || lastWeek.EndDate < lastUsing)
                    {
                        throw new PXRowPersistingException(typeof(EPSetup.customWeek).Name, row.CustomWeek, Messages.CustomWeekNotCreated, firstUsing, lastUsing);
                    }
                }
            }
        }
Пример #15
0
        public static FABook FindByBookMarker(PXGraph graph, int marker)
        {
            if (marker == FABook.bookID.Markers.GLBook)
            {
                return(PXSelect <FABook,
                                 Where <FABook.updateGL, Equal <True> > >
                       .Select(graph));
            }

            if (marker == FABook.bookID.Markers.GLOrAnyBook)
            {
                return(PXSelectOrderBy <FABook,
                                        OrderBy <Desc <FABook.updateGL> > >
                       .SelectSingleBound(graph, null));
            }

            throw new NotImplementedException();
        }
        private Dictionary <int, RUTROTWorkType> GetAvailableWorkTypes(PXGraph graph, DateTime?date)
        {
            if (date == null)
            {
                return(null);
            }
            Dictionary <int, RUTROTWorkType> availableWorkTypes = new Dictionary <int, RUTROTWorkType>();

            foreach (RUTROTWorkType workType in PXSelectOrderBy <RUTROTWorkType,
                                                                 OrderBy <Asc <RUTROTWorkType.rUTROTType, Asc <RUTROTWorkType.position> > > > .Select(graph))
            {
                if (RUTROTHelper.IsUpToDateWorkType(workType, date.Value))
                {
                    availableWorkTypes.Add(workType.WorkTypeID.Value, workType);
                }
            }
            return(availableWorkTypes);
        }
        protected virtual void EPCustomWeek_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPCustomWeek row = (EPCustomWeek)e.Row;

            if (row != null)
            {
                EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .Select(this);

                if (lastWeek != null)
                {
                    bool readOnly = lastWeek.WeekID > row.WeekID;
                    PXUIFieldAttribute.SetReadOnly(cache, row, true);
                    PXUIFieldAttribute.SetReadOnly <EPCustomWeek.endDate>(cache, row, readOnly);
                    PXUIFieldAttribute.SetReadOnly <EPCustomWeek.isFullWeek>(cache, row, readOnly);
                    PXUIFieldAttribute.SetReadOnly <EPCustomWeek.startDate>(cache, row, row.Year != null && row.StartDate != null && (row.StartDate.Value.AddDays(-6d).Year <= row.Year.Value && row.Year.Value <= row.StartDate.Value.AddDays(6d).Year));
                }
            }
        }
Пример #18
0
        protected virtual void EPCustomWeek_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            EPCustomWeek row = (EPCustomWeek)e.Row;

            if (row != null)
            {
                if (row.StartDate != null && row.EndDate != null && row.StartDate.Value.Year != row.Year.Value && row.EndDate.Value.Year != row.Year.Value)
                {
                    throw new PXException(Messages.EndOfYear);
                }
            }
            EPCustomWeek lastWeek = PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.year, Desc <EPCustomWeek.number> > > > .SelectSingleBound(this, new object[] { });

            if (lastWeek != null && lastWeek.EndDate == null)
            {
                throw new PXException(Messages.IncrorrectPrevWeek);
            }
        }
        protected virtual void EPGenerateWeeksDialog_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPGenerateWeeksDialog row = (EPGenerateWeeksDialog)e.Row;

            if (row == null)
            {
                return;
            }

            if (row.CutOffDayOne == EPGenerateWeeksDialog.CutOffDayListAttribute.FixedDayOfMonth)
            {
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.dayOne>(cache, row, true);
                PXUIFieldAttribute.SetRequired <EPGenerateWeeksDialog.dayOne>(cache, true);
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.cutOffDayTwo>(cache, row, true);
                PXDefaultAttribute.SetPersistingCheck <EPGenerateWeeksDialog.dayOne>(cache, row, PXPersistingCheck.NullOrBlank);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.cutOffDayTwo>(cache, row, false);
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.dayOne>(cache, row, false);
                row.DayOne       = null;
                row.DayTwo       = null;
                row.CutOffDayTwo = EPGenerateWeeksDialog.CutOffDayListAttribute.None;
            }
            if (row.CutOffDayTwo == EPGenerateWeeksDialog.CutOffDayListAttribute.FixedDayOfMonth)
            {
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.dayTwo>(cache, row, true);
                PXUIFieldAttribute.SetRequired <EPGenerateWeeksDialog.dayTwo>(cache, true);
                PXDefaultAttribute.SetPersistingCheck <EPGenerateWeeksDialog.dayTwo>(cache, row, PXPersistingCheck.NullOrBlank);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.dayTwo>(cache, row, false);
                row.DayTwo = null;
            }

            EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.number> > > .Select(this);

            if (lastWeek != null)
            {
                PXUIFieldAttribute.SetEnabled <EPGenerateWeeksDialog.fromDate>(cache, row, false);
            }
        }
        public virtual IEnumerable previousperiod(PXAdapter adapter)
        {
            InventoryTranByAcctEnqFilter filter = Filter.Current as InventoryTranByAcctEnqFilter;
            FinPeriod nextperiod = PXSelect <FinPeriod,
                                             Where <FinPeriod.finPeriodID,
                                                    Less <Current <InventoryTranByAcctEnqFilter.finPeriodID> > >,
                                             OrderBy <Desc <FinPeriod.finPeriodID> >
                                             > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Desc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);
            }

            filter.FinPeriodID = nextperiod.FinPeriodID;
            ResetFilterDates(filter);
            return(adapter.Get());
        }
        public virtual IEnumerable previousperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = Filter.Current as GLHistoryEnqFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID,
                                                             Less <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Desc <FinPeriod.finPeriodID> >
                                                      > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Desc <FinPeriod.finPeriodID> >
                                              > .SelectWindowed(this, 0, 1);
            }

            filter.FinPeriodID = nextperiod != null ? nextperiod.FinPeriodID : null;

            return(adapter.Get());
        }
Пример #22
0
        protected virtual IEnumerable opportunityProbabilities()
        {
            List <string> activeProbabilities = new List <string>();

            foreach (CROpportunityClassProbability probability in OpportunityClassActiveProbabilities.Select())
            {
                if (probability.ClassID == OpportunityClass.Current.CROpportunityClassID)
                {
                    activeProbabilities.Add(probability.StageID);
                }
            }

            foreach (CROpportunityProbability probability in
                     PXSelectOrderBy <CROpportunityProbability,
                                      OrderBy <Asc <CROpportunityProbability.sortOrder, Asc <CROpportunityProbability.probability, Asc <CROpportunityProbability.stageCode> > > > > .
                     Select(this))
            {
                probability.IsActive = activeProbabilities.Contains(probability.StageCode);
                yield return(new PXResult <CROpportunityProbability>(probability));
            }
        }
        protected virtual void EPGenerateWeeksDialog_FromDate_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
        {
            EPGenerateWeeksDialog row = (EPGenerateWeeksDialog)e.Row;

            if (e.NewValue == null || row == null)
            {
                return;
            }
            if ((DateTime)e.NewValue > row.TillDate)
            {
                e.Cancel = true;
                throw new PXSetPropertyException(ErrorMessages.StartDateGreaterThanEndDate, PXUIFieldAttribute.GetDisplayName <EPGenerateWeeksDialog.fromDate>(cache), PXUIFieldAttribute.GetDisplayName <EPGenerateWeeksDialog.tillDate>(cache), row.FromDate);
            }
            DateTime?    firstUsingDate = GetFirstUsingWeek();
            EPCustomWeek lastWeek       = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

            if (firstUsingDate != null && (DateTime)e.NewValue > firstUsingDate && lastWeek == null)
            {
                e.Cancel = true;
                throw new PXSetPropertyException(Messages.ExistsActivitiesGreateThanDate, PXUIFieldAttribute.GetDisplayName <EPGenerateWeeksDialog.fromDate>(cache), firstUsingDate);
            }
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = this.CurrentFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID,
                                                             Greater <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Asc <FinPeriod.finPeriodID> >
                                                      > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);

                if (nextperiod == null)
                {
                    yield return(filter);
                }
            }
            filter.FinPeriodID = nextperiod != null ? nextperiod.FinPeriodID : null;
            yield return(filter);
        }
        public virtual IEnumerable previousperiod(PXAdapter adapter)
        {
            AccountByYearFilter filter     = this.CurrentFilter;
            FinYear             nextperiod = PXSelect <FinYear,
                                                       Where <FinYear.year,
                                                              Less <Current <AccountByYearFilter.finYear> > >,
                                                       OrderBy <Desc <FinYear.year> >
                                                       > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinYear,
                                              OrderBy <Desc <FinYear.year> >
                                              > .SelectWindowed(this, 0, 1);

                if (nextperiod == null)
                {
                    yield return(filter);
                }
            }
            filter.FinYear = nextperiod != null ? nextperiod.Year : null;
            yield return(filter);
        }
        protected virtual void EPCustomWeek_RowDeleting(PXCache cache, PXRowDeletingEventArgs e)
        {
            EPCustomWeek row = (EPCustomWeek)e.Row;

            if (row == null)
            {
                return;
            }
            if (cache.GetStatus(row) != PXEntryStatus.Inserted && cache.GetStatus(row) != PXEntryStatus.InsertedDeleted)
            {
                if ((EPTimeCard)PXSelect <EPTimeCard> .Search <EPTimeCard.weekId>(this, row.WeekID) != null || (PMTimeActivity)PXSelect <PMTimeActivity> .Search <PMTimeActivity.weekID>(this, row.WeekID) != null)
                {
                    throw new PXException(Messages.WeekInUse);
                }
            }

            EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .Select(this);

            if (lastWeek != null && lastWeek.WeekID > row.WeekID)
            {
                throw new PXSetPropertyException(Messages.WeekNotLast, PXErrorLevel.RowWarning);
            }
        }
Пример #27
0
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            InventoryTranByAcctEnqFilter filter = Filter.Current as InventoryTranByAcctEnqFilter;
            FinPeriod nextperiod = PXSelect <FinPeriod,
                                             Where <FinPeriod.finPeriodID,
                                                    Greater <Current <InventoryTranByAcctEnqFilter.finPeriodID> > >,
                                             OrderBy <Asc <FinPeriod.finPeriodID> >
                                             > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);

                if (nextperiod == null)
                {
                    yield return(filter);
                }
            }
            filter.FinPeriodID = nextperiod.FinPeriodID;
            ResetFilterDates(filter);
            yield return(filter);
        }
Пример #28
0
        protected virtual void EPSetup_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPSetup row = e.Row as EPSetup;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <EPSetup.useReceiptAccountForTips>(cache, row, row.NonTaxableTipItem.HasValue);
                PXUIFieldAttribute.SetEnabled <EPSetup.offBalanceAccountGroupID>(cache, row, row.PostingOption == EPPostOptions.PostToOffBalance);
                if (row.CustomWeek == true)
                {
                    EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

                    PXUIFieldAttribute.SetEnabled <EPSetup.customWeek>(cache, row, lastWeek == null);
                }

                bool claimApprovalVisible = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() &&
                                            PXAccess.FeatureInstalled <FeaturesSet.expenseManagement>();

                PXUIFieldAttribute.SetVisible <EPSetup.claimDetailsAssignmentMapID>(cache, null, claimApprovalVisible);
                PXUIFieldAttribute.SetVisible <EPSetup.claimAssignmentMapID>(cache, null, claimApprovalVisible);
                PXUIFieldAttribute.SetVisible <EPSetup.claimDetailsAssignmentNotificationID>(cache, null, claimApprovalVisible);
            }
        }
        private void GetNextUsingWeek(out DateTime startDate, out int number, out int year)
        {
            EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

            if (lastWeek != null)
            {
                startDate = lastWeek.EndDate.Value.AddDays(1d);
                if (lastWeek.Number > 1 && lastWeek.StartDate.Value.Year < startDate.Year)
                {
                    number = 1;
                }
                else
                {
                    number = lastWeek.Number.Value + 1;
                }
                year = startDate.Year;
            }
            else
            {
                DateTime?First = GetFirstUsingWeek();
                if (First != null)
                {
                    startDate = (DateTime)First;
                }
                else if (WeekFilter.Current != null)
                {
                    startDate = new DateTime(WeekFilter.Current.Year.Value, 1, 1);
                }
                else
                {
                    startDate = new DateTime(Accessinfo.BusinessDate.Value.Year, 1, 1);
                }

                number = PXWeekSelectorAttribute.GetWeekID(startDate) % 100;
                year   = PXWeekSelectorAttribute.GetWeekID(startDate) / 100;
            }
        }
        private DateTime?GetFirstUsingWeek()
        {
            DateTime   dateFromActivity = new DateTime(1900, 1, 1);
            DateTime   startDate        = new DateTime(1900, 1, 1);
            EPTimeCard lastTimeCard     =
                (EPTimeCard)PXSelectOrderBy <EPTimeCard, OrderBy <Asc <EPTimeCard.weekId> > > .SelectSingleBound(this, null);

            CRPMTimeActivity lastActivity = PXSelect <CRPMTimeActivity,
                                                      Where <CRPMTimeActivity.weekID, IsNotNull,
                                                             And <CRPMTimeActivity.trackTime, Equal <True>,
                                                                  And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.emailRouting>,
                                                                       And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.task>,
                                                                            And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.events> > > > > >,
                                                      OrderBy <
                                                          Asc <CRPMTimeActivity.weekID> > > .SelectSingleBound(this, null);

            if (lastTimeCard != null)
            {
                startDate = PXWeekSelectorAttribute.GetWeekStartDate(lastTimeCard.WeekID.Value);
            }
            if (lastActivity != null)
            {
                dateFromActivity = lastActivity.StartDate.Value;
            }

            startDate = startDate <= dateFromActivity ? startDate : dateFromActivity;

            if (startDate == new DateTime(1900, 1, 1))
            {
                return(null);
            }
            else
            {
                return(startDate);
            }
        }
		private void InitializePropertyValueView(PXGraph graph)
		{
			//Init PXVirtual Static constructor
			typeof (PropertyValue).GetCustomAttributes(typeof (PXVirtualAttribute), false);

			var propertiesSelect = new PXSelectOrderBy<PropertyValue,
				OrderBy<Asc<PropertyValue.order>>>(graph, 
				new PXSelectDelegate(() => graph.Caches[typeof(PropertyValue)].Cached.Cast<PropertyValue>().Where(item => item.Hidden != true)));
			graph.Views.Add(PropertiesViewName, propertiesSelect.View);
			if (View.Cache.Fields.Any(o=>o.EndsWith("_Attributes")) && !graph.Views.Caches.Contains(typeof(CS.CSAnswers)))
			{
					graph.Views.Caches.Add(typeof(CS.CSAnswers));
			}
		}