/// <summary> /// 得到一个对象实体 /// </summary> public Danyl.SnnuURP.Model.TeacherScoreView DataRowToModel(DataRow row) { Danyl.SnnuURP.Model.TeacherScoreView model = new Danyl.SnnuURP.Model.TeacherScoreView(); if (row != null) { if (row["Sid"] != null && row["Sid"].ToString() != "") { model.Sid = int.Parse(row["Sid"].ToString()); } if (row["Tid"] != null && row["Tid"].ToString() != "") { model.Tid = int.Parse(row["Tid"].ToString()); } if (row["Cname"] != null) { model.Cname = row["Cname"].ToString(); } if (row["Sname"] != null) { model.Sname = row["Sname"].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["UsualScore"] != null && row["UsualScore"].ToString() != "") { model.UsualScore = int.Parse(row["UsualScore"].ToString()); } if (row["MidtermScore"] != null && row["MidtermScore"].ToString() != "") { model.MidtermScore = int.Parse(row["MidtermScore"].ToString()); } if (row["FinalExamScore"] != null && row["FinalExamScore"].ToString() != "") { model.FinalExamScore = int.Parse(row["FinalExamScore"].ToString()); } if (row["TotalScore"] != null && row["TotalScore"].ToString() != "") { model.TotalScore = int.Parse(row["TotalScore"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Danyl.SnnuURP.Model.TeacherScoreView GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Sid,Tid,Cname,Sname,Years,Semaster,UsualScore,MidtermScore,FinalExamScore,TotalScore from TeacherScoreView "); strSql.Append(" where "); SqlParameter[] parameters = { }; Danyl.SnnuURP.Model.TeacherScoreView model = new Danyl.SnnuURP.Model.TeacherScoreView(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }