Beispiel #1
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.Class DataRowToModel(DataRow row)
		{
			Danyl.SnnuURP.Model.Class model=new Danyl.SnnuURP.Model.Class();
			if (row != null)
			{
				if(row["ClassId"]!=null && row["ClassId"].ToString()!="")
				{
					model.ClassId=int.Parse(row["ClassId"].ToString());
				}
				if(row["ClassName"]!=null)
				{
					model.ClassName=row["ClassName"].ToString();
				}
				if(row["MajorId"]!=null && row["MajorId"].ToString()!="")
				{
					model.MajorId=int.Parse(row["MajorId"].ToString());
				}
				if(row["Grade"]!=null)
				{
					model.Grade=row["Grade"].ToString();
				}
				if(row["StuCount"]!=null && row["StuCount"].ToString()!="")
				{
					model.StuCount=int.Parse(row["StuCount"].ToString());
				}
				if(row["DistrictId"]!=null && row["DistrictId"].ToString()!="")
				{
					model.DistrictId=int.Parse(row["DistrictId"].ToString());
				}
			}
			return model;
		}
Beispiel #2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.Class GetModel(int ClassId,int MajorId,int DistrictId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 ClassId,ClassName,MajorId,Grade,StuCount,DistrictId from Class ");
			strSql.Append(" where ClassId=@ClassId and MajorId=@MajorId and DistrictId=@DistrictId ");
			SqlParameter[] parameters = {
					new SqlParameter("@ClassId", SqlDbType.Int,4),
					new SqlParameter("@MajorId", SqlDbType.Int,4),
					new SqlParameter("@DistrictId", SqlDbType.Int,4)			};
			parameters[0].Value = ClassId;
			parameters[1].Value = MajorId;
			parameters[2].Value = DistrictId;

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