Beispiel #1
0
        /// <summary>
        /// return a container indicating which data parts are supplied
        /// </summary>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns></returns>
        public static Container GetContainer(string city, string state, string zip)
        {
            bool hasCity  = !TestRoutine.IsNullOrEmpty(city);
            bool hasState = !TestRoutine.IsNullOrEmpty(state);
            bool hasZip   = !TestRoutine.IsNullOrEmpty(zip);

            // test when all fields are specified.
            if (hasCity && hasState && hasZip)
            {
                return(Container.CityStateZip);
            }

            if (hasCity && hasState)
            {
                return(Container.CityState);
            }

            if (hasCity)
            {
                return(Container.City);
            }

            if (hasState)
            {
                return(Container.State);
            }

            if (hasZip)
            {
                return(Container.Zip);
            }

            return(Container.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve an AMS Reference AMSCityState_D for given city, state and zip
        /// </summary>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns></returns>
        public static DataTable LookupCSZ(string city, string state, string zip)
        {
            #region Sanity Checks
            if (TestRoutine.IsNullOrEmpty(city) &&
                TestRoutine.IsNullOrEmpty(state) &&
                TestRoutine.IsNullOrEmpty(zip)
                )
            {
                throw new ArgumentNullException("All parameters cannot be null!");
            }
            #endregion

            DbParameter[] parameters = new DbParameter[] {
                dataFactory.GetParameterIn("@City", DbType.String, 28, city),
                dataFactory.GetParameterIn("@State", DbType.String, 2, state),
                dataFactory.GetParameterIn("@Zip", DbType.String, 5, zip),
            };
            return(dataFactory.FillTable("select * from AMSCityState_D where (city = @City or @City is null) and (state = @State or @State is null) and (zip = @Zip or @Zip is null)", parameters));
        }
Beispiel #3
0
        /// <summary>
        /// Validate data integrity
        /// </summary>
        /// <returns></returns>
        public bool Validate()
        {
            if (!this.validate)
            {
                return(false);
            }

            bool val = false;

            switch (GetContainer(City, State, Zip))
            {
            case Container.Empty:
                val = false;
                break;

            case Container.CityStateZip:
                val = TestRoutine.VerifyCSZ(City, State, Zip);
                break;

            case Container.CityState:
                val = TestRoutine.VerifyCSZ(City, State, null);
                break;

            case Container.City:
                val = TestRoutine.VerifyCSZ(City, null, null);
                break;

            case Container.State:
                val = TestRoutine.VerifyCSZ(null, State, null);
                break;

            case Container.Zip:
                val = TestRoutine.VerifyCSZ(null, null, Zip);
                break;

            default:
                val = false;
                break;
            }

            return(val);
        }