/// <summary> /// 我的收藏删除 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void DataList3_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "delete") { string u_id = e.CommandArgument.ToString(); Session["u_id"] = u_id; Travel.Model.Tab_user tab_user = new Travel.Model.Tab_user(); Travel.Model.Tab_collect tab_collect = new Travel.Model.Tab_collect(); ////通过Session获取用户的 u_collect tab_collect.U_collect = Travel.BLL.CollectBusiness.GetCollectById(Convert.ToInt32(Session["u_id"])).U_emaile; //通过Session获取用户emaile tab_user.U_emaile = Travel.BLL.UserBusiness.GetUserByEmaile(Session["u_emaile"].ToString()).U_emaile; //Travel.Model.Tab_collect tc = Travel.BLL.CollectBusiness.GetCollectByEmaile(Session["u_emaile"].ToString()); //tab_collect.U_collect = tc.U_emaile; //调用数据库里的删除收藏的存储过程 if (Travel.BLL.CollectBusiness.DeleteCollect(tab_user.U_emaile, tab_collect.U_collect)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('删除收藏成功!')</script>"); Response.AddHeader("Refresh", "0"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('删除收藏失败!')</script>"); } } }
protected void Unnamed_ServerClick(object sender, EventArgs e) { Travel.Model.Tab_article tab_article = new Travel.Model.Tab_article(); Travel.Model.Tab_collect tab_collect = new Travel.Model.Tab_collect(); tab_collect.U_emaile = Convert.ToString(Session["u_emaile"]);//将session中的emaile交给 //tab_collect.U_emaile = "*****@*****.**"; string title = Convert.ToString(((System.Web.UI.HtmlControls.HtmlAnchor)sender).HRef); Session["t_title"] = title; //直接将文章的标题交给收藏 tab_collect.U_collect = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).T_title; tab_collect.T_content = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).T_content; tab_collect.UploadTime = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).UploadTime; if (string.IsNullOrEmpty(tab_collect.U_emaile)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('请先登录!')</script>"); //跳转到指定界面 Response.Redirect("Login.aspx"); } else { if (string.IsNullOrEmpty(tab_collect.T_content) || string.IsNullOrEmpty(tab_collect.U_collect)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('数据错误!')</script>"); } else { if (Travel.BLL.CollectBusiness.AddCollect(tab_collect)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('收藏成功!')</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('请重新尝试!')</script>"); } } } }