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

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

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

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

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

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

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

            return dal.GetModel(F_EntityId);
        }

        /// <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_Form_EntityInfo> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_Form_EntityInfo> DataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Form_EntityInfo> modelList = new List<CallCenterApi.Model.T_Form_EntityInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Form_EntityInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Form_EntityInfo();
                    if (dt.Rows[n]["F_EntityId"] != null && dt.Rows[n]["F_EntityId"].ToString() != "")
                    {
                        model.F_EntityId = int.Parse(dt.Rows[n]["F_EntityId"].ToString());
                    }
                    if (dt.Rows[n]["F_Name"] != null && dt.Rows[n]["F_Name"].ToString() != "")
                    {
                        model.F_Name = dt.Rows[n]["F_Name"].ToString();
                    }
                    if (dt.Rows[n]["F_DBTableName"] != null && dt.Rows[n]["F_DBTableName"].ToString() != "")
                    {
                        model.F_DBTableName = dt.Rows[n]["F_DBTableName"].ToString();
                    }
                    if (dt.Rows[n]["F_IsActivity"] != null && dt.Rows[n]["F_IsActivity"].ToString() != "")
                    {
                        model.F_IsActivity = int.Parse(dt.Rows[n]["F_IsActivity"].ToString());
                    }
                    if (dt.Rows[n]["F_Des"] != null && dt.Rows[n]["F_Des"].ToString() != "")
                    {
                        model.F_Des = dt.Rows[n]["F_Des"].ToString();
                    }
                    if (dt.Rows[n]["F_LinkTableName"] != null && dt.Rows[n]["F_LinkTableName"].ToString() != "")
                    {
                        model.F_LinkTableName = dt.Rows[n]["F_LinkTableName"].ToString();
                    }
                    if (dt.Rows[n]["F_LinkFieldName"] != null && dt.Rows[n]["F_LinkFieldName"].ToString() != "")
                    {
                        model.F_LinkFieldName = dt.Rows[n]["F_LinkFieldName"].ToString();
                    }
                    if (dt.Rows[n]["F_CreateSQL"] != null && dt.Rows[n]["F_CreateSQL"].ToString() != "")
                    {
                        model.F_CreateSQL = dt.Rows[n]["F_CreateSQL"].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_ModifySQL"] != null && dt.Rows[n]["F_ModifySQL"].ToString() != "")
                    {
                        model.F_ModifySQL = dt.Rows[n]["F_ModifySQL"].ToString();
                    }
                    if (dt.Rows[n]["F_LastModifyOn"] != null && dt.Rows[n]["F_LastModifyOn"].ToString() != "")
                    {
                        model.F_LastModifyOn = DateTime.Parse(dt.Rows[n]["F_LastModifyOn"].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

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