protected virtual void EPEmployeeClass_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
 {
     PXUIFieldAttribute.SetVisible <EPEmployeeClass.curyID>(cache, null, (bool)cmsetup.Current.MCActivated);
     PXUIFieldAttribute.SetVisible <EPEmployeeClass.curyRateTypeID>(cache, null, (bool)cmsetup.Current.MCActivated);
     PXUIFieldAttribute.SetVisible <EPEmployeeClass.allowOverrideCury>(cache, null, (bool)cmsetup.Current.MCActivated);
     PXUIFieldAttribute.SetVisible <EPEmployeeClass.allowOverrideRate>(cache, null, (bool)cmsetup.Current.MCActivated);
     if (e.Row != null)
     {
         EPEmployeeClass row = (EPEmployeeClass)e.Row;
         PXUIFieldAttribute.SetEnabled <EPEmployeeClass.cashAcctID>(cache, e.Row, String.IsNullOrEmpty(row.PaymentMethodID) == false);
     }
 }
Exemple #2
0
        protected virtual void EPEmployeeClass_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var mcFeatureInstalled = PXAccess.FeatureInstalled <FeaturesSet.multicurrency>();

            PXUIFieldAttribute.SetVisible <EPEmployeeClass.curyID>(cache, null, mcFeatureInstalled);
            PXUIFieldAttribute.SetVisible <EPEmployeeClass.curyRateTypeID>(cache, null, mcFeatureInstalled);
            PXUIFieldAttribute.SetVisible <EPEmployeeClass.allowOverrideCury>(cache, null, mcFeatureInstalled);
            PXUIFieldAttribute.SetVisible <EPEmployeeClass.allowOverrideRate>(cache, null, mcFeatureInstalled);
            if (e.Row != null)
            {
                EPEmployeeClass row = (EPEmployeeClass)e.Row;
                PXUIFieldAttribute.SetEnabled <EPEmployeeClass.cashAcctID>(cache, e.Row, String.IsNullOrEmpty(row.PaymentMethodID) == false);
            }
        }
        protected virtual void EPEmployeeClass_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            EPEmployeeClass row = e.Row as EPEmployeeClass;

            if (row != null)
            {
                EPEmployee refEmployee = PXSelect <EPEmployee, Where <EPEmployee.vendorClassID, Equal <Current <EPEmployeeClass.vendorClassID> > > > .SelectWindowed(this, 0, 1);

                if (refEmployee != null)
                {
                    e.Cancel = true;
                    throw new PXException(CS.Messages.ReferencedByEmployee, refEmployee.AcctCD);
                }
            }
        }
Exemple #4
0
        public static DateTime?GetNextActivityStartDate <Activity>(PXGraph graph, PXResultset <Activity> res, PMTimeActivity row, int?fromWeekId, int?tillWeekId, PXCache tempDataCache, Type tempDataField)
            where Activity : PMTimeActivity, new()
        {
            DateTime?date;

            if (fromWeekId != null || tillWeekId != null)
            {
                date = PXWeekSelector2Attribute.GetWeekStartDate(graph, (int)(fromWeekId ?? tillWeekId));
            }
            else
            {
                date = graph.Accessinfo.BusinessDate.GetValueOrDefault(DateTime.Now).Date;
            }

            EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(graph, row.OwnerID);

            EPEmployeeClass employeeClass = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.vendorClassID, Equal <Required <EPEmployee.vendorClassID> > > > .Select(graph, employee != null?employee.VendorClassID : null);

            var calendarId = CRActivityMaint.GetCalendarID(graph, row);

            if (employeeClass != null && EPEmployeeClass.defaultDateInActivity.LastDay == employeeClass.DefaultDateInActivity)
            {
                DateTime?val = tempDataCache.GetValue(tempDataCache.Current, tempDataField.Name) as DateTime?;
                if (val != null)
                {
                    int week = PXWeekSelector2Attribute.GetWeekID(graph, (DateTime)val);
                    if ((fromWeekId == null || week >= fromWeekId) && (tillWeekId == null || tillWeekId >= week))
                    {
                        date = val;
                    }
                }
            }
            else
            {
                DateTime weekDate = (DateTime)date;
                DateTime?newDate  = null;
                date = res != null && res.Count > 0 ? res.Max(_ => ((Activity)_).Date) : null ?? date;
                for (int curentWeek = PXWeekSelector2Attribute.GetWeekID(graph, weekDate); tillWeekId == null || curentWeek <= tillWeekId; curentWeek = PXWeekSelector2Attribute.GetWeekID(graph, weekDate))
                {
                    PXWeekSelector2Attribute.WeekInfo week1 = PXWeekSelector2Attribute.GetWeekInfo(graph,
                                                                                                   PXWeekSelector2Attribute.GetWeekID(graph, weekDate));
                    foreach (KeyValuePair <DayOfWeek, PXWeekSelector2Attribute.DayInfo> pair in week1.Days.OrderBy(_ => _.Value.Date))
                    {
                        if (pair.Value.Date >= date &&
                            (CalendarHelper.IsWorkDay(graph, calendarId, (DateTime)pair.Value.Date) ||
                             string.IsNullOrEmpty(calendarId) && pair.Key != DayOfWeek.Saturday && pair.Key != DayOfWeek.Sunday))
                        {
                            newDate = (DateTime)pair.Value.Date;
                            break;
                        }
                        weekDate = weekDate.AddDays(1D);
                    }
                    if (newDate != null)
                    {
                        date = ((DateTime)newDate).Date;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(calendarId) && date != null)
            {
                DateTime startDate;
                DateTime endDate;
                CalendarHelper.CalculateStartEndTime(graph, calendarId, (DateTime)date, out startDate, out endDate);
                date = startDate;
            }

            return(date);
        }