Exemple #1
0
        private void CheckNumbers(PXCache cache, object row)
        {
            NumberingSequence currow = row as NumberingSequence;

            if (currow == null)
            {
                return;
            }

            currow.StartNbr = currow.StartNbr.SafeTrimStart();
            currow.EndNbr   = currow.EndNbr.SafeTrimStart();
            currow.LastNbr  = currow.LastNbr.SafeTrimStart();
            currow.WarnNbr  = currow.WarnNbr.SafeTrimStart();

            string nbr    = null;
            string s_mask = (currow.StartNbr == null) ? null : NumberingDetector.MakeMask(currow.StartNbr, ref nbr);
            string s_nbr  = nbr;
            string e_mask = (currow.EndNbr == null) ? null : NumberingDetector.MakeMask(currow.EndNbr, ref nbr);
            string e_nbr  = nbr;
            string l_mask = (currow.LastNbr == null) ? null : NumberingDetector.MakeMask(currow.LastNbr, ref nbr);
            string l_nbr  = nbr;
            string w_mask = (currow.WarnNbr == null) ? null : NumberingDetector.MakeMask(currow.WarnNbr, ref nbr);
            string w_nbr  = nbr;

            if (s_mask != e_mask || l_mask != null && s_mask != l_mask || w_mask != null && s_mask != w_mask)
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.SameNumberingMask, PXErrorLevel.RowError));
                return;
            }
            if (currow.StartNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.StartNumMustBeGreaterEndNum, PXErrorLevel.RowError));
                return;
            }
            if (currow.WarnNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.WarnNumMustBeLessEndNum, PXErrorLevel.RowError));
                return;
            }
            if (currow.WarnNbr?.CompareTo(currow.StartNbr) <= 0)
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.WarnNumMustBeGreaterStartNum, PXErrorLevel.RowError));
                return;
            }
            if (currow.LastNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.LastNumMustBeLessEndNum, PXErrorLevel.RowError));
                return;
            }
            if (currow.LastNbr?.CompareTo(currow.StartNbr) < 0 && !EqualLastAndStartMinusOne(s_nbr, l_nbr))
            {
                cache.RaiseExceptionHandling <NumberingSequence.numberingID>(currow, currow.NumberingID, new PXSetPropertyException(Messages.LastNumMustBeGreaterOrEqualStartNum, PXErrorLevel.RowError));
                return;
            }
        }
Exemple #2
0
        private void CheckNumbers(object row)
        {
            NumberingSequence currow = row as NumberingSequence;

            if (currow == null)
            {
                return;
            }

            currow.StartNbr = currow.StartNbr.SafeTrimStart();
            currow.EndNbr   = currow.EndNbr.SafeTrimStart();
            currow.LastNbr  = currow.LastNbr.SafeTrimStart();
            currow.WarnNbr  = currow.WarnNbr.SafeTrimStart();

            string nbr    = null;
            string s_mask = (currow.StartNbr == null) ? null : NumberingDetector.MakeMask(currow.StartNbr, ref nbr);
            string s_nbr  = nbr;
            string e_mask = (currow.EndNbr == null) ? null : NumberingDetector.MakeMask(currow.EndNbr, ref nbr);
            string e_nbr  = nbr;
            string l_mask = (currow.LastNbr == null) ? null : NumberingDetector.MakeMask(currow.LastNbr, ref nbr);
            string l_nbr  = nbr;
            string w_mask = (currow.WarnNbr == null) ? null : NumberingDetector.MakeMask(currow.WarnNbr, ref nbr);
            string w_nbr  = nbr;

            if (s_mask != e_mask || l_mask != null && s_mask != l_mask || w_mask != null && s_mask != w_mask)
            {
                throw new PXException(Messages.SameNumberingMask);
            }
            if (currow.StartNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                throw new PXException(Messages.StartNumMustBeGreaterEndNum);
            }
            if (currow.WarnNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                throw new PXException(Messages.WarnNumMustBeLessEndNum);
            }
            if (currow.WarnNbr?.CompareTo(currow.StartNbr) <= 0)
            {
                throw new PXException(Messages.WarnNumMustBeGreaterStartNum);
            }
            if (currow.LastNbr?.CompareTo(currow.EndNbr) >= 0)
            {
                throw new PXException(Messages.LastNumMustBeLessEndNum);
            }
            if (currow.LastNbr?.CompareTo(currow.StartNbr) < 0 && !EqualLastAndStartMinusOne(s_nbr, l_nbr))
            {
                throw new PXException(Messages.LastNumMustBeGreaterOrEqualStartNum);
            }
        }
		public static string MakeMask(string str, ref string nbr)
		{
			return NumberingDetector.MakeMask(str, ref nbr);
		}
		public NumberingMaint()
		{
			PXUIFieldAttribute.SetRequired<NumberingSequence.nbrStep>(Sequence.Cache, true);
			detector = new NumberingDetector(this, ApplicationAreas.StandardFinance | ApplicationAreas.AdvancedFinance |
				ApplicationAreas.Distribution | ApplicationAreas.Project);
		}