public void bindMenu() { menu_id = Convert.ToInt32(ViewState["menu_id"].ToString()); model = bll.GetModel(menu_id); menu_id = model.Menu_id; name = model.Menu_name; content = model.Menu_content; }
/// <summary> /// 更新首页版块 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdMenu(YouthMenu model) { int rows = dal.UpdMenu(model); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 添加首页版块 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddMenu(YouthMenu model) { StringBuilder str = new StringBuilder(); str.Append(" insert into menu "); str.Append(" (menu_name,menu_content) "); str.Append(" values "); str.Append(" (@menu_name,@menu_content) "); SqlParameter[] parameters = { new SqlParameter("@menu_name", SqlDbType.NVarChar, 50), new SqlParameter("@menu_content", SqlDbType.NText) }; parameters[0].Value = model.Menu_name; parameters[1].Value = model.Menu_content; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
/// <summary> /// 更新首页版块 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdMenu(YouthMenu model) { StringBuilder str = new StringBuilder(); str.Append(" update menu "); str.Append(" set menu_name=@menu_name, "); str.Append(" menu_content=@menu_content "); str.Append(" where menu_id=@menu_id "); SqlParameter[] parameters = { new SqlParameter("@menu_name", SqlDbType.NVarChar, 50), new SqlParameter("@menu_content", SqlDbType.NText), new SqlParameter("@menu_id", SqlDbType.Int, 8) }; parameters[0].Value = model.Menu_name; parameters[1].Value = model.Menu_content; parameters[2].Value = model.Menu_id; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
/// <summary> /// 根据id得到首页实体 /// </summary> /// <param name="menu_id"></param> /// <returns></returns> public YouthMenu GetModel(int menu_id) { YouthMenu model = new YouthMenu(); StringBuilder str = new StringBuilder(); str.Append(" select * from menu "); str.Append(" where menu_id= " + menu_id); DataSet ds = DbHelperSQL.Query(str.ToString()); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; model.Menu_id = Convert.ToInt32(row["menu_id"].ToString()); model.Menu_name = row["menu_name"].ToString(); model.Menu_content = row["menu_content"].ToString(); return(model); } else { return(null); } }
protected void bindOriginalMenu() { originalModel = bll.GetModel(menu_id); txtName.Text = originalModel.Menu_name; txtContent.Text = originalModel.Menu_content; }