Example #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <hm.Model.dept> DataTableToList(DataTable dt)
        {
            List <hm.Model.dept> modelList = new List <hm.Model.dept>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                hm.Model.dept model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new hm.Model.dept();
                    if (dt.Rows[n]["deptId"] != null && dt.Rows[n]["deptId"].ToString() != "")
                    {
                        model.deptId = int.Parse(dt.Rows[n]["deptId"].ToString());
                    }
                    if (dt.Rows[n]["parentId"] != null && dt.Rows[n]["parentId"].ToString() != "")
                    {
                        model.parentId = int.Parse(dt.Rows[n]["parentId"].ToString());
                    }
                    if (dt.Rows[n]["deptName"] != null && dt.Rows[n]["deptName"].ToString() != "")
                    {
                        model.deptName = dt.Rows[n]["deptName"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<hm.Model.dept> DataTableToList(DataTable dt)
 {
     List<hm.Model.dept> modelList = new List<hm.Model.dept>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         hm.Model.dept model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new hm.Model.dept();
             if(dt.Rows[n]["deptId"]!=null && dt.Rows[n]["deptId"].ToString()!="")
             {
                 model.deptId=int.Parse(dt.Rows[n]["deptId"].ToString());
             }
             if(dt.Rows[n]["parentId"]!=null && dt.Rows[n]["parentId"].ToString()!="")
             {
                 model.parentId=int.Parse(dt.Rows[n]["parentId"].ToString());
             }
             if(dt.Rows[n]["deptName"]!=null && dt.Rows[n]["deptName"].ToString()!="")
             {
             model.deptName=dt.Rows[n]["deptName"].ToString();
             }
             if(dt.Rows[n]["userId"]!=null && dt.Rows[n]["userId"].ToString()!="")
             {
                 model.userId=int.Parse(dt.Rows[n]["userId"].ToString());
             }
             if(dt.Rows[n]["manager"]!=null && dt.Rows[n]["manager"].ToString()!="")
             {
             model.manager=dt.Rows[n]["manager"].ToString();
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Example #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(hm.Model.dept model)
 {
     return(dal.Update(model));
 }
Example #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(hm.Model.dept model)
 {
     return(dal.Add(model));
 }