protected void Page_Load(object sender, EventArgs e)
        {
            if(Request.QueryString["id"] != null)
            {
                m_oIAMessage = DataAccess.IAMessages.SingleOrDefault(row => row.IAMessageID == MemberProtect.Utility.ValidateInteger(Request.QueryString["id"]));

                if(m_oIAMessage != null)
                {
                    // Admin + Staff can view details of any message
                    if(ApplicationContext.IsAdmin && ApplicationContext.IsStaff)
                    {
                        m_repeaterRecipients.DataSource = DataAccess.fn_Message_GetRecipients(m_oIAMessage.IAMessageID);
                        m_repeaterRecipients.DataBind();
                    }

                    m_oIAMessageRecipient = DataAccess.IAMessageRecipients.SingleOrDefault(row => row.MPUserID == MemberProtect.CurrentUser.UserID && row.IAMessageID == m_oIAMessage.IAMessageID);
                    if(m_oIAMessageRecipient != null)
                    {
                        if(!m_oIAMessageRecipient.IsAcknowledged)
                        {
                            m_oIAMessageRecipient.IsAcknowledged = true;
                            m_oIAMessageRecipient.AcknowledgedDateTime = DateTime.Now;
                            DataAccess.SubmitChanges();
                        }
                    }
                    else
                    {
                        // Admin + Staff can view details of any message
                        if(!(ApplicationContext.IsAdmin && ApplicationContext.IsStaff))
                        {
                            Response.Redirect("~/messages-inbox.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("~/messages-inbox.aspx");
                }
            }
        }
        protected void OnSend(object sender, EventArgs e)
        {
            DateTime oStartDateTime = new DateTime(1950, 1, 1, 0, 0, 0, 0);
            DateTime oEndDateTime = new DateTime(2100, 1, 1, 0, 0, 0, 0);

            // Validation
            if(m_dtStartDateTime.SelectedDate.HasValue && m_dtEndDateTime.SelectedDate.HasValue)
            {
                oStartDateTime = m_dtStartDateTime.SelectedDate.Value;
                oEndDateTime = m_dtEndDateTime.SelectedDate.Value;

                if(oStartDateTime.CompareTo(oEndDateTime) > 0)
                {
                    SetMessage("Start Date/Time must come before the Stop Date/Time.", MessageTone.Negative);
                    return;
                }
            }

            List<Guid> assignedIndividuals = GetIndividualUsers();
            if (m_chkGroups.SelectedValue == string.Empty && assignedIndividuals.Count() <= 0)
            {
                SetMessage("Please select group(s) or specific user(s) to send your message to.", MessageTone.Negative);
                return;
            }

            // Create message
            IAMessage oIAMessage = new IAMessage();
            oIAMessage.MPUserID = MemberProtect.CurrentUser.UserID;
            oIAMessage.DisplayStartDateTime = oStartDateTime;
            oIAMessage.DisplayEndDateTime = oEndDateTime;
            oIAMessage.Subject = m_txtSubject.Text;
            oIAMessage.Body = m_txtMessage.Content;
            oIAMessage.CreatedDateTime = DateTime.Now;
            DataAccess.IAMessages.InsertOnSubmit(oIAMessage);
            DataAccess.SubmitChanges();

            // Assign users to message recipients
            IQueryable<MPUserData> oMPUsers = null;
            List<IAMessageRecipient> oReceipients = new List<IAMessageRecipient>();
            if(m_chkGroups.SelectedValue != string.Empty)
            {
                foreach(ListItem oItem in m_chkGroups.Items)
                {
                    if(oItem.Selected)
                    {
                        if(oItem.Value == "Staff")
                        {
                            oMPUsers = DataAccess.MPUserDatas.Where(row => row.IsStaff == "Y" && row.IsArchived == "N");
                        }
                        else if(oItem.Value == "Talent")
                        {
                            oMPUsers = DataAccess.MPUserDatas.Where(row => row.IsTalent == "Y" && row.IsArchived == "N");
                        }
                        else if(oItem.Value == "Customers")
                        {
                            oMPUsers = DataAccess.MPUserDatas.Where(row => row.IsCustomer == "Y" && row.IsArchived == "N");
                        }

                        foreach(MPUserData oMPUserData in oMPUsers)
                        {
                            IAMessageRecipient oIAMessageRecipient = new IAMessageRecipient();
                            oIAMessageRecipient.IAMessageID = oIAMessage.IAMessageID;
                            oIAMessageRecipient.MPUserID = oMPUserData.MPUserID;
                            oIAMessageRecipient.IsAcknowledged = false;
                            oIAMessageRecipient.AcknowledgedDateTime = new DateTime(1950, 1, 1, 0, 0, 0, 0);
                            oReceipients.Add(oIAMessageRecipient);
                        }
                    }
                }

                if(oReceipients.Count > 0)
                {
                    DataAccess.IAMessageRecipients.InsertAllOnSubmit(oReceipients);
                    DataAccess.SubmitChanges();
                }
            }

            // Process individual users
            if (assignedIndividuals.Count > 0)
            {
                foreach (Guid assignedUserID in assignedIndividuals)
                {
                    if (DataAccess.IAMessageRecipients.Count(row => row.IAMessageID == oIAMessage.IAMessageID && row.MPUserID == assignedUserID) == 0)
                    {
                        IAMessageRecipient oIAMessageRecipient = new IAMessageRecipient();
                        oIAMessageRecipient.IAMessageID = oIAMessage.IAMessageID;
                        oIAMessageRecipient.MPUserID = assignedUserID;
                        oIAMessageRecipient.IsAcknowledged = false;
                        oIAMessageRecipient.AcknowledgedDateTime = new DateTime(1950, 1, 1, 0, 0, 0, 0);
                        DataAccess.IAMessageRecipients.InsertOnSubmit(oIAMessageRecipient);
                        DataAccess.SubmitChanges();
                    }
                }
            }

            RedirectMessage("~/messages-inbox.aspx", "Message has been sent!", MessageTone.Positive);
        }