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

namespace CallCenterApi.BLL
{
    /// <summary>
    /// 通话记录表
    /// </summary>
    public partial class T_Call_CallRecords_QC
    {
        private readonly DAL.T_Call_CallRecords_QC dal = new DAL.T_Call_CallRecords_QC();
        public T_Call_CallRecords_QC()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int CallRecordsId)
        {
            return dal.Exists(CallRecordsId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.T_Call_CallRecords_QC model)
        {
            return dal.Add(model);
        }

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

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateQC(Model.T_Call_CallRecords_QC model)
        {
            return dal.UpdateQC(model);
        }

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

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

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.T_Call_CallRecords_QC GetModel(int CallRecordsId)
        {

            return dal.GetModel(CallRecordsId);
        }

        /// <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<Model.T_Call_CallRecords_QC> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.T_Call_CallRecords_QC> DataTableToList(DataTable dt)
        {
            List<Model.T_Call_CallRecords_QC> modelList = new List<Model.T_Call_CallRecords_QC>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.T_Call_CallRecords_QC model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.T_Call_CallRecords_QC();
                    if (dt.Rows[n]["CallId"] != null && dt.Rows[n]["CallId"].ToString() != "")
                    {
                        model.CallId = dt.Rows[n]["CallId"].ToString();
                    }
                    if (dt.Rows[n]["CallNumber"] != null && dt.Rows[n]["CallNumber"].ToString() != "")
                    {
                        model.CallNumber = dt.Rows[n]["CallNumber"].ToString();
                    }
                    if (dt.Rows[n]["CusId"] != null && dt.Rows[n]["CusId"].ToString() != "")
                    {
                        model.CusId = dt.Rows[n]["CusId"].ToString();
                    }
                    if (dt.Rows[n]["CusCode"] != null && dt.Rows[n]["CusCode"].ToString() != "")
                    {
                        model.CusCode = dt.Rows[n]["CusCode"].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]["CallState"] != null && dt.Rows[n]["CallState"].ToString() != "")
                    {
                        model.CallState = int.Parse(dt.Rows[n]["CallState"].ToString());
                    }
                    if (dt.Rows[n]["DealType"] != null && dt.Rows[n]["DealType"].ToString() != "")
                    {
                        model.DealType = int.Parse(dt.Rows[n]["DealType"].ToString());
                    }
                    if (dt.Rows[n]["BeginTime"] != null && dt.Rows[n]["BeginTime"].ToString() != "")
                    {
                        model.BeginTime = DateTime.Parse(dt.Rows[n]["BeginTime"].ToString());
                    }
                    if (dt.Rows[n]["IvrStartTime"] != null && dt.Rows[n]["IvrStartTime"].ToString() != "")
                    {
                        model.IvrStartTime = DateTime.Parse(dt.Rows[n]["IvrStartTime"].ToString());
                    }
                    if (dt.Rows[n]["IvrEndTime"] != null && dt.Rows[n]["IvrEndTime"].ToString() != "")
                    {
                        model.IvrEndTime = DateTime.Parse(dt.Rows[n]["IvrEndTime"].ToString());
                    }
                    if (dt.Rows[n]["RingStartTime"] != null && dt.Rows[n]["RingStartTime"].ToString() != "")
                    {
                        model.RingStartTime = DateTime.Parse(dt.Rows[n]["RingStartTime"].ToString());
                    }
                    if (dt.Rows[n]["RingEndTime"] != null && dt.Rows[n]["RingEndTime"].ToString() != "")
                    {
                        model.RingEndTime = DateTime.Parse(dt.Rows[n]["RingEndTime"].ToString());
                    }
                    if (dt.Rows[n]["TalkStartTime"] != null && dt.Rows[n]["TalkStartTime"].ToString() != "")
                    {
                        model.TalkStartTime = DateTime.Parse(dt.Rows[n]["TalkStartTime"].ToString());
                    }
                    if (dt.Rows[n]["TalkEndTime"] != null && dt.Rows[n]["TalkEndTime"].ToString() != "")
                    {
                        model.TalkEndTime = DateTime.Parse(dt.Rows[n]["TalkEndTime"].ToString());
                    }
                    if (dt.Rows[n]["EndTime"] != null && dt.Rows[n]["EndTime"].ToString() != "")
                    {
                        model.EndTime = DateTime.Parse(dt.Rows[n]["EndTime"].ToString());
                    }
                    if (dt.Rows[n]["LongTime"] != null && dt.Rows[n]["LongTime"].ToString() != "")
                    {
                        model.LongTime = int.Parse(dt.Rows[n]["LongTime"].ToString());
                    }
                    if (dt.Rows[n]["IvrLongTime"] != null && dt.Rows[n]["IvrLongTime"].ToString() != "")
                    {
                        model.IvrLongTime = int.Parse(dt.Rows[n]["IvrLongTime"].ToString());
                    }
                    if (dt.Rows[n]["RingLongTime"] != null && dt.Rows[n]["RingLongTime"].ToString() != "")
                    {
                        model.RingLongTime = int.Parse(dt.Rows[n]["RingLongTime"].ToString());
                    }
                    if (dt.Rows[n]["TalkLongTime"] != null && dt.Rows[n]["TalkLongTime"].ToString() != "")
                    {
                        model.TalkLongTime = int.Parse(dt.Rows[n]["TalkLongTime"].ToString());
                    }
                    if (dt.Rows[n]["UserId"] != null && dt.Rows[n]["UserId"].ToString() != "")
                    {
                        model.UserId = int.Parse(dt.Rows[n]["UserId"].ToString());
                    }
                    if (dt.Rows[n]["UserCode"] != null && dt.Rows[n]["UserCode"].ToString() != "")
                    {
                        model.UserCode = dt.Rows[n]["UserCode"].ToString();
                    }
                    if (dt.Rows[n]["UserName"] != null && dt.Rows[n]["UserName"].ToString() != "")
                    {
                        model.UserName = dt.Rows[n]["UserName"].ToString();
                    }
                    if (dt.Rows[n]["ExtNumber"] != null && dt.Rows[n]["ExtNumber"].ToString() != "")
                    {
                        model.ExtNumber = dt.Rows[n]["ExtNumber"].ToString();
                    }
                    model.FilePath = dt.Rows[n]["FilePath"].ToString();
                    if (dt.Rows[n]["IsExitWorkOrder"] != null && dt.Rows[n]["IsExitWorkOrder"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsExitWorkOrder"].ToString() == "1") || (dt.Rows[n]["IsExitWorkOrder"].ToString().ToLower() == "true"))
                        {
                            model.IsExitWorkOrder = true;
                        }
                        else
                        {
                            model.IsExitWorkOrder = false;
                        }
                    }
                    if (dt.Rows[n]["IsDeal"] != null && dt.Rows[n]["IsDeal"].ToString() != "")
                    {
                        model.IsDeal = int.Parse(dt.Rows[n]["IsDeal"].ToString());
                    }
                    if (dt.Rows[n]["OperateType"] != null && dt.Rows[n]["OperateType"].ToString() != "")
                    {
                        model.OperateType = int.Parse(dt.Rows[n]["OperateType"].ToString());
                    }
                    if (dt.Rows[n]["OperateObject"] != null && dt.Rows[n]["OperateObject"].ToString() != "")
                    {
                        model.OperateObject = dt.Rows[n]["OperateObject"].ToString();
                    }
                    if (dt.Rows[n]["OperateTime"] != null && dt.Rows[n]["OperateTime"].ToString() != "")
                    {
                        model.OperateTime = DateTime.Parse(dt.Rows[n]["OperateTime"].ToString());
                    }
                    if (dt.Rows[n]["Remark"] != null && dt.Rows[n]["Remark"].ToString() != "")
                    {
                        model.Remark = dt.Rows[n]["Remark"].ToString();
                    }
                    if (dt.Rows[n]["MYD"] != null && dt.Rows[n]["MYD"].ToString() != "")
                    {
                        model.MYD = int.Parse(dt.Rows[n]["MYD"].ToString());
                    }
                    if (dt.Rows[n]["BusinessType"] != null && dt.Rows[n]["BusinessType"].ToString() != "")
                    {
                        model.BusinessType = int.Parse(dt.Rows[n]["BusinessType"].ToString());
                    }
                    if (dt.Rows[n]["Location"] != null && dt.Rows[n]["Location"].ToString() != "")
                    {
                        model.Location = dt.Rows[n]["Location"].ToString();
                    }
                    if (dt.Rows[n]["CallRecordsId"] != null && dt.Rows[n]["CallRecordsId"].ToString() != "")
                    {
                        model.CallRecordsId = int.Parse(dt.Rows[n]["CallRecordsId"].ToString());
                    }
                    if (dt.Rows[n]["WaitStartTime"] != null && dt.Rows[n]["WaitStartTime"].ToString() != "")
                    {
                        model.WaitStartTime = DateTime.Parse(dt.Rows[n]["WaitStartTime"].ToString());
                    }
                    if (dt.Rows[n]["WaitEndTime"] != null && dt.Rows[n]["WaitEndTime"].ToString() != "")
                    {
                        model.WaitEndTime = DateTime.Parse(dt.Rows[n]["WaitEndTime"].ToString());
                    }
                    if (dt.Rows[n]["WaitLongTime"] != null && dt.Rows[n]["WaitLongTime"].ToString() != "")
                    {
                        model.WaitLongTime = int.Parse(dt.Rows[n]["WaitLongTime"].ToString());
                    }
                    if (dt.Rows[n]["NoCallState"] != null && dt.Rows[n]["NoCallState"].ToString() != "")
                    {
                        model.NoCallState = int.Parse(dt.Rows[n]["NoCallState"].ToString());
                    }
                    if (dt.Rows[n]["WorkTimesDiff"] != null && dt.Rows[n]["WorkTimesDiff"].ToString() != "")
                    {
                        model.WorkTimesDiff = int.Parse(dt.Rows[n]["WorkTimesDiff"].ToString());
                    }
                    if (dt.Rows[n]["F_QCState"] != null && dt.Rows[n]["F_QCState"].ToString() != "")
                    {
                        model.F_QCState = int.Parse(dt.Rows[n]["F_QCState"].ToString());
                    }
                    if (dt.Rows[n]["F_QCScore"] != null && dt.Rows[n]["F_QCScore"].ToString() != "")
                    {
                        model.F_QCScore = decimal.Parse(dt.Rows[n]["F_QCScore"].ToString());
                    }
                    if (dt.Rows[n]["F_QCRemark"] != null && dt.Rows[n]["F_QCRemark"].ToString() != "")
                    {
                        model.F_QCRemark = dt.Rows[n]["F_QCRemark"].ToString();
                    }
                    if (dt.Rows[n]["F_QCUserId"] != null && dt.Rows[n]["F_QCUserId"].ToString() != "")
                    {
                        model.F_QCUserId = int.Parse(dt.Rows[n]["F_QCUserId"].ToString());
                    }
                    if (dt.Rows[n]["F_QCUserName"] != null && dt.Rows[n]["F_QCUserName"].ToString() != "")
                    {
                        model.F_QCUserName = dt.Rows[n]["F_QCUserName"].ToString();
                    }
                    if (dt.Rows[n]["F_QCTime"] != null && dt.Rows[n]["F_QCTime"].ToString() != "")
                    {
                        model.F_QCTime = DateTime.Parse(dt.Rows[n]["F_QCTime"].ToString());
                    }
                    if (dt.Rows[n]["F_QCIsSelect"] != null && dt.Rows[n]["F_QCIsSelect"].ToString() != "")
                    {
                        model.F_QCIsSelect = int.Parse(dt.Rows[n]["F_QCIsSelect"].ToString());
                    }
                    if (dt.Rows[n]["F_QCQuestion"] != null && dt.Rows[n]["F_QCQuestion"].ToString() != "")
                    {
                        model.F_QCQuestion = dt.Rows[n]["F_QCQuestion"].ToString();
                    }
                    if (dt.Rows[n]["F_QCAdvise"] != null && dt.Rows[n]["F_QCAdvise"].ToString() != "")
                    {
                        model.F_QCAdvise = dt.Rows[n]["F_QCAdvise"].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);
        }

        #endregion  Method
    }
}
