/// <summary> /// 修改链接 /// </summary> /// <param name="r"></param> /// <returns></returns> public int editLinks(R_Links r) { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(@"UPDATE R_Links SET Links_Name=@Links_Name, Links_Url=@Links_Url,User_ID=@User_ID WHERE (ID = @ID)"); db.AddInParameter(cmd, "@Links_Name", DbType.String, r.Links_Name); db.AddInParameter(cmd, "@Links_Url", DbType.String, r.Links_Url); db.AddInParameter(cmd, "@User_ID", DbType.Int32, r.User_ID); db.AddInParameter(cmd, "@ID", DbType.Int32, r.ID); return db.ExecuteNonQuery(cmd); }
/// <summary> /// 添加新链接 /// </summary> /// <param name="r"></param> /// <returns></returns> public int addLinks(R_Links r) { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(@"insert into R_Links (Links_Name, Links_Url,User_ID) values (@Links_Name, @Links_Url,@User_ID)"); db.AddInParameter(cmd, "@Links_Name", DbType.String, r.Links_Name); db.AddInParameter(cmd, "@Links_Url", DbType.String, r.Links_Url); db.AddInParameter(cmd, "@User_ID", DbType.Int32, r.User_ID); return db.ExecuteNonQuery(cmd); }
private void AddLinks(R_Links r) { B_Links b = new B_Links(); _Links_Name.Text = ""; if (b.addLinks(r)) { Response.Redirect("Links.aspx"); } else { ll_ts.Text = "添加失败!"; } }
private void editLinks(R_Links r) { B_Links b = new B_Links(); r.ID = id; _Links_Name.Text = ""; if (b.editLinks(r)) { Response.Redirect("Links.aspx"); } else { ll_ts.Text = "修改失败"; } }
protected void but_Links_Click(object sender, EventArgs e) { R_Links r = new R_Links(); r.User_ID = Convert.ToInt32(Request.Cookies["user"]["ID"]); r.Links_Name = Links_Name.Text.Trim(); r.Links_Url = Links_Url.Text.Trim(); if (action.Equals("edit")) { editLinks(r); } else { AddLinks(r); } }
/// <summary> /// 修改链接 /// </summary> /// <param name="r"></param> /// <returns></returns> public bool editLinks(R_Links r) { return d.editLinks(r) == 1 ? true : false; }
/// <summary> /// 添加新链接 /// </summary> /// <param name="r"></param> /// <returns></returns> public bool addLinks(R_Links r) { return d.addLinks(r) == 1 ? true : false; }