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

namespace RMYY_CallCenter_Api.Bll
{
    /// <summary>
	/// 休息日表
	/// </summary>
	public partial class T_Sys_WorkOffDays
    {
        private readonly RMYY_CallCenter_Api.Dal.T_Sys_WorkOffDays dal = new RMYY_CallCenter_Api.Dal.T_Sys_WorkOffDays();
        public T_Sys_WorkOffDays()
        { }
        #region  Method

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

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays model)
        {
            return dal.Update(model);
        }
        public bool UpdateState(RMYY_CallCenter_Api.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 RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays GetModel(int F_OffID)
        {

            return dal.GetModel(F_OffID);
        }
        public RMYY_CallCenter_Api.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<RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays> DataTableToList(DataTable dt)
        {
            List<RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays> modelList = new List<RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RMYY_CallCenter_Api.Model.T_Sys_WorkOffDays model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new RMYY_CallCenter_Api.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);
        }

        #endregion  Method
    }
}
