protected void deleteBtn_Click(object sender, EventArgs e) { int appointmentIdentifier; try { appointmentIdentifier = Convert.ToInt32(appointmentsView.SelectedRow.Cells[1].Text); } catch (Exception) { return; } NewBDcon(); dbcon.AppointmentTables.Load(); dbcon.MessagesTables.Load(); AppointmentTable entry = dbcon.AppointmentTables.Find(appointmentIdentifier); string advisorEmail = appointmentsView.SelectedRow.Cells[5].Text; string studentEmail = appointmentsView.SelectedRow.Cells[7].Text; string message = "Appointment Cancel: " + appointmentsView.SelectedRow.Cells[2].Text + " " + appointmentsView.SelectedRow.Cells[3].Text; string role = check_role(); MessagesTable messageEntry; if (role == "advisor") { messageEntry = new MessagesTable { EmailDate = DateTime.Today, EmailFrom = advisorEmail, EmailText = message, EmailTime = DateTime.Today.TimeOfDay, EmailTo = studentEmail }; } else { messageEntry = new MessagesTable { EmailDate = DateTime.Today, EmailFrom = studentEmail, EmailText = message, EmailTime = DateTime.Now.TimeOfDay, EmailTo = advisorEmail }; } dbcon.MessagesTables.Add(messageEntry); dbcon.AppointmentTables.Remove(entry); dbcon.SaveChanges(); View_Own_Appointments(); }
protected void Button1_Click(object sender, EventArgs e) { AppointmentDBEntities1 dbcon = new AppointmentDBEntities1(); int hour = Convert.ToInt32(HourBox.Text); int min = Convert.ToInt32(MinuteBox.Text); AppointmentTable myAppointment = new AppointmentTable(); DoctorTable doctorTable = new DoctorTable(); // add data to the myAppointment myAppointment.Reason = ReasonBox.Text; myAppointment.AppDate = Convert.ToDateTime(DateBox.Text); myAppointment.AppTime = new TimeSpan(hour, min, 0); // add myAppointment to the table dbcon.AppointmentTables.Add(myAppointment); dbcon.SaveChanges(); // clear UsernameBox.Text = ""; DoctorBox.Text = ""; DateBox.Text = ""; HourBox.Text = ""; MinuteBox.Text = ""; ReasonBox.Text = ""; }
protected void Button1_Click(object sender, EventArgs e) { AppointmentDBEntities1 dbcon = new AppointmentDBEntities1(); dbcon.AppointmentTables.Load(); // select item to delete AppointmentTable abc = (from x in dbcon.AppointmentTables.Local where x.AppointmentId == Convert.ToInt32(RemoveBox.Text) select x).First(); // delete obj dbcon.AppointmentTables.Remove(abc); dbcon.SaveChanges(); }
protected void Button1_Click(object sender, EventArgs e) { AppointmentDBEntities1 dbcon = new AppointmentDBEntities1(); EmailTable email = new EmailTable(); email.EmailText = messageTextBox.Text; email.TO = toTextBox.Text; email.FROM = "username"; dbcon.EmailTables.Add(email); dbcon.SaveChanges(); messageTextBox.Text = ""; toTextBox.Text = ""; sentLabel.Text = "Message Sent Successfully"; sentLabel.Visible = true; }
protected void submitBtn_Click(object sender, EventArgs e) { DateTime dateTime; if (DropDownList1.Items.Count != 0) { dateTime = DateTime.ParseExact(DropDownList1.SelectedItem.Value, "hh:mm tt", CultureInfo.InvariantCulture); } else { return; } string role = check_role(); NewBDcon(); dbconDate.StudentTables.Load(); dbconDate.UserTables.Load(); dbconDate.AdvisorTables.Load(); dbconDate.AppointmentTables.Load(); dbconDate.MessagesTables.Load(); TimeSpan span = dateTime.TimeOfDay; string userName = User.Identity.Name; int advisor, student; if ("advisor" == role) { advisor = (from advisors in dbconDate.AdvisorTables.Local where advisors.AdvisorUserName == userName select advisors.AdvisorID).First(); student = Convert.ToInt32(StudentsView.SelectedRow.Cells[1].Text); } else { advisor = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName select students.StudentAdvisorID).First(); student = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName select students.StudentID).First(); } AppointmentTable entry = new AppointmentTable { AdvisorID = advisor, AppointmentDate = Calendar1.SelectedDate, AppointmentReason = TextBox1.Text, StudentID = student, AppointmentTime = span, }; AdvisorTable advisorEntry = dbconDate.AdvisorTables.Find(advisor); StudentTable studentEntry = dbconDate.StudentTables.Find(student); string studentEmail, advisorEmail; if ("advisor" == role) { advisorEmail = (from advisors in dbconDate.AdvisorTables.Local where advisors.AdvisorUserName == userName join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName select user.UserEmail).First(); studentEmail = StudentsView.SelectedRow.Cells[3].Text; } else { studentEmail = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName join user in dbconDate.UserTables.Local on students.StudentUserName equals user.UserName select user.UserEmail).First(); advisorEmail = (from students in dbconDate.StudentTables.Local where students.StudentUserName == userName join advisors in dbconDate.AdvisorTables.Local on students.StudentAdvisorID equals advisors.AdvisorID join user in dbconDate.UserTables.Local on advisors.AdvisorUserName equals user.UserName select user.UserEmail).First(); } DateTime holdTime = DateTime.Today.Add(span); string displayTime = holdTime.ToString("hh:mm tt"); string emailMessage = "Appointment date and Time: " + Calendar1.SelectedDate.ToShortDateString() + " " + displayTime + " \nAppointment Reason: " + TextBox1.Text; MessagesTable message; if ("advisor" == role) { message = new MessagesTable { EmailTime = DateTime.Now.TimeOfDay, EmailDate = DateTime.Today, EmailTo = studentEmail, EmailFrom = advisorEmail, EmailText = emailMessage }; } else { message = new MessagesTable { EmailTime = DateTime.Now.TimeOfDay, EmailDate = DateTime.Today, EmailTo = advisorEmail, EmailFrom = studentEmail, EmailText = emailMessage }; } dbconDate.MessagesTables.Add(message); dbconDate.SaveChanges(); dbconDate.AppointmentTables.Add(entry); dbconDate.SaveChanges(); Response.Redirect(ResolveUrl("Student_Home.aspx")); }