Esempio n. 1
0
        //  private DbPriceRules _DbPriceRules { get; set; }


        public static PriceRule getTopiaryRule()
        {
            DbPriceRules DBrules = new DbPriceRules();
            var          rules   = DBrules.GetRules();

            return(rules.Single(r => r.RuleNumber == 22));
        }
Esempio n. 2
0
        public static PriceRule getPotRule(string root, string cleanString)
        {
            DbPriceRules DBrules = new DbPriceRules();
            var          rules   = DBrules.GetRules();

            try
            {
                var numPart = CleanNumbers(CleanString(cleanString));
                if (Decimal.TryParse(numPart, out decimal size))
                {
                    if ((size < 1.0m) || (size == 9 && root == "P"))
                    {
                        return(rules.Single(r => r.RuleNumber == 1));
                        // then 1
                        //return PriceRules.Rules.Single(r => r.RuleNumber == 1);
                    }
                    if (size >= 1.0m && size <= 3.0m || (root == "P"))
                    {
                        // then 2
                        //return PriceRules.Rules.Single(r => r.RuleNumber == 2);
                        return(rules.Single(r => r.RuleNumber == 2));
                    }
                    if (size > 3.0m && size <= 7.5m)
                    {
                        // then 3
                        return(rules.Single(r => r.RuleNumber == 3));
                    }
                    if (size > 7.5m && size <= 15.0m)
                    {
                        // then 4
                        return(rules.Single(r => r.RuleNumber == 4));
                    }
                    if (size > 15.0m && size <= 30.0m)
                    {
                        // then 5
                        return(rules.Single(r => r.RuleNumber == 5));
                    }
                    if (size > 30.0m)
                    {
                        // then 6
                        return(rules.Single(r => r.RuleNumber == 6));
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(null);
        }
Esempio n. 3
0
        public static PriceRule getRBRule(string root, string min, string max)
        {
            DbPriceRules DBrules = new DbPriceRules();
            var          rules   = DBrules.GetRules();

            try
            {
                var     minNumPart = CleanNumbers(CleanString(min));
                var     maxNumPart = CleanNumbers(CleanString(max));
                decimal minM       = Decimal.Parse(minNumPart);
                decimal maxM       = Decimal.Parse(maxNumPart);

                if (maxM == 0)
                {
                    // test 1
                    if (minM > 0 & minM <= 30)
                    {
                        return(rules.Single(r => r.RuleNumber == 25));
                    }

                    // test 2
                    if (minM > 30 & minM <= 60)
                    {
                        return(rules.Single(r => r.RuleNumber == 26));
                    }

                    //test 3
                    if (minM > 60 & minM <= 100)
                    {
                        return(rules.Single(r => r.RuleNumber == 27));
                    }

                    //test 4
                    if (minM > 100)
                    {
                        return(rules.Single(r => r.RuleNumber == 27));
                    }
                }
                // diff between 0 and 4 normally applied to trees
                if (maxM - minM < 4)
                {
                    // test 5
                    if (minM <= 10.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 7));
                    }
                    // test 6
                    if (minM > 10.0m && maxM <= 14.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 8));
                    }
                    // test span 5 and 6 use rule 7
                    if (minM <= 10.0m && maxM <= 14.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 7));
                    }

                    // R25RB:range=2 and min>14 and max<=18
                    if (minM <= 14.0m && maxM <= 18.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 25));
                    }
                    // R26RB:range=2 and min>18 and max<=20
                    if (minM <= 18.0m && maxM <= 20.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 26));
                    }
                    // test span 25 and 26 use rule 25
                    if (minM <= 14.0m && maxM <= 20.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 25));
                    }

                    // R27RB:range=2 and min>20and max<=30


                    //// test 7
                    //if (minM >= 18 && maxM <= 30)
                    //{
                    //    return rules.Single(r => r.RuleNumber == 9);
                    //}
                    if (minM >= 20.0m && maxM <= 30.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 27));
                    }
                    // test span 6 and 7 use rule 8
                    if (minM > 10.0m && maxM <= 30)
                    {
                        return(rules.Single(r => r.RuleNumber == 8));
                    }
                }
                // dif is more than 4 normally applied to shrubs
                else if (maxM - minM >= 4.0m) // need a 100 to 125 Rule
                {
                    // test 8
                    if (maxM <= 60) // changed on 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 10));
                    }
                    // test 9
                    if (minM >= 60 && maxM <= 100) // new rule 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 20));
                    }
                    // test span 8 and 9 use rule 10
                    if (minM <= 60 && maxM <= 100) // new rule 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 10));
                    }
                    // test 10
                    if (minM >= 100 && maxM <= 150) // updated 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 11));
                    }
                    // test span 9 and 10 use rule 20
                    if (minM >= 60 && maxM <= 150) // new rule 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 20));
                    }
                    // test 11
                    if (minM >= 150 && maxM <= 250)
                    {
                        return(rules.Single(r => r.RuleNumber == 12));
                    }
                    // test span 10 and 11 use rule 11
                    if (minM >= 100 && maxM <= 250) // updated 11/9
                    {
                        return(rules.Single(r => r.RuleNumber == 11));
                    }
                    // test 12
                    if (minM <= 250 && maxM <= 300)
                    {
                        return(rules.Single(r => r.RuleNumber == 13));
                    }
                    // test span 11 and 12 use rule 12
                    if (minM >= 150 && maxM <= 300)
                    {
                        return(rules.Single(r => r.RuleNumber == 12));
                    }
                    // test 13
                    if (maxM > 300)
                    {
                        return(rules.Single(r => r.RuleNumber == 13));
                    }
                }
            }
            catch (Exception ex)
            {
                return(rules.Single(r => r.RuleNumber == 13));;
            }



            return(PriceRules.Rules.Single(r => r.RuleNumber == 23));
        }
Esempio n. 4
0
        public static PriceRule getBulbRule()
        {
            DbPriceRules DBrules = new DbPriceRules();

            return(DBrules.GetRules().Single(r => r.RuleNumber == 21));
        }
Esempio n. 5
0
        public static PriceRule getBRRule(string Root, string min, string max)
        {
            DbPriceRules DBrules = new DbPriceRules();
            var          rules   = DBrules.GetRules();

            try
            {
                var     minNumPart = CleanNumbers(CleanString(min));
                var     maxNumPart = CleanNumbers(CleanString(max));
                decimal minM       = Decimal.Parse(minNumPart);
                decimal maxM       = Decimal.Parse(maxNumPart);
                // special case no size specified
                if (maxM == 0)
                {
                    if (minM == 0)
                    {
                        return(rules.Single(r => r.RuleNumber == 14));
                    }
                    if (minM > 0 & minM <= 30)
                    {
                        return(rules.Single(r => r.RuleNumber == 28));
                    }
                    if (minM > 30 & minM <= 60)
                    {
                        return(rules.Single(r => r.RuleNumber == 29));
                    }
                    if (minM >= 60 & minM <= 100)
                    {
                        return(rules.Single(r => r.RuleNumber == 30));
                    }
                    if (minM > 100)
                    {
                        return(rules.Single(r => r.RuleNumber == 31));
                    }
                }
                if (maxM - minM <= 4)
                {
                    // rule 1
                    if (maxM <= 12.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 14));
                    }
                    // rule 2
                    if (minM >= 12.0m)
                    {
                        return(rules.Single(r => r.RuleNumber == 15));
                    }
                }
                else if (maxM - minM > 4.0m)
                {
                    //rules 3
                    if (maxM <= 60)
                    {
                        return(rules.Single(r => r.RuleNumber == 16));
                    }
                    //rule 4
                    if (minM >= 60 && maxM <= 150)
                    {
                        return(rules.Single(r => r.RuleNumber == 17));
                    }
                    // span r3 and r 4 select 16
                    if (maxM <= 60)
                    {
                        return(rules.Single(r => r.RuleNumber == 16));
                    }
                    // rule 5
                    if (minM >= 150 && maxM <= 250)
                    {
                        return(rules.Single(r => r.RuleNumber == 18));
                    }
                    // rule 6
                    if (minM >= 250)
                    {
                        return(rules.Single(r => r.RuleNumber == 19));
                    }
                }
            }
            catch (Exception ex)
            {
                return(rules.Single(r => r.RuleNumber == 14));
            }

            return(rules.Single(r => r.RuleNumber == 24));
        }