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

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

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

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

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

            return dal.Delete(F_ItemId);
        }

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

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

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

            return dal.GetModel(F_ItemId);
        }

        /// <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_QuestionItems> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_Ask_QuestionItems> DataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Ask_QuestionItems> modelList = new List<CallCenterApi.Model.T_Ask_QuestionItems>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Ask_QuestionItems model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Ask_QuestionItems();
                    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_QuestionId"] != null && dt.Rows[n]["F_QuestionId"].ToString() != "")
                    {
                        model.F_QuestionId = int.Parse(dt.Rows[n]["F_QuestionId"].ToString());
                    }
                    model.F_ItemName = dt.Rows[n]["F_ItemName"].ToString();
                    if (dt.Rows[n]["F_IsAnswer"] != null && dt.Rows[n]["F_IsAnswer"].ToString() != "")
                    {
                        model.F_IsAnswer = int.Parse(dt.Rows[n]["F_IsAnswer"].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_Sort"] != null && dt.Rows[n]["F_Sort"].ToString() != "")
                    {
                        model.F_Sort = int.Parse(dt.Rows[n]["F_Sort"].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_QuestionItems> TempDataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Ask_QuestionItems> modelList = new List<CallCenterApi.Model.T_Ask_QuestionItems>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Ask_QuestionItems model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Ask_QuestionItems();
                    if (dt.Rows[n]["F_Id"] != null && dt.Rows[n]["F_Id"].ToString() != "")
                    {
                        model.F_ItemId = int.Parse(dt.Rows[n]["F_Id"].ToString());
                    }
                    if (dt.Rows[n]["ExpandIntField1"] != null && dt.Rows[n]["ExpandIntField1"].ToString() != "")
                    {
                        model.F_QuestionId = int.Parse(dt.Rows[n]["ExpandIntField1"].ToString());
                    }
                    model.F_ItemName = dt.Rows[n]["ExpandVchField1"].ToString();
                    if (dt.Rows[n]["ExpandIntField2"] != null && dt.Rows[n]["ExpandIntField2"].ToString() != "")
                    {
                        model.F_IsAnswer = int.Parse(dt.Rows[n]["ExpandIntField2"].ToString());
                    }
                    model.F_Remark = dt.Rows[n]["ExpandVchField2"].ToString();
                    if (dt.Rows[n]["ExpandIntField3"] != null && dt.Rows[n]["ExpandIntField3"].ToString() != "")
                    {
                        model.F_Sort = int.Parse(dt.Rows[n]["ExpandIntField3"].ToString());
                    }
                    if (dt.Rows[n]["ExpandIntField4"] != null && dt.Rows[n]["ExpandIntField4"].ToString() != "")
                    {
                        model.F_SortModel = int.Parse(dt.Rows[n]["ExpandIntField4"].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
    }
}

