コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string _recieverEmail = "";
            string _senderEmail = "";
            string _message = "";
            string _subject = "";
               string calendarValue = DateTime.Now.ToShortDateString();

               if (Calendar1.SelectedDate.ToShortDateString() == "01/01/0001")
               {
               calendarValue = DateTime.Now.AddDays(1).ToShortDateString();
               }
               else
               {
               calendarValue = Calendar1.SelectedDate.ToShortDateString();
               }

            UserDetails _user = (UserDetails)Session["User"];

            UserDetails studentDetails = new UserDetails();
            MeetingDetails meetingInfo = new MeetingDetails();
            meetingInfo.selectMeetingDetailsByMeetingID();

            studentDetails = UserDetails.getUserById(tuteeDdl.SelectedValue);

            _recieverEmail = studentDetails.EmailAddress.ToString().Trim();
            _senderEmail = _user.EmailAddress.ToString();

            _subject = "Meeting Request";
            _message = "Hello " + studentDetails.FirstName.ToString().Trim() + " "+ studentDetails.Surname.ToString().Trim() +", ";
            _message += Environment.NewLine;
            _message += "You have been requested to attend the following meeting at the following location by " + _user.Fullname + ", please respond, thank you.";
            _message += "Location: " + Environment.NewLine;
            _message += TextBox1.Text + Environment.NewLine;
            _message += Environment.NewLine + "Date and Time:";
            _message += Environment.NewLine + calendarValue + " " + DropDownList1.SelectedItem + ":" + DropDownList3.SelectedItem;
            _message += Environment.NewLine + Environment.NewLine;
            _message += "Kind Regards, " + Environment.NewLine + _user.Fullname.ToString();
            general_functions.Instance.email(_recieverEmail, _senderEmail, _message, _subject);
            DateTime dtt = Convert.ToDateTime((DropDownList1.SelectedItem.ToString() + ":" + DropDownList3.SelectedItem.ToString() +":" + "00").ToString());
            TimeSpan TS = new TimeSpan(dtt.Hour, dtt.Minute, dtt.Second);
            string selectedTutee = (String) Session["selectedStudent"];

            MeetingDetails tutorMeetingDetails = new MeetingDetails(selectedTutee,
                _user.UserID,
                Convert.ToDateTime(calendarValue),
                TS,
                DropDownList2.SelectedItem.ToString(),
                TextBox1.Text,
                "-",
                "Accepted");
            tutorMeetingDetails.insertToDatabase();

            populateDropDownList();
            TuteesSelectionPanel.Visible = false;
            appointmentPanel.Visible = true;
            populateTable();
        }
コード例 #2
0
        public static List <MeetingDetails> getAllMeetingsByStudentID(string id)
        {
            try
            {
                List <MeetingDetails> allMeetings = new List <MeetingDetails>();
                string command =
                    "SELECT MeetingDetails.MeetingID, MeetingDetails.StudentID, { fn CONCAT({ fn CONCAT(UserDetails.Firstname, ', ') }, dbo.UserDetails.Surname) } AS 'Student', " +
                    "MeetingDetails.TutorID, { fn CONCAT({ fn CONCAT(UserDetails_1.Firstname, ', ') }, UserDetails_1.Surname) } AS Tutor, dbo.MeetingDetails.Date, " +
                    "MeetingDetails.Time, MeetingDetails.Type, MeetingDetails.Location, MeetingDetails.StudentStatus, MeetingDetails.TutorStatus " +
                    "FROM MeetingDetails INNER JOIN " +
                    "UserDetails ON MeetingDetails.StudentID = UserDetails.UserID INNER JOIN " +
                    "UserDetails AS UserDetails_1 ON MeetingDetails.TutorID = UserDetails_1.UserID " +
                    "WHERE MeetingDetails.StudentID='" + id + "' ORDER BY Date DESC, Time DESC";

                SqlCommand sqlCommand = new SqlCommand(command, DBConnection.getInstance().Conn);

                DBConnection.getInstance().Conn.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        long     _meetingID     = reader.GetInt32(reader.GetOrdinal("MeetingID"));
                        string   _studentID     = reader.GetString(reader.GetOrdinal("StudentID"));
                        string   _tutorID       = reader.GetString(reader.GetOrdinal("TutorID"));
                        DateTime _date          = reader.GetDateTime(reader.GetOrdinal("Date"));
                        TimeSpan _time          = reader.GetTimeSpan(reader.GetOrdinal("Time"));;
                        string   _type          = reader.GetString(reader.GetOrdinal("Type"));
                        string   _location      = reader.GetString(reader.GetOrdinal("Location"));
                        string   _StudentStatus = reader.GetString(reader.GetOrdinal("StudentStatus"));
                        string   _TutorStatus   = reader.GetString(reader.GetOrdinal("TutorStatus"));
                        string   _studentName   = reader.GetString(reader.GetOrdinal("Student"));
                        string   _tutorName     = reader.GetString(reader.GetOrdinal("Tutor"));

                        MeetingDetails md = new MeetingDetails(_meetingID, _studentID,
                                                               _tutorID, _date, _time, _type, _location, _StudentStatus, _TutorStatus, _studentName, _tutorName);
                        allMeetings.Add(md);
                    }
                }
                return(allMeetings);
            }
            catch (ArgumentOutOfRangeException aoorex)
            {
                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                DBConnection.getInstance().Conn.Close();
            }
        }
コード例 #3
0
        //public static List<MeetingDetails> getAllMeetingsByStudentID(string id)
        //{
        //    try
        //    {
        //        List<MeetingDetails> allMeetings = new List<MeetingDetails>();
        //        string command = "SELECT * FROM MeetingDetails WHERE StudentID = '" + id + "'";
        //        SqlCommand sqlCommand = new SqlCommand(command, DBConnection.getInstance().Conn);
        //        DBConnection.getInstance().Conn.Open();
        //        using (SqlDataReader reader = sqlCommand.ExecuteReader())
        //        {
        //            while (reader.Read())
        //            {
        //                long _meetingID = reader.GetInt32(reader.GetOrdinal("MeetingID"));
        //                string _studentID = reader.GetString(reader.GetOrdinal("StudentID"));
        //                string _tutorID = reader.GetString(reader.GetOrdinal("TutorID"));
        //                DateTime _date = reader.GetDateTime(reader.GetOrdinal("Date"));
        //                TimeSpan _time = reader.GetTimeSpan(reader.GetOrdinal("Time")); ;
        //                string _type = reader.GetString(reader.GetOrdinal("Type"));
        //                string _location = reader.GetString(reader.GetOrdinal("Location"));
        //                string _StudentStatus = reader.GetString(reader.GetOrdinal("StudentStatus"));
        //                string _TutorStatus = reader.GetString(reader.GetOrdinal("TutorStatus"));
        //                MeetingDetails md = new MeetingDetails(_meetingID, _studentID,
        //                    _tutorID, _date, _time, _type, _location, _StudentStatus, _TutorStatus);
        //                allMeetings.Add(md);
        //            }
        //        }
        //        return allMeetings;
        //    }
        //    catch (ArgumentOutOfRangeException aoorex)
        //    {
        //        return null;
        //    }
        //    catch (Exception ex)
        //    {
        //        return null;
        //    }
        //    finally
        //    {
        //        DBConnection.getInstance().Conn.Close();
        //    }
        //}
        public static List<MeetingDetails> getAllMeetingsByTutorID(string id)
        {
            try
            {
                List<MeetingDetails> allMeetings = new List<MeetingDetails>();
                string command =
            "SELECT MeetingDetails.MeetingID, MeetingDetails.StudentID, { fn CONCAT({ fn CONCAT(UserDetails.Firstname, ', ') }, dbo.UserDetails.Surname) } AS 'Student', " +
            "MeetingDetails.TutorID, { fn CONCAT({ fn CONCAT(UserDetails_1.Firstname, ', ') }, UserDetails_1.Surname) } AS Tutor, dbo.MeetingDetails.Date, " +
            "MeetingDetails.Time, MeetingDetails.Type, MeetingDetails.Location, MeetingDetails.StudentStatus, MeetingDetails.TutorStatus " +
            "FROM MeetingDetails INNER JOIN " +
            "UserDetails ON MeetingDetails.StudentID = UserDetails.UserID INNER JOIN " +
            "UserDetails AS UserDetails_1 ON MeetingDetails.TutorID = UserDetails_1.UserID " +
            "WHERE MeetingDetails.TutorID='" + id + "' ORDER BY Date DESC, Time DESC";

                SqlCommand sqlCommand = new SqlCommand(command, DBConnection.getInstance().Conn);

                DBConnection.getInstance().Conn.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        long _meetingID = reader.GetInt32(reader.GetOrdinal("MeetingID"));
                        string _studentID = reader.GetString(reader.GetOrdinal("StudentID"));
                        string _tutorID = reader.GetString(reader.GetOrdinal("TutorID"));
                        DateTime _date = reader.GetDateTime(reader.GetOrdinal("Date"));
                        TimeSpan _time = reader.GetTimeSpan(reader.GetOrdinal("Time")); ;
                        string _type = reader.GetString(reader.GetOrdinal("Type"));
                        string _location = reader.GetString(reader.GetOrdinal("Location"));
                        string _StudentStatus = reader.GetString(reader.GetOrdinal("StudentStatus"));
                        string _TutorStatus = reader.GetString(reader.GetOrdinal("TutorStatus"));
                        string _studentName = reader.GetString(reader.GetOrdinal("Student"));
                        string _tutorName = reader.GetString(reader.GetOrdinal("Tutor"));

                        MeetingDetails md = new MeetingDetails(_meetingID, _studentID,
                            _tutorID, _date, _time, _type, _location, _StudentStatus, _TutorStatus, _studentName, _tutorName);
                        allMeetings.Add(md);
                    }
                }
                return allMeetings;
            }
            catch (ArgumentOutOfRangeException aoorex)
            {
                return null;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                DBConnection.getInstance().Conn.Close();
            }
        }
コード例 #4
0
        private void updateMeeting(string MeetingID, string updateType)
        {
            string _recieverEmail = "";
            string _senderEmail = "";
            string _message = "";
            string _subject = "";

            UserDetails _user = (UserDetails)Session["User"];

             UserDetails tutorDetails = new UserDetails();
            MeetingDetails meetingInfo = new MeetingDetails();
            meetingInfo.MeetingID = long.Parse(MeetingID);
            meetingInfo.selectMeetingDetailsByMeetingID();

            tutorDetails= UserDetails.getUserById(meetingInfo.TutorID.ToString());

            _recieverEmail = tutorDetails.EmailAddress.ToString().Trim();
            _senderEmail = _user.EmailAddress.ToString();
            _subject = "Meeting Update";
            _message = "Hello " + tutorDetails.FirstName + " "+tutorDetails.Surname;
            _message += Environment.NewLine;
            _message += "There is a meeting update please login to the eTutor System to view the meeting details, thank you.";
            _message += Environment.NewLine + Environment.NewLine;
            _message += "Kind Regards, " + Environment.NewLine + _user.Fullname.ToString();
            general_functions.Instance.email(_recieverEmail, _senderEmail, _message, _subject);

            if(updateType == "Accepted")
            {
                meetingInfo.StudentStatus = "Accepted";
            }
            else if(updateType == "Declined")
            {
                meetingInfo.StudentStatus = "Declined";
            }

            meetingInfo.updateStudentToDatabase();

            populateDropDownList();
            appointmentPanel.Visible = true;
            populateTable();
        }