public IEnumerable moveUp(PXAdapter adapter)
        {
            RUTROTWorkType currentRow = WorkTypes.Current;

            if (currentRow != null)
            {
                RUTROTWorkType prevRow = PXSelect <RUTROTWorkType,
                                                   Where <RUTROTWorkType.rUTROTType, Equal <Required <RUTROTWorkType.rUTROTType> >,
                                                          And <RUTROTWorkType.position, Less <Required <RUTROTWorkType.position> > > >,
                                                   OrderBy <Desc <RUTROTWorkType.position> > > .SelectWindowed(this, 0, 1, currentRow.RUTROTType, currentRow.Position);

                if (prevRow != null)
                {
                    int?tempPosition = prevRow.Position;
                    prevRow.Position = null;
                    WorkTypes.Update(prevRow);
                    prevRow.Position    = currentRow.Position;
                    currentRow.Position = tempPosition;
                    currentRow          = WorkTypes.Update(currentRow);
                    WorkTypes.Update(prevRow);
                    WorkTypes.Cache.ActiveRow = currentRow;
                }
            }
            return(adapter.Get());
        }
예제 #2
0
        public static bool IsUpToDateWorkType(int?workTypeID, DateTime currentDate, PXGraph graph)
        {
            RUTROTWorkType workType = PXSelect <RUTROTWorkType,
                                                Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(graph, workTypeID);

            return(IsUpToDateWorkType(workType, currentDate));
        }
        protected virtual void RUTROTWorkType_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            RUTROTWorkType workType = (RUTROTWorkType)e.Row;

            if (workType != null && workType.WorkTypeID != null)
            {
                if (PXSelect <ARTran,
                              Where <ARTranRUTROT.rUTROTWorkTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this, workType.WorkTypeID).Any())
                {
                    throw new PXException(RUTROTMessages.CannotDeleteWorkType);
                }

                if (PXSelect <SOLine,
                              Where <SOLineRUTROT.rUTROTWorkTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this, workType.WorkTypeID).Any())
                {
                    throw new PXException(RUTROTMessages.CannotDeleteWorkType);
                }

                if (PXSelect <InventoryItem,
                              Where <InventoryItemRUTROT.rUTROTWorkTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this, workType.WorkTypeID).Any())
                {
                    throw new PXException(RUTROTMessages.CannotDeleteWorkType);
                }
            }
        }
예제 #4
0
 public static bool IsUpToDateWorkType(RUTROTWorkType workType, DateTime currentDate)
 {
     if (workType == null)
     {
         return(false);
     }
     return((workType.EndDate > currentDate || workType.EndDate == null) && workType.StartDate <= currentDate);
 }
		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;
		}
예제 #6
0
        private void ClearWorkTypes(RUTROT rutrot)
        {
            foreach (Tran line in Transactions.Select())
            {
                TranExt        lineRR   = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(line);
                RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, lineRR.RUTROTWorkTypeID);

                if (workType?.RUTROTType != rutrot.RUTROTType)
                {
                    lineRR.RUTROTWorkTypeID = null;
                    Transactions.Update(line);
                }
            }
        }
		protected virtual void RUTROTWorkType_EndDate_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
		{
			RUTROTWorkType row = (RUTROTWorkType)e.Row;
			if (row == null || row.StartDate == null)
			{
				return;
			}
			DateTime? endDate = (DateTime)e.NewValue;
			if (endDate == null)
			{
				return;
			}
			if (row.StartDate > endDate)
			{
				throw new PXException(CR.Messages.EndDateLessThanStartDate);
			}
		}
예제 #8
0
        protected virtual void ARTran_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            ARTran         row      = e.Row as ARTran;
            ARTranRUTROT   rowRR    = RUTROTHelper.GetExtensionNullable <ARTran, ARTranRUTROT>(row);
            RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, rowRR.RUTROTWorkTypeID);

            if (rowRR?.IsRUTROTDeductible == true && Base.Document.Current.Released != true && rowRR?.RUTROTItemType != RUTROTItemTypes.OtherCost &&
                Base.Document.Current.Voided != true && !RUTROTHelper.IsUpToDateWorkType(workType, Base.Document.Current.DocDate ?? DateTime.Now))
            {
                sender.RaiseExceptionHandling <ARTranRUTROT.rUTROTWorkTypeID>(row, workType?.Description, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkType));
            }
            else
            {
                sender.RaiseExceptionHandling <ARTranRUTROT.rUTROTWorkTypeID>(row, workType?.Description, null);
            }
        }
예제 #9
0
        protected virtual void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOLine         row      = e.Row as SOLine;
            SOLineRUTROT   rowRR    = RUTROTHelper.GetExtensionNullable <SOLine, SOLineRUTROT>(row);
            RUTROTWorkType workType = PXSelect <RUTROTWorkType, Where <RUTROTWorkType.workTypeID, Equal <Required <RUTROTWorkType.workTypeID> > > > .Select(this.Base, rowRR.RUTROTWorkTypeID);

            if (rowRR?.IsRUTROTDeductible == true && Base.Document.Current.Completed != true && rowRR?.RUTROTItemType != RUTROTItemTypes.OtherCost &&
                Base.Document.Current.Rejected != true && !RUTROTHelper.IsUpToDateWorkType(workType, Base.Document.Current.OrderDate ?? DateTime.Now))
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.rUTROTWorkTypeID>(row, workType?.Description, new PXSetPropertyException(RUTROTMessages.ObsoleteWorkType));
            }
            else
            {
                sender.RaiseExceptionHandling <SOLineRUTROT.rUTROTWorkTypeID>(row, workType?.Description, null);
            }
            PXUIFieldAttribute.SetEnabled <SOLineRUTROT.isRUTROTDeductible>(Base.Transactions.Cache, row, row.IsStockItem != true);
        }
		public IEnumerable moveDown(PXAdapter adapter)
		{
			RUTROTWorkType currentRow = WorkTypes.Current;
			if(currentRow!=null)
			{
				RUTROTWorkType nextRow = PXSelect<RUTROTWorkType,
					Where<RUTROTWorkType.rUTROTType, Equal<Required<RUTROTWorkType.rUTROTType>>,
					And<RUTROTWorkType.position, Greater<Required<RUTROTWorkType.position>>>>,
					OrderBy<Asc<RUTROTWorkType.position>>>.SelectWindowed(this, 0, 1, currentRow.RUTROTType, currentRow.Position);
				if (nextRow != null)
				{
					int? tempPosition = nextRow.Position;
					nextRow.Position = null;
					WorkTypes.Update(nextRow);
					nextRow.Position = currentRow.Position;
					currentRow.Position = tempPosition;
					currentRow = WorkTypes.Update(currentRow);
					WorkTypes.Update(nextRow);
					WorkTypes.Cache.ActiveRow = currentRow;
				}
			}
			return adapter.Get();
		}