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

📄 clientdelete.cs

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

    public class ClientDelete
    {
        private static readonly IClientDelete dal = DataAccess.CreateClientDelete();
        private PowerEasy.Crm.CheckClientType m_CheckClientType;
        private string m_ClientIdList;
        private int m_Count;
        private string m_DeleteInfo;
        private string m_Exclusion;
        private string m_GroupIdList;

        private bool CheckClient(int clientId)
        {
            if (StringHelper.FoundCharInArr(this.Exclusion, "ExcludingBalance") && (Client.GetClientById(clientId).Balance > 0M))
            {
                return false;
            }
            if (StringHelper.FoundCharInArr(this.Exclusion, "ExcludingOrder") && (dal.GetOrderCount(clientId) > 0))
            {
                return false;
            }
            if (StringHelper.FoundCharInArr(this.Exclusion, "ExcludingBankroll") && (dal.GetBankrollItemCount(clientId) > 0))
            {
                return false;
            }
            if (StringHelper.FoundCharInArr(this.Exclusion, "ExcludingService") && (dal.GetServiceItemCount(clientId) > 0))
            {
                return false;
            }
            if (StringHelper.FoundCharInArr(this.Exclusion, "ExcludingComplain") && (dal.GetComplainItemCount(clientId) > 0))
            {
                return false;
            }
            return true;
        }

        public void Delete()
        {
            this.GetClientIdList();
            if (DataValidator.IsValidId(this.ClientIdList))
            {
                foreach (string str in this.ClientIdList.Split(new char[] { ',' }))
                {
                    int clientId = DataConverter.CLng(str);
                    if ((clientId != 0) && this.CheckClient(clientId))
                    {
                        this.DeleteCorrelativeInfo(clientId);
                    }
                }
            }
        }

        private bool DeleteCorrelativeInfo(int clientId)
        {
            if (Client.Delete(clientId.ToString()))
            {
                this.m_Count++;
            }
            else
            {
                return false;
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelOrder"))
            {
                dal.DelOrder(clientId);
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelBankroll"))
            {
                dal.DelBankrollItem(clientId);
            }
            else
            {
                dal.UpdateBankrollItem(clientId);
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelService"))
            {
                dal.DelServiceItem(clientId);
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelComplain"))
            {
                dal.DelComplainItem(clientId);
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelCompany"))
            {
                dal.DelCompany(clientId);
            }
            else
            {
                dal.UpdateCompany(clientId);
            }
            if (StringHelper.FoundCharInArr(this.DeleteInfo, "DelContacter"))
            {
                dal.DelContacter(clientId);
            }
            else
            {
                dal.UpdateContacter(clientId);
            }
            if (!StringHelper.FoundCharInArr(this.DeleteInfo, "DelUser"))
            {
                dal.UpdateUser(clientId);
            }
            else
            {
                foreach (KeyValuePair<int, string> pair in dal.GetUserIdByClientId(clientId))
                {
                    string str = pair.Value;
                    if (!string.IsNullOrEmpty(str))
                    {
                        IList<int> orderId = dal.GetOrderId(str);
                        if ((orderId.Count > 0) && dal.DelOrder(str))
                        {
                            foreach (int num in orderId)
                            {
                                dal.DelOrderItem(num);
                            }
                        }
                        dal.DelPaymentLog(str);
                        dal.DelBankrollItem(str);
                        dal.DelPointLog(str);
                        dal.DelValidLog(str);
                        if (dal.DelUser(clientId))
                        {
                            dal.DelContacter(str);
                        }
                    }
                }
            }
            return true;
        }

        private void GetClientIdList()
        {
            switch (this.CheckClientType)
            {
                case PowerEasy.Crm.CheckClientType.AppointId:
                    break;

                case PowerEasy.Crm.CheckClientType.AppointGroup:
                    this.ClientIdList = Client.GetClientIdByGroup(this.GroupIdList);
                    break;

                case PowerEasy.Crm.CheckClientType.All:
                    this.ClientIdList = Client.GetAllClientId();
                    return;

                default:
                    return;
            }
        }

        public PowerEasy.Crm.CheckClientType CheckClientType
        {
            get
            {
                return this.m_CheckClientType;
            }
            set
            {
                this.m_CheckClientType = value;
            }
        }

        public string ClientIdList
        {
            get
            {
                return this.m_ClientIdList;
            }
            set
            {
                this.m_ClientIdList = value;
            }
        }

        public int Count
        {
            get
            {
                return this.m_Count;
            }
        }

        public string DeleteInfo
        {
            get
            {
                return this.m_DeleteInfo;
            }
            set
            {
                this.m_DeleteInfo = value;
            }
        }

        public string Exclusion
        {
            get
            {
                return this.m_Exclusion;
            }
            set
            {
                this.m_Exclusion = value;
            }
        }

        public string GroupIdList
        {
            get
            {
                return this.m_GroupIdList;
            }
            set
            {
                this.m_GroupIdList = value;
            }
        }
    }
}

⌨️ 快捷键说明

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