protected void Page_Load(object sender, EventArgs e)
        {
            Literal title = (Literal)Master.FindControl("pageTitle");
            title.Text = "Messages Single View";

            if (!IsPostBack)
            {

                string date = "";

                if (!String.IsNullOrEmpty(Session["selectedMessageID"].ToString()))
                {

                    int id = int.Parse(Session["selectedMessageID"].ToString());
                    // message.MessageId = id;
                    StringBuilder concatinater = new StringBuilder();
                    Message message = new Message(id);
                    DataTable aMessage = test.GetAMessage(message);

                    NotificationDAL notificationDAL = new NotificationDAL();

                    notificationDAL.UpdateMessageNotificationIsRead(message);

                    foreach (DataRow row in aMessage.Rows)
                    {
                        Reusable_Methods reusable_Methods = new Reusable_Methods();
                        date = reusable_Methods.FormatDateTime(DateTime.Parse((row["DateTime"]).ToString()));
                        //date = Convert.ToDateTime(row["DateTime"]).ToString("M");

                        //Building single message view box
                        concatinater.Append("<div class='SingleViewmsgeWrapper' id='");
                        concatinater.Append(row["messageID"].ToString());

                        //concatinater.Append("' ><div class='msgeHeading ui-corner-all' ><h2 class='ui-corner-all'> <a class='btnMemberProfile' id='");
                        concatinater.Append("' ><div class='msgeHeading ui-corner-all' ><h2 class='ui-corner-all'> <a href='#' class='btnMemberProfile replyMsge' style='font-weight:normal; font-size: 1.2em; ' id='");
                        concatinater.Append(row["FriendID"].ToString());
                        concatinater.Append("' >");
                        concatinater.Append(row["Friend"].ToString());
                        concatinater.Append("</a><span class='DateWithTime ui-corner-all floatright' style='font-size: 1.2em;' >  ");
                        concatinater.Append(date);
                        concatinater.Append("</span></h2> </div>");
                        concatinater.Append("<p class=''>");
                        concatinater.Append(row["MessageText"].ToString());
                        concatinater.Append("</p></div>");

                    }

                    MessageString = concatinater.ToString();

                }
            }
        }
Exemple #2
0
        public DataTable GetAMessage(Message message)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspGetMessage", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@MessageID", message.MessageId);

                DataTable aMessage = new DataTable();

                try
                {
                    con.Open();

                    da = new SqlDataAdapter(cmd);
                    da.Fill(aMessage);

                }
                catch (SqlException)
                {
                    throw new ApplicationException("Error connection to database");

                }
                return aMessage;

            }
        }
Exemple #3
0
        public bool IsMessageRead(Message message)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspGetIsMessageRead", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@MessageID", message.MessageId));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);

                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    int count = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());

                    if (count > 0)
                        return true;
                    else
                        return false;
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message.ToString());
                    //return false;
                }
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Literal title = (Literal)Master.FindControl("pageTitle");
            title.Text = "Inbox";
            Page.RouteData.Values["Id"] = "Inbox";

            if (!IsPostBack)
            {
                if (Session["memberID"] == null)
                {

                    Response.Redirect("~/Login.aspx");

                }

                else
                {
                    #region ##
                    if (IsPostBack)
                    {
                        if (Request["__EVENTARGUMENT"] != "")
                        {
                            try
                            {
                                string s = Request["__EVENTARGUMENT"];

                                Session["Data"] = s.TrimEnd(',');

                                Response.Redirect("~/ViewMessages.aspx");
                            }
                            catch (Exception ex)
                            {
                                ex.ToString();
                            }
                        }
                    }
                    #endregion

                }
            }

            MessagesDAL DAL = new MessagesDAL();
            string date = "";
            string shrtMessage = "";
            DataTable inboxList = DAL.getInboxList(new Member(Session["memberID"].ToString()));

            StringBuilder concatinater = new StringBuilder();

            foreach (DataRow row in inboxList.Rows)
            {
                Message message = new Message(int.Parse(row["messageID"].ToString()));

                //date = Convert.ToDateTime(row["DateTime"]).ToString("D");

                reusable_Methods = new Reusable_Methods();

                date = reusable_Methods.FormatDateTime(DateTime.Parse(row["DateTime"].ToString()));

                if (row["MessageText"].ToString().Length > 45)
                {
                    shrtMessage = row["MessageText"].ToString().Substring(0, 45) + "...";

                }
                else
                {
                    shrtMessage = row["MessageText"].ToString();

                }

                //Building single message view box
                concatinater.Append("<div class='msgeWrapper ");

                if(!DAL.IsMessageRead(message))
                {
                //isRead
                    concatinater.Append("isNotRead");
                }

                concatinater.Append("' id='");
                concatinater.Append(row["messageID"].ToString());

                concatinater.Append("'> <div class='checkBox'><input type='checkbox'  /> </div><div class='msge' ><div><span class='sendingFriend blueFontTextColor' id='");
                concatinater.Append(row["FriendID"].ToString());
                concatinater.Append("' >");
                concatinater.Append(row["FriendDisplayName"].ToString());
                concatinater.Append("</a><span class='DateWithTime floatright'>");
                concatinater.Append(date);
                concatinater.Append("</span></div><div class='slideInMenu floatright' style='visibility:hidden;' ><span class='floatright BorberRad3' id='deleteMsge' >Delete</span>");
                concatinater.Append(" <span class='floatright BorberRad3' BorberRad3'>Reply</span></div><div class='msgeText floatright'>");
                concatinater.Append(shrtMessage);
                concatinater.Append("</div></div> <div style='clear:both;'></div></div>");

            }

            items = concatinater.ToString();
        }