コード例 #1
0
    protected void btnSendComment_Click(object sender, EventArgs e)
    {
        UtilDataContext  dc         = new UtilDataContext();
        UserItemComments NewComment = new UserItemComments();

        dc.UserItemComments.InsertOnSubmit(NewComment);
        NewComment.ItemCode       = _itemCode;
        NewComment.UserCode       = UserCode;
        NewComment.HCItemTypeCode = _hCItemTypeCode;
        NewComment.Comment        = txtComment.Text;
        NewComment.CommentDate    = DateTime.Now;
        NewComment.ID             = Tools.GetRandID();
        dc.SubmitChanges();
        txtComment.Text = "";

        string SiteDomain = ConfigurationSettings.AppSettings["SiteDomain"];

        if (_hCItemTypeCode == 3)//Photos
        {
            UsersDataContext dcUser            = new UsersDataContext();
            Users            OwnerUser         = dcUser.Users.SingleOrDefault(p => p.Code.Equals(_ownerUserCode));
            string           OwnerUserFullName = OwnerUser.FirstName + " " + OwnerUser.LastName;

            if (OwnerUser != null)
            {
            }
            BOLUserActions UserActionsBOL = new BOLUserActions();
            UserActionsBOL.NewAction(UserCode, "<a href='" + SiteDomain + "Users/Profile.aspx?ID=" + Session["UserID"] + "'>" + Session["FirstName"] + " " + Session["LastName"] + "</a> نظر جدیدی روی عکس <a href='" + SiteDomain + "Users/Profile.aspx?ID=" + OwnerUser.ID + "'>" + OwnerUserFullName + "</a> <a href='Users/ShowPhoto.aspx?ID=" + _params + "'>" + " ارسال کرده است.</a>", 7);
        }

        LoadComments(rptComments, _itemCode);
    }
コード例 #2
0
    protected void HandleRepeaterCommand(object source, RepeaterCommandEventArgs e)
    {
        string          CommentID        = "";
        UtilDataContext dc               = new UtilDataContext();
        LinkButton      btnDeleteComment = (LinkButton)e.Item.Controls[1].FindControl("btnDeleteComment");

        int        UserCode = Convert.ToInt32(Session["UserCode"]);
        LinkButton hplTitle = (LinkButton)e.Item.Controls[1].FindControl("hplTitle");


        #region DeleteComment
        if (e.CommandName == "DeleteComment")
        {
            CommentID = btnDeleteComment.Attributes["CommentID"];
            UserItemComments CurItemComment = dc.UserItemComments.SingleOrDefault(p => p.ID.Equals(CommentID));
            if (CurItemComment != null)
            {
                dc.UserItemComments.DeleteAllOnSubmit(dc.UserItemComments.Where(p => p.Code.Equals(CurItemComment.Code)));
                dc.SubmitChanges();

                LoadComments((Repeater)source, (int)CurItemComment.ItemCode);
            }
        }
        #endregion
    }