/// <summary> /// 得到一个对象实体 /// </summary> public Danyl.SnnuURP.Model.TeachCourseView DataRowToModel(DataRow row) { Danyl.SnnuURP.Model.TeachCourseView model = new Danyl.SnnuURP.Model.TeachCourseView(); if (row != null) { if (row["Tid"] != null && row["Tid"].ToString() != "") { model.Tid = int.Parse(row["Tid"].ToString()); } if (row["Tname"] != null) { model.Tname = row["Tname"].ToString(); } if (row["Cid"] != null && row["Cid"].ToString() != "") { model.Cid = int.Parse(row["Cid"].ToString()); } if (row["Cname"] != null) { model.Cname = row["Cname"].ToString(); } if (row["DeptId"] != null && row["DeptId"].ToString() != "") { model.DeptId = int.Parse(row["DeptId"].ToString()); } if (row["Years"] != null && row["Years"].ToString() != "") { model.Years = DateTime.Parse(row["Years"].ToString()); } if (row["Semaster"] != null && row["Semaster"].ToString() != "") { model.Semaster = int.Parse(row["Semaster"].ToString()); } if (row["CourseAttribute"] != null) { model.CourseAttribute = row["CourseAttribute"].ToString(); } if (row["Credit"] != null && row["Credit"].ToString() != "") { model.Credit = decimal.Parse(row["Credit"].ToString()); } if (row["TextBook"] != null) { model.TextBook = row["TextBook"].ToString(); } if (row["Hours"] != null && row["Hours"].ToString() != "") { model.Hours = int.Parse(row["Hours"].ToString()); } if (row["WeekHours"] != null && row["WeekHours"].ToString() != "") { model.WeekHours = int.Parse(row["WeekHours"].ToString()); } if (row["CourseRemainder"] != null && row["CourseRemainder"].ToString() != "") { model.CourseRemainder = int.Parse(row["CourseRemainder"].ToString()); } if (row["Section"] != null && row["Section"].ToString() != "") { model.Section = int.Parse(row["Section"].ToString()); } if (row["Week"] != null) { model.Week = row["Week"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Danyl.SnnuURP.Model.TeachCourseView GetModel(int Tid, int Cid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Tid,Tname,Cid,Cname,DeptId,Years,Semaster,CourseAttribute,Credit,TextBook,Hours,WeekHours,CourseRemainder,Section,Week from TeachCourseView "); strSql.Append(" where Tid=@Tid and Cid=@Cid "); SqlParameter[] parameters = { new SqlParameter("@Tid", SqlDbType.Int,4), new SqlParameter("@Cid", SqlDbType.Int,4) }; parameters[0].Value = Tid; parameters[1].Value = Cid; Danyl.SnnuURP.Model.TeachCourseView model = new Danyl.SnnuURP.Model.TeachCourseView(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }