示例#1
0
        protected void SendButton_Click(object sender, EventArgs e)
        {
            //create new MessagesTable object
            MessagesTable newMessage = new MessagesTable();

            newMessage.MessageFROM = Session["LoginName"].ToString().Trim();
            newMessage.MessageTO   = RecipientsDropDownList.SelectedValue;
            newMessage.Date        = DateTime.Now;
            newMessage.Message     = MessageTextBox.Text;
            newMessage.IsRead      = 0;

            //update database
            dbcon.MessagesTables.Add(newMessage);
            dbcon.SaveChanges();

            Server.Transfer("Messages.aspx", true);
        }
示例#2
0
        // Searches for a Message in database by messageID, and returns copy
        public static MessagesTable getMessageByID(int messageID)
        {
            MessagesTable result = null;

            foreach (MessagesTable m in dbcon.MessagesTables)
            {
                if (m.MessageID == messageID)
                {
                    result             = new MessagesTable();
                    result.MessageID   = m.MessageID;
                    result.MessageTO   = m.MessageTO;
                    result.MessageFROM = m.MessageFROM;
                    result.Date        = m.Date;
                    result.Message     = m.Message;
                    result.IsRead      = m.IsRead;
                    break;
                }
            }
            return(result);
        }