Ejemplo n.º 1
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }

            BestMessages bstMsg = new BestMessages();
            bstMsg.overrideAdd = true;
            string parentGuid = Request.Form["parentGuid"];
            if(! string.IsNullOrEmpty(parentGuid))
            {
                bstMsg.parentGuid = new Guid(parentGuid);
            }
            bstMsg.messageText = Request.Form["msgText"];
            bstMsg.messageFrom = Utils.User.UserName;
            bstMsg.messageTo = Request.Form["msgTo"];
            bstMsg.CenterId = Utils.User.CenterId;

            StringBuilder sbHtml = new StringBuilder();
            if (!bstMsg.CurrentRow.Save())
            {
                /* Return Message */
                sbHtml.Append("<div>Unable to send message.</div>");
            }

            /* Write HTML of Message */
            bstMsg.TableRows.Clear();
            bstMsg.LoadRows("messageFrom=?", "messageFrom", Utils.User.UserName, "messagedate desc");
            sbHtml.Append("<table cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%;\"><tr><th>Sent Date</th><th>To</th><th>Message</th></tr>");
            for(int i=0; i < bstMsg.TableRows.Count; i++)
            {
                bstMsg.currentRowId = i;
                sbHtml.Append("<td>" + HttpUtility.HtmlEncode(bstMsg.messageDate.ToString("MM/dd/yyyy")) + "</td><td>" + HttpUtility.HtmlEncode(bstMsg.TableRows[i].Fields["messageTo"].displayFormatFunc.Invoke(bstMsg.TableRows[i]).ToString()) + "</td><td>" + HttpUtility.HtmlEncode(bstMsg.messageText) + "</td></tr>");
            }
            sbHtml.Append("</table>");

            Response.Write(sbHtml.ToString());
        }
Ejemplo n.º 2
0
 private string MessagesHTML(bool IsSentMsg)
 {
     StringBuilder sbhtml = new StringBuilder();
     BestMessages bstMsgs = new BestMessages();
     if (IsSentMsg)
     {
         bstMsgs.LoadRows("messageFrom=?", "messageFrom", Utils.User.UserName, "messagedate desc");
     }
     else
     {
         bstMsgs.LoadRows("messageTo=?", "messageTo", Utils.User.UserName, "messagedate desc");
     }
     if (bstMsgs.TableRows.Count > 0)
     {
         sbhtml.Append("<table cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%;\"><tr><th>" + (IsSentMsg?"Send Date":"Receive Date") + "</th><th>" + (IsSentMsg?"To":"From") + "</th><th>Message</th></tr>");
         for (int i = 0; i < bstMsgs.TableRows.Count; i++)
         {
             bstMsgs.currentRowId = i;
             sbhtml.Append("<td>" + HttpUtility.HtmlEncode(bstMsgs.messageDate.ToString("MM/dd/yyyy")) + "</td><td>");
             if(IsSentMsg)
             { sbhtml.Append(HttpUtility.HtmlEncode(bstMsgs.TableRows[i].Fields["messageTo"].displayFormatFunc.Invoke(bstMsgs.TableRows[i]).ToString()));
             }
             else
             {
                 sbhtml.Append( bstMsgs.TableRows[i].Fields["messageFrom"].displayFormatFunc.Invoke(bstMsgs.TableRows[i]).ToString());
             }
             sbhtml.Append("</td><td>" + HttpUtility.HtmlEncode(bstMsgs.messageText) + "</td></tr>");
         }
         sbhtml.Append("</table>");
     }
     else
     {
         sbhtml.Append("You have No New Messages");
     }
     return sbhtml.ToString();
 }