Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Ncu.jsj.Model.Student> DataTableToList(DataTable dt)
        {
            List <Ncu.jsj.Model.Student> modelList = new List <Ncu.jsj.Model.Student>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Ncu.jsj.Model.Student model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Ncu.jsj.Model.Student();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["name"] != null && dt.Rows[n]["name"].ToString() != "")
                    {
                        model.name = dt.Rows[n]["name"].ToString();
                    }
                    if (dt.Rows[n]["age"] != null && dt.Rows[n]["age"].ToString() != "")
                    {
                        model.age = int.Parse(dt.Rows[n]["age"].ToString());
                    }
                    if (dt.Rows[n]["pictureurl"] != null && dt.Rows[n]["pictureurl"].ToString() != "")
                    {
                        model.pictureurl = dt.Rows[n]["pictureurl"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Ncu.jsj.Model.Student model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Ncu.jsj.Model.Student model)
 {
     return(dal.Add(model));
 }