public IList<Core.Business.TeachingPlan> GetAllTeachingPlan() { IList<Core.Business.TeachingPlan> teachingPlanlist = new List<Core.Business.TeachingPlan>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllTeachingPlan); if(reader != null) { while(reader.Read()) { Core.Business.TeachingPlan teachingPlan = new Core.Business.TeachingPlan(); if (!reader.IsDBNull(0)) teachingPlan.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) teachingPlan.ProCode = reader.GetString(1); if (!reader.IsDBNull(2)) teachingPlan.CourseCode = reader.GetString(2); if (!reader.IsDBNull(3)) teachingPlan.Term = reader.GetInt32(3); if (!reader.IsDBNull(4)) teachingPlan.CourseCate = reader.GetString(4); if (!reader.IsDBNull(5)) teachingPlan.IsTheory = reader.GetBoolean(5); if (!reader.IsDBNull(6)) teachingPlan.CrsNumPerTerm = reader.GetInt32(6); teachingPlan.MarkOld(); teachingPlanlist.Add(teachingPlan); } reader.Close(); } return teachingPlanlist; }
public Core.Business.TeachingPlan Select(int id) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@Id", SqlDbType.Int, id); SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectTeachingPlan); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.TeachingPlan teachingPlan = new Core.Business.TeachingPlan(); if (!reader.IsDBNull(0)) teachingPlan.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) teachingPlan.ProCode = reader.GetString(1); if (!reader.IsDBNull(2)) teachingPlan.CourseCode = reader.GetString(2); if (!reader.IsDBNull(3)) teachingPlan.Term = reader.GetInt32(3); if (!reader.IsDBNull(4)) teachingPlan.CourseCate = reader.GetString(4); if (!reader.IsDBNull(5)) teachingPlan.IsTheory = reader.GetBoolean(5); if (!reader.IsDBNull(6)) teachingPlan.CrsNumPerTerm = reader.GetInt32(6); reader.Close(); return teachingPlan; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }