protected void DeletePatientAppointButton_Click(object sender, EventArgs e) { if (ShowPatientAppointments.SelectedRow != null) // if appointment selected to delete on gridview, do this { AppointmentsTable delete = new AppointmentsTable(); string input = ShowPatientAppointments.SelectedValue.ToString(); // gets AppointmentID of selected row int appointmentID = Convert.ToInt32(input); delete = UtilitiesClass.createAppointment(appointmentID); // creates copy of appointment object to delete foreach (AppointmentsTable appointment in dbcon.AppointmentsTables) // check if appointment exists { if (appointment.AppointmentID == delete.AppointmentID) // if appointment exists, delete it { dbcon.AppointmentsTables.Remove(appointment); } } dbcon.SaveChanges(); // save changes to database ShowPatientAppointments.DataBind(); // update changes to grid view displaying patient appointment if (ShowPatientAppointments.Rows.Count == 0) // if no appointments, display message { DisplayNoAppointMessage.Text = "You have no appointments set up."; DisplayNoAppointMessage.Visible = true; DeletePatientAppointButton.Visible = false; // makes delete appointment button invisible } } }
public static void Initialize() { Appointments = new AppointmentsTable(); Doctors = new DoctorsTable(); Patients = new PatientsTable(); AppointmentsConflicts = new AppointmentConflictsTable(); AppointmentsOpLog = new AppointmentsOpLogTable(); Patients.Add(new PatientModel() { PatientId = "19860813-XXXX", PatientName = "Henrik Karlsson" }); Patients.Add(new PatientModel() { PatientId = "19750612-XXXX", PatientName = "Erik Henriksson" }); Patients.Add(new PatientModel() { PatientId = "19600519-XXXX", PatientName = "Cecilia Eliasson" }); Doctors.Add(new DoctorModel() { DoctorId = "201012-1425", DoctorName = "Mikael Seström" }); Doctors.Add(new DoctorModel() { DoctorId = "200911-1758", DoctorName = "Carina Axel" }); Doctors.Add(new DoctorModel() { DoctorId = "199005-1875", DoctorName = "Martin Eriksson" }); }
protected void DeleteDoctorAppointButton_Click(object sender, EventArgs e) // same logic for deleting patient appointments { if (ShowDoctorAppointments.SelectedRow != null) { AppointmentsTable delete = new AppointmentsTable(); string input = ShowDoctorAppointments.SelectedValue.ToString(); int appointmentID = Convert.ToInt32(input); delete = UtilitiesClass.createAppointment(appointmentID); foreach (AppointmentsTable appointment in dbcon.AppointmentsTables) { if (appointment.AppointmentID == delete.AppointmentID) { dbcon.AppointmentsTables.Remove(appointment); } } dbcon.SaveChanges(); ShowDoctorAppointments.DataBind(); if (ShowDoctorAppointments.Rows.Count == 0) { DisplayNoAppointMessage.Text = "You have no appointments set up."; DisplayNoAppointMessage.Visible = true; DeleteDoctorAppointButton.Visible = false; } } }
private void Button1_Click(object sender, EventArgs e) { switch (comboBox2.SelectedIndex) { case 0: EventsTable eventsTable = new EventsTable(); eventsTable.Show(); break; case 1: WorkersTable workersTable = new WorkersTable(); workersTable.Show(); break; case 2: DocsTable docsTable = new DocsTable(); docsTable.Show(); break; case 3: AppointmentsTable appointmentsTable = new AppointmentsTable(); appointmentsTable.Show(); break; case 4: CompaniesTable companiesTable = new CompaniesTable(); companiesTable.Show(); break; } }
protected void Button1_Click(object sender, EventArgs e) { if ((DateTime.Compare(Calendar1.SelectedDate, DateTime.Now) < 0)) { Label2.Text = "Error: please select date today or After " + Calendar1.SelectedDate.ToString(); } if (TextBox_time.Text.Length == 0) { Label2.Text = "Error: please enter a time for the appointment"; } if (TextBox_time.Text.Length > 0 && DateTime.Compare(Calendar1.SelectedDate, DateTime.Now) >= 0) { dbcon.AppointmentsTables.Load(); AppointmentsTable app = new AppointmentsTable(); app.DoctorID = Convert.ToInt32(DropDownList_doctor.SelectedValue); app.Date = Calendar1.SelectedDate; app.Time = TimeSpan.Parse(TextBox_time.Text, System.Globalization.CultureInfo.CurrentCulture); app.PatientID = patPK; app.Purpose = TextBox_purpose.Text.Trim(); int confilcts_pat = (from x in dbcon.AppointmentsTables.Local where x.PatientID == patPK && (DateTime.Compare(app.Date, x.Date) == 0) && TimeSpan.Compare(app.Time, x.Time) == 0 select x).ToList().Count; int confilcts_Doc = (from x in dbcon.AppointmentsTables.Local where x.DoctorID == app.DoctorID && (DateTime.Compare(app.Date, x.Date) == 0) && TimeSpan.Compare(app.Time, x.Time) == 0 select x).ToList().Count; if (confilcts_Doc > 0) { Label2.Text = "Error: Doctor has conflict"; } else if (confilcts_pat > 0) { Label2.Text = "Error: Can't schedule 2 appointments at the same time"; } else { dbcon.AppointmentsTables.Add(app); dbcon.SaveChanges(); GridView1.DataBind(); Label2.Text = "Appointment created!"; } } }
protected void Button1_Click(object sender, EventArgs e) { HA3_DataBaseV1Entities3 myDbcon4 = new HA3_DataBaseV1Entities3(); myDbcon4.AppointmentsTables.Load(); AppointmentsTable delApp = (from x in myDbcon4.AppointmentsTables.Local where x.AppointmentID == Convert.ToInt32(Label3.Text) select x).First(); myDbcon4.AppointmentsTables.Remove(delApp); myDbcon4.SaveChanges(); GridView1.DataBind(); MessageBox.Show("Appointment successfully deleted."); }
protected void Button_delete_Click(object sender, EventArgs e) { if (GridView1.SelectedIndex >= 0) { dbcon.AppointmentsTables.Load(); // load up the database // find the appointment based on the Appointment ID AppointmentsTable app = dbcon.AppointmentsTables.Find(Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text)); // delete the item dbcon.AppointmentsTables.Remove(app); //remove the appointment dbcon.SaveChanges(); // save the changes GridView1.DataBind(); // update the gridview } }
protected void Button1_Click(object sender, EventArgs e) { if (Calendar1.SelectedDate <= DateTime.Now) { MessageBox.Show("Date has to be after current day!"); } else { AppointmentsTable myAppointment = new AppointmentsTable(); string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); int patID = myPatient.PatientsID; /* myDbcon2.DoctorsTables.Load(); * * var myApp = from x in myDbcon2.DoctorsTables.Local * where x.Department == DropDownList2.SelectedValue * select x; * * DropDownList3.DataSource = myApp.ToList(); * DropDownList3.DataBind(); */ /*myDbcon3.DoctorsTables.Load(); * DoctorsTable myDoc = (from x in myDbcon3.DoctorsTables.Local * where (x.FirstName + x.LastName) == DropDownList3.SelectedValue * select x).First();*/ myAppointment.PatientID = patID; myAppointment.Purpose = TextBox1.Text; myAppointment.DoctorID = Convert.ToInt32(DropDownList3.SelectedValue); myAppointment.VisitSummary = TextBox2.Text; myAppointment.Date = Calendar1.SelectedDate; int hours = Convert.ToInt32(TextBox3.Text); int mins = Convert.ToInt32(DropDownList1.SelectedValue); myAppointment.Time = new TimeSpan(hours, mins, 0); //Check for conflicting appointments bool timeconflict = false; foreach (var x in myDbcon1.AppointmentsTables) { if (myAppointment.Date == x.Date && myAppointment.Time == x.Time) { timeconflict = true; } } if (timeconflict == true) { //Display error message MessageBox.Show("Time conflicts with an existing appointment."); } else { //Add data to the table myDbcon1.AppointmentsTables.Add(myAppointment); myDbcon1.SaveChanges(); MessageBox.Show("Appointment successfully created."); } } }