using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ZXDT.CallCenter.BLL
{
    /// <summary>
    /// 计划表
    /// </summary>
    public partial class T_CTI_Task
    {
        private readonly ZXDT.CallCenter.DAL.T_CTI_Task dal = new ZXDT.CallCenter.DAL.T_CTI_Task();
        public T_CTI_Task()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(long TaskID)
        {
            return dal.Exists(TaskID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(ZXDT.CallCenter.Model.T_CTI_Task model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZXDT.CallCenter.Model.T_CTI_Task model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateState(int id,int state)
        {
            return dal.UpdateState(id, state);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long TaskID)
        {

            return dal.Delete(TaskID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string TaskIDlist)
        {
            return dal.DeleteList(TaskIDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZXDT.CallCenter.Model.T_CTI_Task GetModel(long TaskID)
        {

            return dal.GetModel(TaskID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ZXDT.CallCenter.Model.T_CTI_Task> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ZXDT.CallCenter.Model.T_CTI_Task> DataTableToList(DataTable dt)
        {
            List<ZXDT.CallCenter.Model.T_CTI_Task> modelList = new List<ZXDT.CallCenter.Model.T_CTI_Task>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ZXDT.CallCenter.Model.T_CTI_Task model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ZXDT.CallCenter.Model.T_CTI_Task();
                    if (dt.Rows[n]["TaskID"] != null && dt.Rows[n]["TaskID"].ToString() != "")
                    {
                        model.TaskID = long.Parse(dt.Rows[n]["TaskID"].ToString());
                    }
                    if (dt.Rows[n]["TaskName"] != null && dt.Rows[n]["TaskName"].ToString() != "")
                    {
                        model.TaskName = dt.Rows[n]["TaskName"].ToString();
                    }
                    if (dt.Rows[n]["TrunkGroupID"] != null && dt.Rows[n]["TrunkGroupID"].ToString() != "")
                    {
                        model.TrunkGroupID = int.Parse(dt.Rows[n]["TrunkGroupID"].ToString());
                    }
                    if (dt.Rows[n]["CallerNum"] != null && dt.Rows[n]["CallerNum"].ToString() != "")
                    {
                        model.CallerNum = dt.Rows[n]["CallerNum"].ToString();
                    }
                    if (dt.Rows[n]["CallType"] != null && dt.Rows[n]["CallType"].ToString() != "")
                    {
                        model.CallType = int.Parse(dt.Rows[n]["CallType"].ToString());
                    }
                    if (dt.Rows[n]["ExInfo"] != null && dt.Rows[n]["ExInfo"].ToString() != "")
                    {
                        model.ExInfo = dt.Rows[n]["ExInfo"].ToString();
                    }
                    if (dt.Rows[n]["MaxTrunkCount"] != null && dt.Rows[n]["MaxTrunkCount"].ToString() != "")
                    {
                        model.MaxTrunkCount = int.Parse(dt.Rows[n]["MaxTrunkCount"].ToString());
                    }
                    if (dt.Rows[n]["IntensityCoefficient"] != null && dt.Rows[n]["IntensityCoefficient"].ToString() != "")
                    {
                        model.IntensityCoefficient = decimal.Parse(dt.Rows[n]["IntensityCoefficient"].ToString());
                    }
                    if (dt.Rows[n]["ItemTableName"] != null && dt.Rows[n]["ItemTableName"].ToString() != "")
                    {
                        model.ItemTableName = dt.Rows[n]["ItemTableName"].ToString();
                    }
                    if (dt.Rows[n]["State"] != null && dt.Rows[n]["State"].ToString() != "")
                    {
                        model.State = int.Parse(dt.Rows[n]["State"].ToString());
                    }
                    if (dt.Rows[n]["AddTime"] != null && dt.Rows[n]["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
                    }
                    if (dt.Rows[n]["y_PSort"] != null && dt.Rows[n]["y_PSort"].ToString() != "")
                    {
                        model.y_PSort = int.Parse(dt.Rows[n]["y_PSort"].ToString());
                    }
                    if (dt.Rows[n]["y_TkModelId"] != null && dt.Rows[n]["y_TkModelId"].ToString() != "")
                    {
                        model.y_TkModelId = long.Parse(dt.Rows[n]["y_TkModelId"].ToString());
                    }
                    if (dt.Rows[n]["y_SXH"] != null && dt.Rows[n]["y_SXH"].ToString() != "")
                    {
                        model.y_SXH = int.Parse(dt.Rows[n]["y_SXH"].ToString());
                    }
                    if (dt.Rows[n]["y_FPCount"] != null && dt.Rows[n]["y_FPCount"].ToString() != "")
                    {
                        model.y_FPCount = int.Parse(dt.Rows[n]["y_FPCount"].ToString());
                    }
                    if (dt.Rows[n]["y_YJCount"] != null && dt.Rows[n]["y_YJCount"].ToString() != "")
                    {
                        model.y_YJCount = int.Parse(dt.Rows[n]["y_YJCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HCCount"] != null && dt.Rows[n]["y_HCCount"].ToString() != "")
                    {
                        model.y_HCCount = int.Parse(dt.Rows[n]["y_HCCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HSCount"] != null && dt.Rows[n]["y_HSCount"].ToString() != "")
                    {
                        model.y_HSCount = int.Parse(dt.Rows[n]["y_HSCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HTCount"] != null && dt.Rows[n]["y_HTCount"].ToString() != "")
                    {
                        model.y_HTCount = int.Parse(dt.Rows[n]["y_HTCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HMCount"] != null && dt.Rows[n]["y_HMCount"].ToString() != "")
                    {
                        model.y_HMCount = int.Parse(dt.Rows[n]["y_HMCount"].ToString());
                    }
                    if (dt.Rows[n]["y_OkCount"] != null && dt.Rows[n]["y_OkCount"].ToString() != "")
                    {
                        model.y_OkCount = int.Parse(dt.Rows[n]["y_OkCount"].ToString());
                    }
                    if (dt.Rows[n]["y_RFCount"] != null && dt.Rows[n]["y_RFCount"].ToString() != "")
                    {
                        model.y_RFCount = int.Parse(dt.Rows[n]["y_RFCount"].ToString());
                    }
                    if (dt.Rows[n]["y_ConsCount"] != null && dt.Rows[n]["y_ConsCount"].ToString() != "")
                    {
                        model.y_ConsCount = int.Parse(dt.Rows[n]["y_ConsCount"].ToString());
                    }
                    if (dt.Rows[n]["y_InvlCount"] != null && dt.Rows[n]["y_InvlCount"].ToString() != "")
                    {
                        model.y_InvlCount = int.Parse(dt.Rows[n]["y_InvlCount"].ToString());
                    }
                    if (dt.Rows[n]["y_NoAnswerCount"] != null && dt.Rows[n]["y_NoAnswerCount"].ToString() != "")
                    {
                        model.y_NoAnswerCount = int.Parse(dt.Rows[n]["y_NoAnswerCount"].ToString());
                    }
                    if (dt.Rows[n]["y_ShutDownCount"] != null && dt.Rows[n]["y_ShutDownCount"].ToString() != "")
                    {
                        model.y_ShutDownCount = int.Parse(dt.Rows[n]["y_ShutDownCount"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ZXDT.CallCenter.Model.vw_CTI_TaskPager> DataTableToListPager(DataTable dt)
        {
            List<ZXDT.CallCenter.Model.vw_CTI_TaskPager> modelList = new List<ZXDT.CallCenter.Model.vw_CTI_TaskPager>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ZXDT.CallCenter.Model.vw_CTI_TaskPager model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ZXDT.CallCenter.Model.vw_CTI_TaskPager();
                    if (dt.Rows[n]["TaskID"] != null && dt.Rows[n]["TaskID"].ToString() != "")
                    {
                        model.TaskID = long.Parse(dt.Rows[n]["TaskID"].ToString());
                    }
                    if (dt.Rows[n]["TaskName"] != null && dt.Rows[n]["TaskName"].ToString() != "")
                    {
                        model.TaskName = dt.Rows[n]["TaskName"].ToString();
                    }
                    if (dt.Rows[n]["TrunkGroupID"] != null && dt.Rows[n]["TrunkGroupID"].ToString() != "")
                    {
                        model.TrunkGroupID = int.Parse(dt.Rows[n]["TrunkGroupID"].ToString());
                    }
                    if (dt.Rows[n]["CallerNum"] != null && dt.Rows[n]["CallerNum"].ToString() != "")
                    {
                        model.CallerNum = dt.Rows[n]["CallerNum"].ToString();
                    }
                    if (dt.Rows[n]["CallType"] != null && dt.Rows[n]["CallType"].ToString() != "")
                    {
                        model.CallType = int.Parse(dt.Rows[n]["CallType"].ToString());
                    }
                    if (dt.Rows[n]["ExInfo"] != null && dt.Rows[n]["ExInfo"].ToString() != "")
                    {
                        model.ExInfo = dt.Rows[n]["ExInfo"].ToString();
                    }
                    if (dt.Rows[n]["MaxTrunkCount"] != null && dt.Rows[n]["MaxTrunkCount"].ToString() != "")
                    {
                        model.MaxTrunkCount = int.Parse(dt.Rows[n]["MaxTrunkCount"].ToString());
                    }
                    if (dt.Rows[n]["IntensityCoefficient"] != null && dt.Rows[n]["IntensityCoefficient"].ToString() != "")
                    {
                        model.IntensityCoefficient = decimal.Parse(dt.Rows[n]["IntensityCoefficient"].ToString());
                    }
                    if (dt.Rows[n]["ItemTableName"] != null && dt.Rows[n]["ItemTableName"].ToString() != "")
                    {
                        model.ItemTableName = dt.Rows[n]["ItemTableName"].ToString();
                    }
                    if (dt.Rows[n]["State"] != null && dt.Rows[n]["State"].ToString() != "")
                    {
                        model.State = int.Parse(dt.Rows[n]["State"].ToString());
                    }
                    if (dt.Rows[n]["AddTime"] != null && dt.Rows[n]["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
                    }
                    if (dt.Rows[n]["y_PSort"] != null && dt.Rows[n]["y_PSort"].ToString() != "")
                    {
                        model.y_PSort = int.Parse(dt.Rows[n]["y_PSort"].ToString());
                    }
                    if (dt.Rows[n]["y_TkModelId"] != null && dt.Rows[n]["y_TkModelId"].ToString() != "")
                    {
                        model.y_TkModelId = long.Parse(dt.Rows[n]["y_TkModelId"].ToString());
                    }
                    if (dt.Rows[n]["y_SXH"] != null && dt.Rows[n]["y_SXH"].ToString() != "")
                    {
                        model.y_SXH = int.Parse(dt.Rows[n]["y_SXH"].ToString());
                    }
                    if (dt.Rows[n]["y_FPCount"] != null && dt.Rows[n]["y_FPCount"].ToString() != "")
                    {
                        model.y_FPCount = int.Parse(dt.Rows[n]["y_FPCount"].ToString());
                    }
                    if (dt.Rows[n]["y_YJCount"] != null && dt.Rows[n]["y_YJCount"].ToString() != "")
                    {
                        model.y_YJCount = int.Parse(dt.Rows[n]["y_YJCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HCCount"] != null && dt.Rows[n]["y_HCCount"].ToString() != "")
                    {
                        model.y_HCCount = int.Parse(dt.Rows[n]["y_HCCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HSCount"] != null && dt.Rows[n]["y_HSCount"].ToString() != "")
                    {
                        model.y_HSCount = int.Parse(dt.Rows[n]["y_HSCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HTCount"] != null && dt.Rows[n]["y_HTCount"].ToString() != "")
                    {
                        model.y_HTCount = int.Parse(dt.Rows[n]["y_HTCount"].ToString());
                    }
                    if (dt.Rows[n]["y_HMCount"] != null && dt.Rows[n]["y_HMCount"].ToString() != "")
                    {
                        model.y_HMCount = int.Parse(dt.Rows[n]["y_HMCount"].ToString());
                    }
                    if (dt.Rows[n]["y_OkCount"] != null && dt.Rows[n]["y_OkCount"].ToString() != "")
                    {
                        model.y_OkCount = int.Parse(dt.Rows[n]["y_OkCount"].ToString());
                    }
                    if (dt.Rows[n]["y_RFCount"] != null && dt.Rows[n]["y_RFCount"].ToString() != "")
                    {
                        model.y_RFCount = int.Parse(dt.Rows[n]["y_RFCount"].ToString());
                    }
                    if (dt.Rows[n]["y_ConsCount"] != null && dt.Rows[n]["y_ConsCount"].ToString() != "")
                    {
                        model.y_ConsCount = int.Parse(dt.Rows[n]["y_ConsCount"].ToString());
                    }
                    if (dt.Rows[n]["y_InvlCount"] != null && dt.Rows[n]["y_InvlCount"].ToString() != "")
                    {
                        model.y_InvlCount = int.Parse(dt.Rows[n]["y_InvlCount"].ToString());
                    }
                    if (dt.Rows[n]["y_NoAnswerCount"] != null && dt.Rows[n]["y_NoAnswerCount"].ToString() != "")
                    {
                        model.y_NoAnswerCount = int.Parse(dt.Rows[n]["y_NoAnswerCount"].ToString());
                    }
                    if (dt.Rows[n]["y_ShutDownCount"] != null && dt.Rows[n]["y_ShutDownCount"].ToString() != "")
                    {
                        model.y_ShutDownCount = int.Parse(dt.Rows[n]["y_ShutDownCount"].ToString());
                    }
                    model.F_Title = dt.Rows[n]["F_Title"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

