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_Sys_WorkOFFDays
    {
        private readonly CallCenterApi.DAL.T_Sys_WorkOFFDays dal = new CallCenterApi.DAL.T_Sys_WorkOFFDays();
        public T_Sys_WorkOFFDays()
        { }
        #region  Method

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

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

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

            return dal.Delete(F_OffID);
        }
        public bool DeleteByDate(string date, string usercode, DateTime nowdate)
        {
            return dal.DeleteByDate(date, usercode,nowdate);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string F_OffIDlist)
        {
            return dal.DeleteList(F_OffIDlist);
        }

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

            return dal.GetModel(F_OffID);
        }
        public CallCenterApi.Model.T_Sys_WorkOFFDays GetModel(string date)
        {

            return dal.GetModel(date);
        }

        /// <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_Sys_WorkOFFDays> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_Sys_WorkOFFDays> DataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_Sys_WorkOFFDays> modelList = new List<CallCenterApi.Model.T_Sys_WorkOFFDays>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_Sys_WorkOFFDays model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_Sys_WorkOFFDays();
                    if (dt.Rows[n]["F_OffID"] != null && dt.Rows[n]["F_OffID"].ToString() != "")
                    {
                        model.F_OffID = int.Parse(dt.Rows[n]["F_OffID"].ToString());
                    }
                    if (dt.Rows[n]["F_OffDate"] != null && dt.Rows[n]["F_OffDate"].ToString() != "")
                    {
                        model.F_OffDate = DateTime.Parse(dt.Rows[n]["F_OffDate"].ToString());
                    }
                    if (dt.Rows[n]["F_OffState"] != null && dt.Rows[n]["F_OffState"].ToString() != "")
                    {
                        model.F_OffState = int.Parse(dt.Rows[n]["F_OffState"].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_CreateBy"] != null && dt.Rows[n]["F_CreateBy"].ToString() != "")
                    {
                        model.F_CreateBy = dt.Rows[n]["F_CreateBy"].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_DeleteBy"] != null && dt.Rows[n]["F_DeleteBy"].ToString() != "")
                    {
                        model.F_DeleteBy = dt.Rows[n]["F_DeleteBy"].ToString();
                    }
                    if (dt.Rows[n]["F_DeleteOn"] != null && dt.Rows[n]["F_DeleteOn"].ToString() != "")
                    {
                        model.F_DeleteOn = DateTime.Parse(dt.Rows[n]["F_DeleteOn"].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
    }
}
