/// <summary> /// 获得数据列表 /// </summary> public List <StudentMS.Model.Student> DataTableToList(DataTable dt) { List <StudentMS.Model.Student> modelList = new List <StudentMS.Model.Student>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { StudentMS.Model.Student model; for (int n = 0; n < rowsCount; n++) { model = new StudentMS.Model.Student(); model.SNO = dt.Rows[n]["SNO"].ToString(); model.SName = dt.Rows[n]["SName"].ToString(); model.SSex = dt.Rows[n]["SSex"].ToString(); if (dt.Rows[n]["SBirthday"].ToString() != "") { model.SBirthday = DateTime.Parse(dt.Rows[n]["SBirthday"].ToString()); } model.DeptNO = dt.Rows[n]["DeptNO"].ToString(); if (dt.Rows[n]["SAge"].ToString() != "") { model.SAge = int.Parse(dt.Rows[n]["SAge"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(StudentMS.Model.Student model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(StudentMS.Model.Student model) { dal.Add(model); }