Beispiel #1
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.StuInfo DataRowToModel(DataRow row)
		{
			Danyl.SnnuURP.Model.StuInfo model=new Danyl.SnnuURP.Model.StuInfo();
			if (row != null)
			{
				if(row["Sid"]!=null && row["Sid"].ToString()!="")
				{
					model.Sid=int.Parse(row["Sid"].ToString());
				}
				if(row["Sname"]!=null)
				{
					model.Sname=row["Sname"].ToString();
				}
				if(row["SnameSpell"]!=null)
				{
					model.SnameSpell=row["SnameSpell"].ToString();
				}
				if(row["SnameEnglish"]!=null)
				{
					model.SnameEnglish=row["SnameEnglish"].ToString();
				}
				if(row["SnameOld"]!=null)
				{
					model.SnameOld=row["SnameOld"].ToString();
				}
				if(row["IdNumber"]!=null)
				{
					model.IdNumber=row["IdNumber"].ToString();
				}
				if(row["Sex"]!=null && row["Sex"].ToString()!="")
				{
					if((row["Sex"].ToString()=="1")||(row["Sex"].ToString().ToLower()=="true"))
					{
						model.Sex=true;
					}
					else
					{
						model.Sex=false;
					}
				}
				if(row["StuType"]!=null)
				{
					model.StuType=row["StuType"].ToString();
				}
				if(row["StuNationality"]!=null)
				{
					model.StuNationality=row["StuNationality"].ToString();
				}
				if(row["StuProvince"]!=null)
				{
					model.StuProvince=row["StuProvince"].ToString();
				}
				if(row["StuBirthday"]!=null && row["StuBirthday"].ToString()!="")
				{
					model.StuBirthday=DateTime.Parse(row["StuBirthday"].ToString());
				}
				if(row["StuPolitical"]!=null)
				{
					model.StuPolitical=row["StuPolitical"].ToString();
				}
				if(row["StuDept"]!=null && row["StuDept"].ToString()!="")
				{
					model.StuDept=int.Parse(row["StuDept"].ToString());
				}
				if(row["StuZipCode"]!=null)
				{
					model.StuZipCode=row["StuZipCode"].ToString();
				}
				if(row["StuEnrollDate"]!=null && row["StuEnrollDate"].ToString()!="")
				{
					model.StuEnrollDate=DateTime.Parse(row["StuEnrollDate"].ToString());
				}
				if(row["StuMajor"]!=null && row["StuMajor"].ToString()!="")
				{
					model.StuMajor=int.Parse(row["StuMajor"].ToString());
				}
				if(row["StuGrade"]!=null && row["StuGrade"].ToString()!="")
				{
					model.StuGrade=int.Parse(row["StuGrade"].ToString());
				}
				if(row["StuClassId"]!=null && row["StuClassId"].ToString()!="")
				{
					model.StuClassId=int.Parse(row["StuClassId"].ToString());
				}
				if(row["PlanId"]!=null && row["PlanId"].ToString()!="")
				{
					model.PlanId=int.Parse(row["PlanId"].ToString());
				}
				if(row["District"]!=null)
				{
					model.District=row["District"].ToString();
				}
			}
			return model;
		}
Beispiel #2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Danyl.SnnuURP.Model.StuInfo GetModel(int Sid,int StuMajor,int StuClassId,int PlanId)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 Sid,Sname,SnameSpell,SnameEnglish,SnameOld,IdNumber,Sex,StuType,StuNationality,StuProvince,StuBirthday,StuPolitical,StuDept,StuZipCode,StuEnrollDate,StuMajor,StuGrade,StuClassId,PlanId,District from StuInfo ");
			strSql.Append(" where Sid=@Sid and StuMajor=@StuMajor and StuClassId=@StuClassId and PlanId=@PlanId ");
			SqlParameter[] parameters = {
					new SqlParameter("@Sid", SqlDbType.Int,4),
					new SqlParameter("@StuMajor", SqlDbType.Int,4),
					new SqlParameter("@StuClassId", SqlDbType.Int,4),
					new SqlParameter("@PlanId", SqlDbType.Int,4)			};
			parameters[0].Value = Sid;
			parameters[1].Value = StuMajor;
			parameters[2].Value = StuClassId;
			parameters[3].Value = PlanId;

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