Example #1
0
        protected void like_Click(object sender, EventArgs e)
        {
            LikesManager       likesManager       = new LikesManager();
            CalculationManager calculationManager = new CalculationManager();
            int UserId    = int.Parse(((Session["user"] as User).Id).ToString());
            int ProjectId = int.Parse(Request.QueryString["Id"]);

            Model.Likes likes = likesManager.GetModelByUserIdAndProjectId(UserId, ProjectId);
            if (likes == null)
            {
                if (likesManager.Insert(UserId, ProjectId) > 0 && calculationManager.LikeCountAddition(ProjectId) > 0)
                {
                    Response.Write("<script>alert('关注成功!!');loaction.href='Projectinfo.aspx';</script>");
                    this.like.Text = "取消关注";
                    Response.Write("<script> window.location.href = document.URL; </script>");
                }
                else
                {
                    Response.Write("<script>alert('关注失败!!');</script>");
                }
            }
            else
            {
                if (likesManager.Delete(UserId, ProjectId) > 0 && calculationManager.LikeCountSubtraction(ProjectId) > 0)
                {
                    Response.Write("<script>alert('已取消关注!!');</script>");
                    this.like.Text = "关注";
                    Response.Write("<script> window.location.href = document.URL; </script>");
                }
                else
                {
                    Response.Write("<script>alert('取消失败!!');</script>");
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int          ProjectId    = int.Parse(Request.QueryString["Id"]);
            int          UserId       = int.Parse(((Session["user"] as User).Id).ToString());
            LikesManager likesManager = new LikesManager();

            Model.Likes likes = likesManager.GetModelByUserIdAndProjectId(UserId, ProjectId);
            //判断用户是否关注有该项目
            if (likes == null)
            {
                this.like.Text = "关注";
            }
            else
            {
                this.like.Text = "取消关注";
            }
            //获取项目数据
            ProjectManager projectManager = new ProjectManager();

            project = projectManager.GetModel(ProjectId);
            UserManager userManager = new UserManager();

            User = userManager.GetModel(project.OwnerId);
            SupportProject supportProject = new SupportProject();
            //获取评论
            CommentManager commentManager = new CommentManager();

            this.RepeaterComment.DataSource = commentManager.GetModelLinkUsers(UserId, ProjectId);
            this.RepeaterComment.DataBind();
            //获取回报内容
            Session["Return"]       = project.Return;
            Session["ReturnMiddle"] = project.ReturnMiddle;
            Session["ReturnMax"]    = project.ReturnMax;
            Session["ReturnTime"]   = project.ReturnTime;
            Session["Freight"]      = project.Freight;
            //获取支持者
            CalculationManager calculationManager = new CalculationManager();

            Session["Small"]          = calculationManager.CountSupportPeopleSmall(ProjectId);
            Session["Middle"]         = calculationManager.CountSupportPeopleMiddle(ProjectId);
            Session["Max"]            = calculationManager.CountSupportPeopleMax(ProjectId);
            Session["CountOfSupport"] = calculationManager.CountSupportWhereProjectId(ProjectId);
        }