⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 region.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.Accessories
{
    using PowerEasy.Common;
    using PowerEasy.IDal.Accessories;
    using PowerEasy.Model.Accessories;
    using System;
    using System.Collections.Generic;

    public sealed class Region
    {
        private static readonly IRegion dal = DataAccess.CreateRegion();

        private Region()
        {
        }

        public static bool Add(RegionInfo regionInfo)
        {
            EncodeRegionInfo(regionInfo);
            return dal.Add(regionInfo);
        }

        public static bool AreaExists(string area, string province, string city)
        {
            return dal.AreaExists(area, province, city);
        }

        private static RegionInfo DecodeRegionInfo(RegionInfo regionInfo)
        {
            regionInfo.Country = DataSecurity.HtmlDecode(regionInfo.Country);
            regionInfo.Province = DataSecurity.HtmlDecode(regionInfo.Province);
            regionInfo.City = DataSecurity.HtmlDecode(regionInfo.City);
            regionInfo.Area = DataSecurity.HtmlDecode(regionInfo.Area);
            regionInfo.PostCode = DataSecurity.HtmlDecode(regionInfo.PostCode);
            regionInfo.AreaCode = DataSecurity.HtmlDecode(regionInfo.AreaCode);
            return regionInfo;
        }

        public static bool Delete(RegionInfo regionInfo)
        {
            return dal.Delete(regionInfo.RegionId.ToString());
        }

        public static bool Delete(string regionId)
        {
            bool flag = false;
            if (DataValidator.IsValidId(regionId))
            {
                flag = dal.Delete(regionId);
            }
            return flag;
        }

        private static RegionInfo EncodeRegionInfo(RegionInfo regionInfo)
        {
            regionInfo.Country = DataSecurity.HtmlEncode(regionInfo.Country);
            regionInfo.Province = DataSecurity.HtmlEncode(regionInfo.Province);
            regionInfo.City = DataSecurity.HtmlEncode(regionInfo.City);
            regionInfo.Area = DataSecurity.HtmlEncode(regionInfo.Area);
            regionInfo.PostCode = DataSecurity.HtmlEncode(regionInfo.PostCode);
            regionInfo.AreaCode = DataSecurity.HtmlEncode(regionInfo.AreaCode);
            return regionInfo;
        }

        public static IList<RegionInfo> GetAreaListByCity(string city)
        {
            return dal.GetAreaListByCity(DataSecurity.FilterBadChar(city));
        }

        public static RegionInfo GetByPostCodeOfFourNumber(string postCode)
        {
            return GetByPostCodeOfFourNumber(postCode, true);
        }

        public static RegionInfo GetByPostCodeOfFourNumber(string postCode, bool isDecode)
        {
            RegionInfo regionInfo = new RegionInfo(true);
            if (DataValidator.IsNumber(postCode) && (DataSecurity.Len(postCode) == 6))
            {
                regionInfo = dal.GetByPostCodeOfFourNumber(postCode);
                if (isDecode)
                {
                    DecodeRegionInfo(regionInfo);
                }
            }
            return regionInfo;
        }

        public static IList<RegionInfo> GetCityListByProvince(string province)
        {
            return dal.GetCityListByProvince(DataSecurity.FilterBadChar(province));
        }

        public static IList<RegionInfo> GetCountryList()
        {
            return dal.GetCountryList();
        }

        public static IList<RegionInfo> GetProvinceListByCountry(string country)
        {
            return dal.GetProvinceListByCountry(DataSecurity.FilterBadChar(country));
        }

        public static RegionInfo GetRegionById(int regionId)
        {
            return GetRegionById(regionId, true);
        }

        public static RegionInfo GetRegionById(int regionId, bool isDecode)
        {
            RegionInfo regionById = dal.GetRegionById(regionId);
            if (regionById.IsNull)
            {
                return null;
            }
            if (isDecode)
            {
                DecodeRegionInfo(regionById);
            }
            return regionById;
        }

        public static IList<RegionInfo> GetRegionList(string searchType, string keyword, int startRowIndexId, int maxiNumRows)
        {
            searchType = DataSecurity.FilterBadChar(searchType);
            keyword = DataSecurity.FilterBadChar(keyword);
            return dal.GetRegionList(startRowIndexId, maxiNumRows, searchType, keyword);
        }

        public static int GetTotalOfRegion(string searchType, string keyword, int startRowIndexId, int maxiNumRows)
        {
            return dal.GetTotalOfRegion();
        }

        public static string GetZipCodeByArea(string country, string province, string city, string area)
        {
            area = string.IsNullOrEmpty(area) ? string.Empty : area;
            return dal.GetZipCodeByArea(country, province, city, area);
        }

        public static bool PostCodeExists(string postCode)
        {
            return ((DataValidator.IsNumber(postCode) && (DataSecurity.Len(postCode) == 6)) && dal.PostCodeExists(postCode));
        }

        public static bool Update(RegionInfo regionInfo)
        {
            EncodeRegionInfo(regionInfo);
            return dal.Update(regionInfo);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -