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

namespace HySoft.BaseCallCenter.BLL
{
    public class LDWorkOrderCount
    {
        public List<Model.LDWorkOrderCount> DataTableToList(DataTable dt)
        {
            List<HySoft.BaseCallCenter.Model.LDWorkOrderCount> modelList = new List<HySoft.BaseCallCenter.Model.LDWorkOrderCount>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HySoft.BaseCallCenter.Model.LDWorkOrderCount model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new DAL.LDWorkOrderCount().DataRowToModel(dt.Rows[n]);
                    model.F_DEPTNAME = model.F_DEPTNAME = getDeptName(model.F_DEPTID);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        private string getDeptName(int deptid)
        {
            var dept = new BLL.T_Sys_Department().GetModel(deptid);
            if (dept != null)
                return dept.F_DeptName;
            else return "";
        }
    }
}
