Exemplo n.º 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);
        }
Exemplo n.º 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));
        }