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(); }
private void checkUser() { _user = (UserDetails)Session["User"]; if (Request.QueryString["blogOwner"] != null) { string blogOwner = Request.QueryString["blogOwner"]; if (_user != null) { if (_user.UserType == 1) { if (!blogOwner.Equals(_user.UserID)) { Response.Redirect("student_area.aspx", true); } } else { Label author = new Label(); UserDetails blogAuthor = model.selectUserDetailsById(Request.QueryString["blogOwner"]); author.Text = "Blog Author: " + blogAuthor.FirstName + " " + blogAuthor.Surname; author.CssClass = "standardLabel"; authorPanel.Controls.Add(author); newPostLinkPanel.Visible = false; newPostFormPanel.Visible = false; } } } else { if (_user.UserType == 1) { Response.Redirect("blog.aspx?blogOwner=" + _user.UserID, true); } else { if (!Page.IsPostBack) { general_functions.Instance.loadTuteeDropDown("blog"); } selectTuteePanel.Visible = true; blogHistoryLinkPanel.Visible = false; blogHistoryPanel.Visible = false; newPostLinkPanel.Visible = false; newPostFormPanel.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { controller.MeetingView = this; populateTable(); general_functions.Instance.MeetingView = this; Meeting_Controller.ControllerInstance.MeetingView = this; general_functions.Instance.setWelcomeMessage("meeting"); populateDropDownList(); UserDetails studentCheck = new UserDetails(); List<MeetingDetails> meetingDetailsLists = new List<MeetingDetails>(); studentCheck = (UserDetails)Session["User"]; if ((Session["StudentMeetingDetailsLists"] != null) && (HttpContext.Current.Request.QueryString["ButtonID"] != null) && (HttpContext.Current.Request.QueryString["type"] != null)) { meetingDetailsLists = (List<MeetingDetails>)Session["StudentMeetingDetailsLists"]; foreach (MeetingDetails meetingItem in meetingDetailsLists) { if (meetingItem.MeetingID == int.Parse(HttpContext.Current.Request.QueryString["ButtonID"]) && studentCheck.UserID == meetingItem.StudentID) { if (HttpContext.Current.Request.QueryString["type"] == "Accept") { string MeetingID = meetingItem.MeetingID.ToString(); string updateType = "Accepted"; updateMeeting(MeetingID, updateType); break; } if (HttpContext.Current.Request.QueryString["type"] == "Decline") { string MeetingID = meetingItem.MeetingID.ToString(); string updateType = "Declined"; updateMeeting(MeetingID, updateType); break; } if (HttpContext.Current.Request.QueryString["type"] == "AcceptDecline") { string MeetingID = meetingItem.MeetingID.ToString(); string updateType = "Accepted"; updateMeeting(MeetingID, updateType); break; } if (HttpContext.Current.Request.QueryString["type"] == "DeclineAccept") { string MeetingID = meetingItem.MeetingID.ToString(); string updateType = "Declined"; updateMeeting(MeetingID, updateType); break; } else { break; } } } } if (!IsPostBack) { appointmentPanel.Visible = true; Session["StudentMeetingDetailsLists"] = null; populateDropDownList(); populateTable(); } }
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(); }
private UserDetails constructUserDetailsFromReader(SqlDataReader rdr) { UserDetails ud = null; string _userid = rdr["UserID"].ToString(); string _fname = rdr["Firstname"].ToString(); string _sname = rdr["Surname"].ToString(); string _email = rdr["EmailAddress"].ToString(); string _pass = rdr["Password"].ToString(); int _type = int.Parse(rdr["UserType"].ToString()); string _supervisor = rdr["SupervisorID"].ToString(); string _programme = rdr["ProgrammeID"].ToString(); int _programmeID = 0, result; if (int.TryParse(_programme, out result)) { _programmeID = result; } ud = new UserDetails(_userid, _fname, _sname, _email, _pass, _type, _supervisor, _programmeID); return ud; }
public static UserDetails getUserById(string id) { UserDetails user = null; try { string command = "SELECT * FROM UserDetails WHERE UserID = '" + id + "'"; SqlCommand sqlCommand = new SqlCommand(command, DBConnection.getInstance().Conn); DBConnection.getInstance().Conn.Open(); using (SqlDataReader reader = sqlCommand.ExecuteReader()) { if (reader.Read()) { string userID = reader.GetString(reader.GetOrdinal("UserID")); string firstName= reader.GetString(reader.GetOrdinal("FirstName")); string surname = reader.GetString(reader.GetOrdinal("Surname")); string emailAddress = reader.GetString(reader.GetOrdinal("EmailAddress")); string password = reader.GetString(reader.GetOrdinal("Password")); int userType = reader.GetInt32(reader.GetOrdinal("UserType")); string supervisorID = reader.IsDBNull(reader.GetOrdinal("SupervisorID")) ? " " : reader.GetString(reader.GetOrdinal("SupervisorID")).ToString(); int programmeID = reader.IsDBNull(reader.GetOrdinal("ProgrammeID")) ? 0 : reader.GetInt32(reader.GetOrdinal("ProgrammeID")); user = new UserDetails(userID, firstName, surname, emailAddress, password, userType, supervisorID, programmeID); } } } catch (ArgumentOutOfRangeException aoorex) { return null; } catch (Exception ex) { return null; } finally { DBConnection.getInstance().Conn.Close(); } return user; }
// Set User Session Variables method private void setUserSessionVariables(UserDetails User) { HttpContext.Current.Session["User"] = User; }