private DateTime?GetLasttUsingWeek()
        {
            DateTime   dateFromActivity = new DateTime(1900, 1, 1);
            DateTime   startDate        = new DateTime(1900, 1, 1);
            EPTimeCard lastTimeCard     = (EPTimeCard)PXSelectOrderBy <EPTimeCard, OrderBy <Desc <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 <
                                                          Desc <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);
            }
        }
Exemplo n.º 2
0
        private DateTime?GetFirstUsingWeek()
        {
            DateTime?startDate = GetFirstActivityDate();

            EPTimeCard firstTimeCard =
                (EPTimeCard)PXSelectOrderBy <EPTimeCard, OrderBy <Asc <EPTimeCard.weekId> > > .SelectSingleBound(this, null);

            if (firstTimeCard != null)
            {
                DateTime timecardStartDate = PXWeekSelectorAttribute.GetWeekStartDate(firstTimeCard.WeekID.Value);
                if (startDate == null)
                {
                    startDate = timecardStartDate;
                }
                else
                {
                    if (timecardStartDate < startDate.Value)
                    {
                        startDate = timecardStartDate;
                    }
                }
            }

            return(startDate);
        }