Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(Request.Params["id"] as string, out this.id))
     {
         JscriptMsg(350, 230, "错误提示", "<b>出现错误啦!</b>您要调用的广告不存在或参数不正确。", "back", "Error");
         return;
     }
     if (!Page.IsPostBack)
     {
         Spread.BLL.Advertising bll = new Spread.BLL.Advertising();
         model = bll.GetModel(this.id);
     }
 }
Пример #2
0
 //保存
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Spread.Model.Advertising model = new Spread.Model.Advertising();
     Spread.BLL.Advertising bll = new Spread.BLL.Advertising();
     model.Title = this.txtTitle.Text.Trim();
     model.AdType = int.Parse(this.rblAdType.SelectedValue);
     model.AdRemark = this.txtAdRemark.Text;
     model.AdNum = int.Parse(this.txtAdNum.Text.Trim());
     model.AdPrice = decimal.Parse(this.txtAdPrice.Text);
     model.AdWidth = int.Parse(this.txtAdWidth.Text);
     model.AdHeight = int.Parse(this.txtAdHeight.Text);
     model.AdTarget = this.rblAdTarget.SelectedValue;
     bll.Add(model);
     JscriptPrint("广告位增加成功啦!", "AdvAdd.aspx", "Success");
 }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Spread.Model.Advertising GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id,Title,AdType,AdRemark,AdNum,AdPrice,AdWidth,AdHeight,AdTarget from Advertising ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
            parameters[0].Value = Id;

            Spread.Model.Advertising model = new Spread.Model.Advertising();
            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();
                if (ds.Tables[0].Rows[0]["AdType"].ToString() != "")
                {
                    model.AdType = int.Parse(ds.Tables[0].Rows[0]["AdType"].ToString());
                }
                model.AdRemark = ds.Tables[0].Rows[0]["AdRemark"].ToString();
                if (ds.Tables[0].Rows[0]["AdNum"].ToString() != "")
                {
                    model.AdNum = int.Parse(ds.Tables[0].Rows[0]["AdNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdPrice"].ToString() != "")
                {
                    model.AdPrice = int.Parse(ds.Tables[0].Rows[0]["AdPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdWidth"].ToString() != "")
                {
                    model.AdWidth = int.Parse(ds.Tables[0].Rows[0]["AdWidth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdHeight"].ToString() != "")
                {
                    model.AdHeight = int.Parse(ds.Tables[0].Rows[0]["AdHeight"].ToString());
                }
                model.AdTarget = ds.Tables[0].Rows[0]["AdTarget"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }