protected void ScheduleButton_Click(object sender, EventArgs e) { currDoc = GetCurrentDoctor(); PatientTable currPat = GetPatientFromName(PatientsSelectDropDownList.SelectedValue.Trim()); //Update DB with new appointmnet AppointmentTable appt = new AppointmentTable(); appt.AppointmentID = GenerateApptID(); appt.DoctorID = docID; appt.PatientID = currPat.PatientID; appt.Data = AppointmentDaySelectCalendar.SelectedDate; appt.Time = TimeSpan.Parse(TimeDropDownList.SelectedValue); medDB.AppointmentTables.Add(appt); UpdateDB(); ////Send message to inbox //MessageTable msgToPatient = new MessageTable(); //msgToPatient.MessageID = GenerateMsgID(); //msgToPatient.MessageTo = currUser.UserLoginName; //msgToPatient.MessageFrom = "System"; //msgToPatient.Date = DateTime.Now; ////msgToPatient.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Doctor {currDoc.LastName}"; //msgToPatient.Message = "Appointment scheduled"; //medDB.MessageTables.Add(msgToPatient); //UpdateDB(); //MessageTable msgToDoctor = new MessageTable(); //msgToDoctor.MessageID = GenerateMsgID(); //msgToDoctor.MessageTo = currDoc.UserLoginName; //msgToDoctor.MessageFrom = "System"; //msgToDoctor.Date = DateTime.Now.Date; ////msgToDoctor.Message = $"Appointment scheduled on {appt.Data} @ {appt.Time} with Patient {currUser.FirstName + currUser.LastName}"; //msgToDoctor.Message = "Appointment scheduled"; //medDB.MessageTables.Add(msgToDoctor); //UpdateDB(); Server.TransferRequest(Request.Url.AbsolutePath, false); }
protected void CheckButton_Click(object sender, EventArgs e) { var DoctorLastName = DoctorSelectDropDownList.SelectedValue.Trim(); // when doctor is changed, show only availible times var doctorQuery = from doc in medDB.DoctorTables where doc.LastName.Trim().Equals(DoctorLastName) select doc.DoctorID; // will always find doctor, dropdown only shows current docs int doctorID = doctorQuery.FirstOrDefault(); docID = doctorID; currDoc = GetDoctorFromID(doctorID); var takenTime = (from a in medDB.AppointmentTables where a.DoctorID == doctorID && a.Data == AppointmentDaySelectCalendar.SelectedDate.Date /*&& a.Time.Equals(TimeSpan.Parse(time))*/ select(TimeSpan) a.Time); List <string> workday = new List <string> { new TimeSpan(8, 15, 0).ToString(), new TimeSpan(9, 15, 0).ToString(), new TimeSpan(10, 15, 0).ToString(), new TimeSpan(11, 15, 0).ToString(), new TimeSpan(1, 15, 0).ToString(), new TimeSpan(2, 15, 0).ToString(), new TimeSpan(3, 15, 0).ToString(), new TimeSpan(4, 15, 0).ToString() }; // find open times foreach (TimeSpan t in takenTime) { if (workday.Contains(t.ToString())) { workday.Remove(t.ToString()); } } TimeDropDownList.Items.Clear(); //show times in dropdown foreach (string time in workday) { TimeDropDownList.Items.Add(time.ToString()); } }
protected void SendButton_Click(object sender, EventArgs e) { DoctorTable currDoc = GetCurrentUser(); string selected = DropDownList1.SelectedValue; PatientTable currPatient = GetPatientFromLastName(selected); if (TextBox1.Text.Length < 50) { //PatientTable currentDoc = /*GetDoctorFromLastName(DropDownList1.SelectedValue.ToString())*/; MessageTable msg = new MessageTable(); msg.Date = DateTime.Now; msg.MessageTo = currPatient.Email; msg.MessageFrom = currDoc.Email; msg.Message = TextBox1.Text; //msg.MessageID medDB.MessageTables.Add(msg); medDB.SaveChanges(); } UpdateDB(); Server.TransferRequest(Request.Url.AbsolutePath, false); }