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

📄 contacter.cs

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

    public sealed class Contacter
    {
        private static readonly IContacter dal = DataAccess.CreateContacter();

        private Contacter()
        {
        }

        public static bool Add(ContacterInfo contacterInfo)
        {
            EncodeContacterInfo(contacterInfo);
            return dal.Add(contacterInfo);
        }

        private static void DecodeContacterInfo(ContacterInfo contacterinfo)
        {
            contacterinfo.UserName = DataSecurity.HtmlDecode(contacterinfo.UserName);
            contacterinfo.Address = DataSecurity.HtmlDecode(contacterinfo.Address);
            contacterinfo.Aim = DataSecurity.HtmlDecode(contacterinfo.Aim);
            contacterinfo.City = DataSecurity.HtmlDecode(contacterinfo.City);
            contacterinfo.Company = DataSecurity.HtmlDecode(contacterinfo.Company);
            contacterinfo.CompanyAddress = DataSecurity.HtmlDecode(contacterinfo.CompanyAddress);
            contacterinfo.Country = DataSecurity.HtmlDecode(contacterinfo.Country);
            contacterinfo.Department = DataSecurity.HtmlDecode(contacterinfo.Department);
            contacterinfo.Email = DataSecurity.HtmlDecode(contacterinfo.Email);
            contacterinfo.Family = DataSecurity.HtmlDecode(contacterinfo.Family);
            contacterinfo.Fax = DataSecurity.HtmlDecode(contacterinfo.Fax);
            contacterinfo.GraduateFrom = DataSecurity.HtmlDecode(contacterinfo.GraduateFrom);
            contacterinfo.Homepage = DataSecurity.HtmlDecode(contacterinfo.Homepage);
            contacterinfo.HomePhone = DataSecurity.HtmlDecode(contacterinfo.HomePhone);
            contacterinfo.Icq = DataSecurity.HtmlDecode(contacterinfo.Icq);
            contacterinfo.IdCard = DataSecurity.HtmlDecode(contacterinfo.IdCard);
            contacterinfo.InterestsOfAmusement = DataSecurity.HtmlDecode(contacterinfo.InterestsOfAmusement);
            contacterinfo.InterestsOfCulture = DataSecurity.HtmlDecode(contacterinfo.InterestsOfCulture);
            contacterinfo.InterestsOfLife = DataSecurity.HtmlDecode(contacterinfo.InterestsOfLife);
            contacterinfo.InterestsOfOther = DataSecurity.HtmlDecode(contacterinfo.InterestsOfOther);
            contacterinfo.InterestsOfSport = DataSecurity.HtmlDecode(contacterinfo.InterestsOfSport);
            contacterinfo.Mobile = DataSecurity.HtmlDecode(contacterinfo.Mobile);
            contacterinfo.Msn = DataSecurity.HtmlDecode(contacterinfo.Msn);
            contacterinfo.Nation = DataSecurity.HtmlDecode(contacterinfo.Nation);
            contacterinfo.NativePlace = DataSecurity.HtmlDecode(contacterinfo.NativePlace);
            contacterinfo.OfficePhone = DataSecurity.HtmlDecode(contacterinfo.OfficePhone);
            contacterinfo.Operation = DataSecurity.HtmlDecode(contacterinfo.Operation);
            contacterinfo.Owner = DataSecurity.HtmlDecode(contacterinfo.Owner);
            contacterinfo.Phs = DataSecurity.HtmlDecode(contacterinfo.Phs);
            contacterinfo.Position = DataSecurity.HtmlDecode(contacterinfo.Position);
            contacterinfo.Province = DataSecurity.HtmlDecode(contacterinfo.Province);
            contacterinfo.QQ = DataSecurity.HtmlDecode(contacterinfo.QQ);
            contacterinfo.ShortedForm = DataSecurity.HtmlDecode(contacterinfo.ShortedForm);
            contacterinfo.Title = DataSecurity.HtmlDecode(contacterinfo.Title);
            contacterinfo.TrueName = DataSecurity.HtmlDecode(contacterinfo.TrueName);
            contacterinfo.UC = DataSecurity.HtmlDecode(contacterinfo.UC);
            contacterinfo.Yahoo = DataSecurity.HtmlDecode(contacterinfo.Yahoo);
            contacterinfo.ZipCode = DataSecurity.HtmlDecode(contacterinfo.ZipCode);
        }

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

        public static bool DeleteByUserName(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return false;
            }
            return dal.DeleteByUserName(DataSecurity.FilterBadChar(userName));
        }

        private static void EncodeContacterInfo(ContacterInfo contacterinfo)
        {
            contacterinfo.UserName = DataSecurity.HtmlEncode(contacterinfo.UserName);
            contacterinfo.Address = DataSecurity.HtmlEncode(contacterinfo.Address);
            contacterinfo.Aim = DataSecurity.HtmlEncode(contacterinfo.Aim);
            contacterinfo.City = DataSecurity.HtmlEncode(contacterinfo.City);
            contacterinfo.Company = DataSecurity.HtmlEncode(contacterinfo.Company);
            contacterinfo.CompanyAddress = DataSecurity.HtmlEncode(contacterinfo.CompanyAddress);
            contacterinfo.Country = DataSecurity.HtmlEncode(contacterinfo.Country);
            contacterinfo.Department = DataSecurity.HtmlEncode(contacterinfo.Department);
            contacterinfo.Email = DataSecurity.HtmlEncode(contacterinfo.Email);
            contacterinfo.Family = DataSecurity.HtmlEncode(contacterinfo.Family);
            contacterinfo.Fax = DataSecurity.HtmlEncode(contacterinfo.Fax);
            contacterinfo.GraduateFrom = DataSecurity.HtmlEncode(contacterinfo.GraduateFrom);
            contacterinfo.Homepage = DataSecurity.HtmlEncode(contacterinfo.Homepage);
            contacterinfo.HomePhone = DataSecurity.HtmlEncode(contacterinfo.HomePhone);
            contacterinfo.Icq = DataSecurity.HtmlEncode(contacterinfo.Icq);
            contacterinfo.IdCard = DataSecurity.HtmlEncode(contacterinfo.IdCard);
            contacterinfo.InterestsOfAmusement = DataSecurity.HtmlEncode(contacterinfo.InterestsOfAmusement);
            contacterinfo.InterestsOfCulture = DataSecurity.HtmlEncode(contacterinfo.InterestsOfCulture);
            contacterinfo.InterestsOfLife = DataSecurity.HtmlEncode(contacterinfo.InterestsOfLife);
            contacterinfo.InterestsOfOther = DataSecurity.HtmlEncode(contacterinfo.InterestsOfOther);
            contacterinfo.InterestsOfSport = DataSecurity.HtmlEncode(contacterinfo.InterestsOfSport);
            contacterinfo.Mobile = DataSecurity.HtmlEncode(contacterinfo.Mobile);
            contacterinfo.Msn = DataSecurity.HtmlEncode(contacterinfo.Msn);
            contacterinfo.Nation = DataSecurity.HtmlEncode(contacterinfo.Nation);
            contacterinfo.NativePlace = DataSecurity.HtmlEncode(contacterinfo.NativePlace);
            contacterinfo.OfficePhone = DataSecurity.HtmlEncode(contacterinfo.OfficePhone);
            contacterinfo.Operation = DataSecurity.HtmlEncode(contacterinfo.Operation);
            contacterinfo.Owner = DataSecurity.HtmlEncode(contacterinfo.Owner);
            contacterinfo.Phs = DataSecurity.HtmlEncode(contacterinfo.Phs);
            contacterinfo.Position = DataSecurity.HtmlEncode(contacterinfo.Position);
            contacterinfo.Province = DataSecurity.HtmlEncode(contacterinfo.Province);
            contacterinfo.QQ = DataSecurity.HtmlEncode(contacterinfo.QQ);
            contacterinfo.ShortedForm = DataSecurity.HtmlEncode(contacterinfo.ShortedForm);
            contacterinfo.Title = DataSecurity.HtmlEncode(contacterinfo.Title);
            contacterinfo.TrueName = DataSecurity.HtmlEncode(contacterinfo.TrueName);
            contacterinfo.UC = DataSecurity.HtmlEncode(contacterinfo.UC);
            contacterinfo.Yahoo = DataSecurity.HtmlEncode(contacterinfo.Yahoo);
            contacterinfo.ZipCode = DataSecurity.HtmlEncode(contacterinfo.ZipCode);
        }

        public static bool Exists(int contacterId)
        {
            return dal.Exists(contacterId);
        }

        public static bool Exists(string userName)
        {
            return dal.Exists(userName);
        }

        public static IList<ContacterInfo> GetAllMobileContacters()
        {
            return dal.GetAllMobileContacters();
        }

        public static ContacterInfo GetContacterByClientId(int clientId)
        {
            return GetContacterByClientId(clientId, true);
        }

        public static ContacterInfo GetContacterByClientId(int clientId, bool isDecode)
        {
            ContacterInfo contacterByClientId = dal.GetContacterByClientId(clientId);
            if (isDecode && !contacterByClientId.IsNull)
            {
                DecodeContacterInfo(contacterByClientId);
            }
            return contacterByClientId;
        }

        public static ContacterInfo GetContacterById(int contacterId)
        {
            return GetContacterById(contacterId, true);
        }

        public static ContacterInfo GetContacterById(int contacterId, bool isDecode)
        {
            ContacterInfo contacterById = dal.GetContacterById(contacterId);
            if (isDecode && !contacterById.IsNull)
            {
                DecodeContacterInfo(contacterById);
            }
            return contacterById;
        }

        public static ContacterInfo GetContacterByUserName(string userName)
        {
            return GetContacterByUserName(userName, true);
        }

        public static ContacterInfo GetContacterByUserName(string userName, bool isDecode)
        {
            ContacterInfo contacterByUserName = dal.GetContacterByUserName(userName);
            if (isDecode && !contacterByUserName.IsNull)
            {
                DecodeContacterInfo(contacterByUserName);
            }
            return contacterByUserName;
        }

        public static Dictionary<int, string> GetContacterListByClientId(int clientId)
        {
            if (clientId <= 0)
            {
                return new Dictionary<int, string>();
            }
            return dal.GetContacterListByClientId(clientId);
        }

        public static IList<ContacterInfo> GetList(int startRowIndexId, int maxNumberRows, int searchType, string keyword)
        {
            if (searchType == 1)
            {
                keyword = DataConverter.CLng(keyword).ToString();
            }
            else
            {
                keyword = DataSecurity.FilterBadChar(keyword);
            }
            return dal.GetList(startRowIndexId, maxNumberRows, searchType, keyword);
        }

        public static int GetMaxId()
        {
            return dal.GetMaxId();
        }

        public static IList<ContacterInfo> GetMobileContacterByGroupId(string groupId)
        {
            if (!DataValidator.IsValidId(groupId))
            {
                return new List<ContacterInfo>();
            }
            return dal.GetMobileContacterByGroupId(groupId);
        }

        public static IList<ContacterInfo> GetMobileContacterByRegion(string country, string province, string city)
        {
            if (string.IsNullOrEmpty(country))
            {
                country = "中华人民共和国";
            }
            return dal.GetMobileContacterByRegion(country, province, city);
        }

        public static IList<ContacterInfo> GetMobileContacterByTrueName(string trueName)
        {
            return dal.GetMobileContacterByTrueName(trueName);
        }

        public static IList<ContacterInfo> GetMobileContacterByUserId(int startId, int endId)
        {
            return dal.GetMobileContacterByUserId(startId, endId);
        }

        public static IList<ContacterInfo> GetMobileContacterByUserName(string userName)
        {
            return dal.GetMobileContacterByUserName(userName);
        }

        public static int GetTotalOfContacter(string searchType, string keyword)
        {
            return dal.GetTotalOfContacter();
        }

        public static bool Update(ContacterInfo contacterInfo)
        {
            EncodeContacterInfo(contacterInfo);
            return dal.Update(contacterInfo);
        }

        public static bool UpdateClientForSameCompany(int clientId, int companyId)
        {
            bool flag = true;
            if (companyId > 0)
            {
                flag = dal.UpdateClientForSameCompany(clientId, companyId);
            }
            return flag;
        }
    }
}

⌨️ 快捷键说明

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