using System;
using System.Data;
using System.Collections.Generic;
using HySoft.Common;
using HySoft.BaseCallCenter.Model;
namespace HySoft.BaseCallCenter.BLL
{
    /// <summary>
    /// T_Wo_WorkOrderHistory
    /// </summary>
    public partial class T_Wo_WorkOrderHistory
    {
        private readonly HySoft.BaseCallCenter.DAL.T_Wo_WorkOrderHistory dal = new HySoft.BaseCallCenter.DAL.T_Wo_WorkOrderHistory();
        public T_Wo_WorkOrderHistory()
        { }
        #region  Method

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

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

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

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

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory GetModel(int F_HISTORYID)
        {

            return dal.GetModel(F_HISTORYID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        //public HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory GetModelByCache(int F_HISTORYID)
        //{

        //    string CacheKey = "T_Wo_WorkOrderHistoryModel-" + F_HISTORYID;
        //    object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(F_HISTORYID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory)objModel;
        //}

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        public DataSet GetListView(string strWhere)
        {
            return dal.GetListView(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.T_Wo_WorkOrderHistory> DataTableToListDetail(DataTable dt)
        {
            List<Model.T_Wo_WorkOrderHistory> modelList = new List<Model.T_Wo_WorkOrderHistory>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.T_Wo_WorkOrderHistory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModelDetail(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory> DataTableToList(DataTable dt)
        {
            List<HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory> modelList = new List<HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new HySoft.BaseCallCenter.Model.T_Wo_WorkOrderHistory();
                    if (dt.Rows[n]["F_HISTORYID"] != null && dt.Rows[n]["F_HISTORYID"].ToString() != "")
                    {
                        model.F_HISTORYID = int.Parse(dt.Rows[n]["F_HISTORYID"].ToString());
                    }
                    if (dt.Rows[n]["F_WORKORDERSTATEID"] != null && dt.Rows[n]["F_WORKORDERSTATEID"].ToString() != "")
                    {
                        model.F_WORKORDERSTATEID = int.Parse(dt.Rows[n]["F_WORKORDERSTATEID"].ToString());
                    }
                    if (dt.Rows[n]["F_OPTUSERID"] != null && dt.Rows[n]["F_OPTUSERID"].ToString() != "")
                    {
                        model.F_OPTUSERID = int.Parse(dt.Rows[n]["F_OPTUSERID"].ToString());
                    }
                    if (dt.Rows[n]["F_OPTDATE"] != null && dt.Rows[n]["F_OPTDATE"].ToString() != "")
                    {
                        model.F_OPTDATE = DateTime.Parse(dt.Rows[n]["F_OPTDATE"].ToString());
                    }
                    if (dt.Rows[n]["F_ELAPSEDTIME"] != null && dt.Rows[n]["F_ELAPSEDTIME"].ToString() != "")
                    {
                        model.F_ELAPSEDTIME = int.Parse(dt.Rows[n]["F_ELAPSEDTIME"].ToString());
                    }
                    if (dt.Rows[n]["F_NEXTOWNERARRID"] != null && dt.Rows[n]["F_NEXTOWNERARRID"].ToString() != "")
                    {
                        model.F_NEXTOWNERARRID = dt.Rows[n]["F_NEXTOWNERARRID"].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_OPTBTNID"] != null && dt.Rows[n]["F_OPTBTNID"].ToString() != "")
                    {
                        model.F_OPTBTNID = int.Parse(dt.Rows[n]["F_OPTBTNID"].ToString());
                    }
                    if (dt.Rows[n]["F_INSTANCEID"] != null && dt.Rows[n]["F_INSTANCEID"].ToString() != "")
                    {
                        model.F_INSTANCEID = int.Parse(dt.Rows[n]["F_INSTANCEID"].ToString());
                    }
                    if (dt.Rows[n]["F_TASKFLAG"] != null && dt.Rows[n]["F_TASKFLAG"].ToString() != "")
                    {
                        model.F_TASKFLAG = int.Parse(dt.Rows[n]["F_TASKFLAG"].ToString());
                    }

                    if (dt.Rows[n]["F_UserName"] != null && dt.Rows[n]["F_UserName"].ToString() != "")
                    {
                        model.F_UserName = dt.Rows[n]["F_UserName"].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_StateName"] != null && dt.Rows[n]["F_StateName"].ToString() != "")
                    {
                        model.F_StateName = dt.Rows[n]["F_StateName"].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
    }
}

