protected void SendButton_Click(object sender, EventArgs e) { //create new MessagesTable object MessagesTable newMessage = new MessagesTable(); newMessage.MessageFROM = Session["LoginName"].ToString().Trim(); newMessage.MessageTO = RecipientsDropDownList.SelectedValue; newMessage.Date = DateTime.Now; newMessage.Message = MessageTextBox.Text; newMessage.IsRead = 0; //update database dbcon.MessagesTables.Add(newMessage); dbcon.SaveChanges(); Server.Transfer("Messages.aspx", true); }
protected void CreateAppointmentButton_Click(object sender, EventArgs e) { flag = true; AppointmentsTable newAppointment = new AppointmentsTable(); newAppointment.PatientID = myPatient.PatientID; newAppointment.DoctorID = Convert.ToInt32(DoctorDropDownList.SelectedItem.Value); newAppointment.Date = Convert.ToDateTime(ShowSelectedDateLabel.Text); int hour = Convert.ToInt32(HourDropDownList.SelectedValue); int min = Convert.ToInt32(MinDropDownList.SelectedValue); TimeSpan mytime = new TimeSpan(hour, min, 0); newAppointment.Time = mytime; newAppointment.Purpose = ""; newAppointment.VisitSummary = ""; foreach (AppointmentsTable appointment in dbcon.AppointmentsTables) { if (DateTime.Compare(appointment.Date, newAppointment.Date) == 0) { if (TimeSpan.Compare(appointment.Time, newAppointment.Time) == 0) { DisplayMesageLabel.Text = "An appointment already exists at this date and time."; DisplayMesageLabel.Visible = true; flag = false; } } } if (flag) { dbcon.AppointmentsTables.Add(newAppointment); dbcon.SaveChanges(); DisplayMesageLabel.Text = "Appointment Added."; DisplayMesageLabel.Visible = true; Server.Transfer("Appointments.aspx", true); } }