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

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

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

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

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

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

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

            return dal.GetModel(F_QuestionId);
        }

        /// <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<CallCenterApi.Model.T_Ask_Question> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_Ask_Question> DataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Ask_Question> modelList = new List<CallCenterApi.Model.T_Ask_Question>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Ask_Question model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Ask_Question();
                    if (dt.Rows[n]["F_QuestionId"] != null && dt.Rows[n]["F_QuestionId"].ToString() != "")
                    {
                        model.F_QuestionId = int.Parse(dt.Rows[n]["F_QuestionId"].ToString());
                    }
                    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_Type"] != null && dt.Rows[n]["F_Type"].ToString() != "")
                    {
                        model.F_Type = int.Parse(dt.Rows[n]["F_Type"].ToString());
                    }
                    if (dt.Rows[n]["F_Title"] != null && dt.Rows[n]["F_Title"].ToString() != "")
                    {
                        model.F_Title = dt.Rows[n]["F_Title"].ToString();
                    }
                    if (dt.Rows[n]["F_Content"] != null && dt.Rows[n]["F_Content"].ToString() != "")
                    {
                        model.F_Content = dt.Rows[n]["F_Content"].ToString();
                    }
                    if (dt.Rows[n]["F_Remark"] != null && dt.Rows[n]["F_Remark"].ToString() != "")
                    {
                        model.F_Remark = dt.Rows[n]["F_Remark"].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_ModifyOn"] != null && dt.Rows[n]["F_ModifyOn"].ToString() != "")
                    {
                        model.F_ModifyOn = DateTime.Parse(dt.Rows[n]["F_ModifyOn"].ToString());
                    }
                    if (dt.Rows[n]["F_ModifyBy"] != null && dt.Rows[n]["F_ModifyBy"].ToString() != "")
                    {
                        model.F_ModifyBy = int.Parse(dt.Rows[n]["F_ModifyBy"].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());
                    }
                    if (dt.Rows[n]["F_SortModel"] != null && dt.Rows[n]["F_SortModel"].ToString() != "")
                    {
                        model.F_SortModel = int.Parse(dt.Rows[n]["F_SortModel"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_Ask_PagerItemsQuestion> DataTableToPagerItemList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Ask_PagerItemsQuestion> modelList = new List<CallCenterApi.Model.T_Ask_PagerItemsQuestion>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Ask_PagerItemsQuestion model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Ask_PagerItemsQuestion();
                    if (dt.Rows[n]["F_ItemId"] != null && dt.Rows[n]["F_ItemId"].ToString() != "")
                    {
                        model.F_ItemId = int.Parse(dt.Rows[n]["F_ItemId"].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_QuestionId"] != null && dt.Rows[n]["F_QuestionId"].ToString() != "")
                    {
                        model.F_QuestionId = int.Parse(dt.Rows[n]["F_QuestionId"].ToString());
                    }
                    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_Type"] != null && dt.Rows[n]["F_Type"].ToString() != "")
                    {
                        model.F_Type = int.Parse(dt.Rows[n]["F_Type"].ToString());
                    }
                    if (dt.Rows[n]["F_Title"] != null && dt.Rows[n]["F_Title"].ToString() != "")
                    {
                        model.F_Title = dt.Rows[n]["F_Title"].ToString();
                    }
                    if (dt.Rows[n]["F_Content"] != null && dt.Rows[n]["F_Content"].ToString() != "")
                    {
                        model.F_Content = dt.Rows[n]["F_Content"].ToString();
                    }
                    if (dt.Rows[n]["F_Remark"] != null && dt.Rows[n]["F_Remark"].ToString() != "")
                    {
                        model.F_Remark = dt.Rows[n]["F_Remark"].ToString();
                    }
                    if (dt.Rows[n]["F_CategoryName"] != null && dt.Rows[n]["F_CategoryName"].ToString() != "")
                    {
                        model.F_CategoryName = dt.Rows[n]["F_CategoryName"].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
    }
}

