Beispiel #1
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.Course DataRowToModel(DataRow row)
		{
			Danyl.SnnuURP.Model.Course model=new Danyl.SnnuURP.Model.Course();
			if (row != null)
			{
				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["CnameEnglish"]!=null)
				{
					model.CnameEnglish=row["CnameEnglish"].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["CourseCategory"]!=null && row["CourseCategory"].ToString()!="")
				{
					model.CourseCategory=int.Parse(row["CourseCategory"].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());
				}
			}
			return model;
		}
Beispiel #2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.Course GetModel(int Cid,int DeptId,int CourseCategory)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 Cid,Cname,CnameEnglish,DeptId,Years,Semaster,CourseAttribute,CourseCategory,Credit,TextBook,Hours,WeekHours from Course ");
			strSql.Append(" where [email protected] and [email protected] and [email protected] ");
			SqlParameter[] parameters = {
					new SqlParameter("@Cid", SqlDbType.Int,4),
					new SqlParameter("@DeptId", SqlDbType.Int,4),
					new SqlParameter("@CourseCategory", SqlDbType.Int,4)			};
			parameters[0].Value = Cid;
			parameters[1].Value = DeptId;
			parameters[2].Value = CourseCategory;

			Danyl.SnnuURP.Model.Course model=new Danyl.SnnuURP.Model.Course();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}