/// <summary> /// 根据id得到新闻版块 /// </summary> /// <param name="news_col_id"></param> /// <returns></returns> public YouthNewsColumn GetListById(int news_col_id) { YouthNewsColumn model = new YouthNewsColumn(); StringBuilder str = new StringBuilder(); str.Append(" select * from news_column "); str.Append(" where news_column_id=" + news_col_id); DataSet ds = DbHelperSQL.Query(str.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["news_column_id"] != null) { model.News_column_id = Convert.ToInt32(ds.Tables[0].Rows[0]["news_column_id"].ToString()); } if (ds.Tables[0].Rows[0]["news_column_name"] != null) { model.News_column_name = ds.Tables[0].Rows[0]["news_column_name"].ToString(); } return(model); } else { return(null); } }
protected void bindNewsCol() { int news_col_id = Convert.ToInt32(ViewState["news_column_id"]); model = bll.GetListById(news_col_id); txtName.Text = model.News_column_name; }
/// <summary> /// 添加新闻版块 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddNewsCol(YouthNewsColumn model) { int rows = news_col_dal.AddNewsCol(model); if (rows > 0) { return(true); } else { return(false); } }
protected void lbtnSave_Click(object sender, EventArgs e) { YouthNewsColumn model = new YouthNewsColumn(); YouthNewsColBLL bll = new YouthNewsColBLL(); model.News_column_name = txtName.Text.ToString(); if (bll.AddNewsCol(model)) { AUTO.Utility.MyUtil.ShowMessageRedirect(this.Page, "添加成功", "NewsColList.aspx"); } else { AUTO.Utility.MyUtil.ShowMessage(this.Page, "添加失败"); } }
/// <summary> /// 添加新闻版块 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddNewsCol(YouthNewsColumn model) { StringBuilder str = new StringBuilder(); str.Append(" insert into news_column "); str.Append(" (news_column_name) "); str.Append(" values "); str.Append(" (@news_column_name) "); SqlParameter[] parameters = { new SqlParameter("@news_column_name", SqlDbType.NVarChar, 25) }; parameters[0].Value = model.News_column_name; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
/// <summary> /// 更新新闻版块 /// </summary> /// <param name="news_column_id"></param> /// <returns></returns> public int UpdNewsCol(YouthNewsColumn model) { StringBuilder str = new StringBuilder(); str.Append(" update news_column set "); str.Append(" news_column_name=@news_column_name "); str.Append(" where news_column_id=@news_column_id "); SqlParameter[] parameters = { new SqlParameter("@news_column_name", SqlDbType.NVarChar, 25), new SqlParameter("@news_column_id", SqlDbType.Int, 8) }; parameters[0].Value = model.News_column_name; parameters[1].Value = model.News_column_id; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
//加载侧边栏名称 private void bindNewsCol() { news_col_model = news_col_bll.GetListById(news_col_id); news_col_name = news_col_model.News_column_name; }