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

            if (rowsCount > 0)
            {
                dbamet.Model.UserList model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new dbamet.Model.UserList();
                    if (dt.Rows[n]["customId"] != null && dt.Rows[n]["customId"].ToString() != "")
                    {
                        model.customId = dt.Rows[n]["customId"].ToString();
                    }
                    if (dt.Rows[n]["customName"] != null && dt.Rows[n]["customName"].ToString() != "")
                    {
                        model.customName = dt.Rows[n]["customName"].ToString();
                    }
                    if (dt.Rows[n]["birth"] != null && dt.Rows[n]["birth"].ToString() != "")
                    {
                        model.birth = DateTime.Parse(dt.Rows[n]["birth"].ToString());
                    }
                    if (dt.Rows[n]["duty"] != null && dt.Rows[n]["duty"].ToString() != "")
                    {
                        model.duty = dt.Rows[n]["duty"].ToString();
                    }
                    if (dt.Rows[n]["className"] != null && dt.Rows[n]["className"].ToString() != "")
                    {
                        model.className = dt.Rows[n]["className"].ToString();
                    }
                    if (dt.Rows[n]["sex"] != null && dt.Rows[n]["sex"].ToString() != "")
                    {
                        model.sex = dt.Rows[n]["sex"].ToString();
                    }
                    if (dt.Rows[n]["interest"] != null && dt.Rows[n]["interest"].ToString() != "")
                    {
                        model.interest = dt.Rows[n]["interest"].ToString();
                    }
                    if (dt.Rows[n]["tel"] != null && dt.Rows[n]["tel"].ToString() != "")
                    {
                        model.tel = dt.Rows[n]["tel"].ToString();
                    }
                    if (dt.Rows[n]["intro"] != null && dt.Rows[n]["intro"].ToString() != "")
                    {
                        model.intro = dt.Rows[n]["intro"].ToString();
                    }
                    if (dt.Rows[n]["point"] != null && dt.Rows[n]["point"].ToString() != "")
                    {
                        model.point = int.Parse(dt.Rows[n]["point"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
示例#2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(dbamet.Model.UserList model)
 {
     return(dal.Update(model));
 }
示例#3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(dbamet.Model.UserList model)
 {
     return(dal.Add(model));
 }