Example #1
0
 //保存
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Spread.Model.Adbanner model = new Spread.Model.Adbanner();
     Spread.BLL.Adbanner bll = new Spread.BLL.Adbanner();
     model.Aid = this.pid;
     model.Title = this.txtTitle.Text.Trim();
     model.StartTime = DateTime.Parse(this.txtStartTime.Text.Trim());
     model.EndTime = DateTime.Parse(this.txtEndTime.Text.Trim());
     model.AdUrl = this.txtImgUrl.Text.Trim();
     model.LinkUrl = this.txtLinkUrl.Text.Trim();
     model.AdRemark = StringPlus.ToHtml(this.txtAdRemark.Text);
     model.IsLock =Convert.ToBoolean(this.rblIsLock.SelectedValue);
     model.AddTime = DateTime.Now;
     bll.Add(model);
     JscriptPrint("广告发布成功啦!", "BarAdd.aspx?Pid=" + this.pid, "Success");
 }
Example #2
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Spread.Model.Adbanner GetModel(int Id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select Id,Aid,Title,StartTime,EndTime,AdUrl,LinkUrl,AdRemark,IsLock,AddTime from Adbanner ");
			strSql.Append(" where Id=@Id ");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = Id;

			Spread.Model.Adbanner model=new Spread.Model.Adbanner();
			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());
				}
				if(ds.Tables[0].Rows[0]["Aid"].ToString()!="")
				{
					model.Aid=int.Parse(ds.Tables[0].Rows[0]["Aid"].ToString());
				}
				model.Title=ds.Tables[0].Rows[0]["Title"].ToString();
				if(ds.Tables[0].Rows[0]["StartTime"].ToString()!="")
				{
					model.StartTime=DateTime.Parse(ds.Tables[0].Rows[0]["StartTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["EndTime"].ToString()!="")
				{
					model.EndTime=DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
				}
				model.AdUrl=ds.Tables[0].Rows[0]["AdUrl"].ToString();
				model.LinkUrl=ds.Tables[0].Rows[0]["LinkUrl"].ToString();
				model.AdRemark=ds.Tables[0].Rows[0]["AdRemark"].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;
			}
		}