using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ZXDT.CallCenter.Model;

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

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

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

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

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

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZXDT.CallCenter.Model.T_QC_IndexCategory GetModel(int F_CategoryId)
        {

            return dal.GetModel(F_CategoryId);
        }

        /// <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_QC_IndexCategory> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ZXDT.CallCenter.Model.T_QC_IndexCategory> DataTableToList(DataTable dt)
        {
            List<ZXDT.CallCenter.Model.T_QC_IndexCategory> modelList = new List<ZXDT.CallCenter.Model.T_QC_IndexCategory>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ZXDT.CallCenter.Model.T_QC_IndexCategory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ZXDT.CallCenter.Model.T_QC_IndexCategory();
                    if (dt.Rows[n]["F_CategoryId"] != null && dt.Rows[n]["F_CategoryId"].ToString() != "")
                    {
                        model.F_CategoryId = int.Parse(dt.Rows[n]["F_CategoryId"].ToString());
                    }
                    if (dt.Rows[n]["F_CategoryNumber"] != null && dt.Rows[n]["F_CategoryNumber"].ToString() != "")
                    {
                        model.F_CategoryNumber = dt.Rows[n]["F_CategoryNumber"].ToString();
                    }
                    if (dt.Rows[n]["F_CategoryName"] != null && dt.Rows[n]["F_CategoryName"].ToString() != "")
                    {
                        model.F_CategoryName = dt.Rows[n]["F_CategoryName"].ToString();
                    }
                    if (dt.Rows[n]["F_CategoryEName"] != null && dt.Rows[n]["F_CategoryEName"].ToString() != "")
                    {
                        model.F_CategoryEName = dt.Rows[n]["F_CategoryEName"].ToString();
                    }
                    if (dt.Rows[n]["F_Layer"] != null && dt.Rows[n]["F_Layer"].ToString() != "")
                    {
                        model.F_Layer = int.Parse(dt.Rows[n]["F_Layer"].ToString());
                    }
                    if (dt.Rows[n]["F_ParentId"] != null && dt.Rows[n]["F_ParentId"].ToString() != "")
                    {
                        model.F_ParentId = int.Parse(dt.Rows[n]["F_ParentId"].ToString());
                    }
                    if (dt.Rows[n]["F_CategoryType"] != null && dt.Rows[n]["F_CategoryType"].ToString() != "")
                    {
                        model.F_CategoryType = int.Parse(dt.Rows[n]["F_CategoryType"].ToString());
                    }
                    if (dt.Rows[n]["F_CanDelete"] != null && dt.Rows[n]["F_CanDelete"].ToString() != "")
                    {
                        model.F_CanDelete = int.Parse(dt.Rows[n]["F_CanDelete"].ToString());
                    }
                    if (dt.Rows[n]["F_IsCommon"] != null && dt.Rows[n]["F_IsCommon"].ToString() != "")
                    {
                        model.F_IsCommon = int.Parse(dt.Rows[n]["F_IsCommon"].ToString());
                    }
                    if (dt.Rows[n]["F_Sort"] != null && dt.Rows[n]["F_Sort"].ToString() != "")
                    {
                        model.F_Sort = int.Parse(dt.Rows[n]["F_Sort"].ToString());
                    }
                    if (dt.Rows[n]["F_Expand1"] != null && dt.Rows[n]["F_Expand1"].ToString() != "")
                    {
                        model.F_Expand1 = dt.Rows[n]["F_Expand1"].ToString();
                    }
                    if (dt.Rows[n]["F_Expand2"] != null && dt.Rows[n]["F_Expand2"].ToString() != "")
                    {
                        model.F_Expand2 = dt.Rows[n]["F_Expand2"].ToString();
                    }
                    if (dt.Rows[n]["F_CreateOn"] != null && dt.Rows[n]["F_CreateOn"].ToString() != "")
                    {
                        model.F_CreateOn = DateTime.Parse(dt.Rows[n]["F_CreateOn"].ToString());
                    }
                    if (dt.Rows[n]["F_CreateBy"] != null && dt.Rows[n]["F_CreateBy"].ToString() != "")
                    {
                        model.F_CreateBy = int.Parse(dt.Rows[n]["F_CreateBy"].ToString());
                    }
                    if (dt.Rows[n]["F_DeleteFlag"] != null && dt.Rows[n]["F_DeleteFlag"].ToString() != "")
                    {
                        model.F_DeleteFlag = int.Parse(dt.Rows[n]["F_DeleteFlag"].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
        #region 获取树结构
        /// <summary>
        ///  获得当前节点下的所有子集以tree的格式
        /// </summary>
        public TreeNodeModel GetMenuJsonModel(int parentId)
        {
            return dal.GetMenuJsonModel(parentId);
        }


        #endregion
    }
}

