Example #1
0
        // Select Messages between student and tutor
        public void displayMessages()
        {
            UserDetails           _user        = (UserDetails)HttpContext.Current.Session["User"];
            List <MessageDetails> _messageList = new List <MessageDetails>();

            if (_user.UserType == 1)
            {
                _messageList = model.selectMessages(_user.UserID, _user.SupervisorID);
            }
            else if (_user.UserType == 2)
            {
                string _studentID = MessageView.studentID;
                _messageList = model.selectMessages(_studentID, _user.UserID);
            }

            Hashtable _formattedMessageData = new Hashtable();
            int       _counter = 1;

            if (_messageList.Count > 0)
            {
                string   _sender  = string.Empty;
                string[] _headers = { "Date", "Time", "From", "Message" };
                _formattedMessageData.Add(0, _headers);
                foreach (MessageDetails _message in _messageList)
                {
                    string[] _tempArray = { _message.Date.ToShortDateString(), _message.Time.ToShortTimeString(), _message.SenderID, _message.MessageContent };
                    _sender = _message.SenderID;
                    _formattedMessageData.Add(_counter, _tempArray);
                    _counter++;
                }
                MessageView.setMessageTable(_formattedMessageData, _sender);
            }
            else
            {
                MessageView.noMessages = "No Message History Found.";
            }
        }