Example #1
0
        /// <summary>
        /// 得到下一个或上一个实体
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Spread.Model.Video GetUpDownModel(int Id, bool UpOrDown)
		{
			StringBuilder strSql=new StringBuilder();
            if (UpOrDown)
            {
                strSql.Append("select top 1 * from [Video] WHERE Id > @Id order by Id asc ");
            }
            else { strSql.Append("select * from [Video] WHERE Id < @Id order by Id desc "); }
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = Id;

			Spread.Model.Video model=new Spread.Model.Video();
			DataSet ds=DbHelper.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
				model.Title=ds.Tables[0].Rows[0]["Title"].ToString();
			
				model.Form=ds.Tables[0].Rows[0]["Form"].ToString();
			
				model.Zhaiyao=ds.Tables[0].Rows[0]["Zhaiyao"].ToString();
                model.GType = ds.Tables[0].Rows[0]["GType"].ToString();
                model.GFactory = ds.Tables[0].Rows[0]["GFactory"].ToString();
                model.GBrand = ds.Tables[0].Rows[0]["GBrand"].ToString();
                model.Code1 = ds.Tables[0].Rows[0]["Code1"].ToString();
                model.Code2 = ds.Tables[0].Rows[0]["Code2"].ToString();
                model.LanguageType = ds.Tables[0].Rows[0]["LanguageType"].ToString();                
				if(ds.Tables[0].Rows[0]["ClassId"].ToString()!="")
				{
					model.ClassId=int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
				}
				model.ImgUrl=ds.Tables[0].Rows[0]["ImgUrl"].ToString();
               
                
				if(ds.Tables[0].Rows[0]["IsMsg"].ToString()!="")
				{
					model.IsMsg=Convert.ToBoolean(ds.Tables[0].Rows[0]["IsMsg"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsTop"].ToString()!="")
				{
                    model.IsTop = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsTop"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsRed"].ToString()!="")
				{
                    model.IsRed = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsRed"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsHot"].ToString()!="")
				{
                    model.IsHot = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsHot"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsSlide"].ToString()!="")
				{
                    model.IsSlide = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSlide"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsLock"].ToString()!="")
				{
                    model.IsLock = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsLock"].ToString());
				}
				if(ds.Tables[0].Rows[0]["AddTime"].ToString()!="")
				{
					model.AddTime=DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
				}
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
              
				return model;
			}
			else
			{
				return null;
			}
		}
Example #2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Spread.Model.Video GetModel(int Id)
		{
			StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,Title,Form,ClassId,ImgUrl,IsMsg,IsTop,IsRed,IsHot,IsSlide,IsLock,AddTime,Zhaiyao,GType,GFactory,GBrand,Code1,Code2,LanguageType from Video ");
			strSql.Append(" where Id=@Id ");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = Id;

			Spread.Model.Video model=new Spread.Model.Video();
			DataSet ds=DbHelper.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
				model.Title=ds.Tables[0].Rows[0]["Title"].ToString();
				
				model.Form=ds.Tables[0].Rows[0]["Form"].ToString();
			
				model.Zhaiyao=ds.Tables[0].Rows[0]["Zhaiyao"].ToString();
                model.GType = ds.Tables[0].Rows[0]["GType"].ToString();
                model.GFactory = ds.Tables[0].Rows[0]["GFactory"].ToString();
                model.GBrand = ds.Tables[0].Rows[0]["GBrand"].ToString();
                model.Code1 = ds.Tables[0].Rows[0]["Code1"].ToString();
                model.Code2 = ds.Tables[0].Rows[0]["Code2"].ToString();
                model.LanguageType = ds.Tables[0].Rows[0]["LanguageType"].ToString();
				if(ds.Tables[0].Rows[0]["ClassId"].ToString()!="")
				{
					model.ClassId=int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
				}
				model.ImgUrl=ds.Tables[0].Rows[0]["ImgUrl"].ToString();
              
               
				if(ds.Tables[0].Rows[0]["IsMsg"].ToString()!="")
				{
					model.IsMsg=Convert.ToBoolean(ds.Tables[0].Rows[0]["IsMsg"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsTop"].ToString()!="")
				{
                    model.IsTop = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsTop"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsRed"].ToString()!="")
				{
                    model.IsRed = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsRed"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsHot"].ToString()!="")
				{
                    model.IsHot = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsHot"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsSlide"].ToString()!="")
				{
                    model.IsSlide = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSlide"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsLock"].ToString()!="")
				{
                    model.IsLock = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsLock"].ToString());
				}
				if(ds.Tables[0].Rows[0]["AddTime"].ToString()!="")
				{
					model.AddTime=DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
				}
               
                
				return model;
			}
			else
			{
				return null;
			}
		}