private void BindData() { PrivateMessage pm = ForumManager.GetPrivateMessageByID(this.PrivateMessageID); if (pm != null) { if (pm.ToUserID != NopContext.Current.User.CustomerID && pm.FromUserID != NopContext.Current.User.CustomerID) { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } if (!pm.IsRead && pm.ToUserID == NopContext.Current.User.CustomerID) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageID, pm.FromUserID, pm.ToUserID, pm.Subject, pm.Text, true, pm.IsDeletedByAuthor, pm.IsDeletedByRecipient, pm.CreatedOn); } } else { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } lblFrom.Text = Server.HtmlEncode(CustomerManager.FormatUserName(pm.FromUser)); lblTo.Text = Server.HtmlEncode(CustomerManager.FormatUserName(pm.ToUser)); lblSubject.Text = Server.HtmlEncode(pm.Subject); lblMessage.Text = ForumManager.FormatPrivateMessageText(pm.Text); }
private void BindData() { Customer toCustomer = null; PrivateMessage replyToPM = ForumManager.GetPrivateMessageByID(this.ReplyToMessageID); if (replyToPM != null) { if (replyToPM.ToUserID == NopContext.Current.User.CustomerID || replyToPM.FromUserID == NopContext.Current.User.CustomerID) { toCustomer = replyToPM.FromUser; txtSubject.Text = string.Format("Re: {0}", replyToPM.Subject); } else { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } } else { toCustomer = CustomerManager.GetCustomerByID(this.ToCustomerID); } if (toCustomer == null || toCustomer.IsGuest) { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } lblSendTo.Text = Server.HtmlEncode(CustomerManager.FormatUserName(toCustomer)); }
protected void btnSend_Click(object sender, EventArgs e) { try { string subject = txtSubject.Text.Trim(); string message = txtMessageBBCode.Text.Trim(); if (String.IsNullOrEmpty(subject)) { throw new NopException(GetLocaleResourceString("PrivateMessages.SubjectCannotBeEmpty")); } if (String.IsNullOrEmpty(message)) { throw new NopException(GetLocaleResourceString("PrivateMessages.MessageCannotBeEmpty")); } Customer toCustomer = null; PrivateMessage replyToPM = ForumManager.GetPrivateMessageByID(this.ReplyToMessageID); if (replyToPM != null) { if (replyToPM.ToUserID == NopContext.Current.User.CustomerID || replyToPM.FromUserID == NopContext.Current.User.CustomerID) { toCustomer = replyToPM.FromUser; } else { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } } else { toCustomer = CustomerManager.GetCustomerByID(this.ToCustomerID); } if (toCustomer == null || toCustomer.IsGuest) { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } PrivateMessage pm = ForumManager.InsertPrivateMessage(NopContext.Current.User.CustomerID, toCustomer.CustomerID, subject, message, false, false, false, DateTime.Now); Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx?Tab=sent"); } catch (Exception exc) { pnlError.Visible = true; lErrorMessage.Text = Server.HtmlEncode(exc.Message); } }
protected void btnReply_Click(object sender, EventArgs e) { PrivateMessage pm = ForumManager.GetPrivateMessageByID(this.PrivateMessageID); if (pm != null) { string replyURL = string.Format("{0}SendPM.aspx?R={1}", CommonHelper.GetStoreLocation(), pm.PrivateMessageID); Response.Redirect(replyURL); } else { Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); } }
protected void btnDelete_Click(object sender, EventArgs e) { PrivateMessage pm = ForumManager.GetPrivateMessageByID(this.PrivateMessageID); if (pm != null) { if (pm.FromUserID == NopContext.Current.User.CustomerID) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageID, pm.FromUserID, pm.ToUserID, pm.Subject, pm.Text, pm.IsRead, true, pm.IsDeletedByRecipient, pm.CreatedOn); } if (pm != null) { if (pm.ToUserID == NopContext.Current.User.CustomerID) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageID, pm.FromUserID, pm.ToUserID, pm.Subject, pm.Text, pm.IsRead, pm.IsDeletedByAuthor, true, pm.CreatedOn); } } } Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx"); }
protected void btnDeleteSelected_Click(object sender, EventArgs e) { if (Page.IsValid) { try { foreach (GridViewRow row in gvSent.Rows) { CheckBox cbSelect = row.FindControl("cbSelect") as CheckBox; HiddenField hfPrivateMessageID = row.FindControl("hfPrivateMessageID") as HiddenField; if (cbSelect != null && hfPrivateMessageID != null) { bool selected = cbSelect.Checked; int pmID = int.Parse(hfPrivateMessageID.Value); if (selected) { PrivateMessage pm = ForumManager.GetPrivateMessageByID(pmID); if (pm != null) { if (pm.FromUserID == NopContext.Current.User.CustomerID) { pm = ForumManager.UpdatePrivateMessage(pm.PrivateMessageID, pm.FromUserID, pm.ToUserID, pm.Subject, pm.Text, pm.IsRead, true, pm.IsDeletedByRecipient, pm.CreatedOn); } } } } } Response.Redirect(CommonHelper.GetStoreLocation() + "PrivateMessages.aspx?Tab=sent"); } catch (Exception exc) { LogManager.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc); } } }