Beispiel #1
0
        /// <summary>
        /// 添加收藏
        /// </summary>
        /// <param name="collect"></param>
        /// <returns></returns>
        public int InsertTheme(CollectTheme collect)
        {
            string sql = "insert into Collect_theme values(@collect_id,@remark,@theme_id,@member_id)";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("collect_id", collect.CollectId),
                new SqlParameter("remark", collect.Remark),
                new SqlParameter("theme_id", collect.ThemeId),
                new SqlParameter("member_id", collect.MemberId)
            };
            return(SqlHelper.ExecuteNonQuery(sql, parameters));
        }
Beispiel #2
0
        protected void collect_ServerClick(object sender, EventArgs e)//收藏
        {
            //判断是否登录
            if (Session["role"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }

            //收藏,主题id通过Request.QueryString["themeId"]获取
            CollectTheme col = new CollectTheme();

            col.CollectId = CollectThemeManagement.CreatCollectId();
            col.ThemeId   = Request.QueryString["themeId"].ToString().Trim();
            col.MemberId  = Session["memberId"].ToString().Trim();
            col.Remark    = "备注";
            Msg           = CollectThemeManagement.CollectTheme(col);
            printMsgToClient();
        }
 /// <summary>
 /// 收藏主题
 /// </summary>
 /// <returns></returns>
 public static string CollectTheme(CollectTheme collect)
 {
     if (collect.IsError)
     {
         return(collect.GetErrorMsg());
     }
     if (ifExist(collect.MemberId, collect.ThemeId))
     {
         return("收藏已存在");
     }
     if (ICTS.InsertTheme(collect) > 0)
     {
         return("收藏成功");
     }
     else
     {
         return("收藏失败");
     }
 }
 /// <summary>
 /// 查询主题是否已收藏
 /// </summary>
 /// <param name="collectId"></param>
 /// <returns></returns>
 static bool ifExist(string memberId, string themeId)
 {
     Model.CollectTheme ct = new CollectTheme()
     {
         MemberId = memberId,
         ThemeId  = themeId
     };
     if (ct.IsError)
     {
         return(false);
     }
     if (ICTS.SelectNum(memberId, themeId) > 0)
     {
         return(true);//已收藏
     }
     else
     {
         return(false);//未收藏
     }
 }
 /// <summary>
 /// 删除收藏
 /// </summary>
 /// <param name="collect"></param>
 /// <returns>"未收藏" "删除收藏成功" "删除收藏失败"</returns>
 public static string UncollectTheme(string memberId, string themeId)
 {
     Model.CollectTheme ct = new CollectTheme()
     {
         MemberId = memberId,
         ThemeId  = themeId
     };
     if (ct.IsError)
     {
         return(ct.GetErrorMsg());
     }
     if (!ifExist(memberId, themeId))
     {
         return("您还未收藏该主题");
     }
     if (ICTS.Delete(memberId, themeId) > 0)
     {
         return("删除收藏成功");
     }
     else
     {
         return("删除收藏失败");
     }
 }