protected void Page_Load(object sender, EventArgs e) { 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; int docID = myPatient.DoctorID; DoctorsTable myDoctor = (from x in myDbcon2.DoctorsTables.Local where x.DoctorID == docID select x).First(); Label1.Text = "Name: " + myPatient.FirstName + " " + myPatient.LastName; Label2.Text = "Doctor: " + myDoctor.FirstName + " " + myDoctor.LastName; myDbcon3.MedicationListTables.Load(); MedicationListTable medicine = (from x in myDbcon3.MedicationListTables.Local where x.PatientID == patID select x).First(); ListBox1.Items.Add(medicine.Description); }
protected void AddMedButton_Click(object sender, EventArgs e) { medicationDB.MedicationListTables.Load(); medicationDB.PatientTables.Load(); string input = MedInputTextBox.Text; int id = Convert.ToInt32(patientIDTextBox.Text); if (!input.Equals("")) { MedicationListTable newMed = new MedicationListTable(); newMed.Description = input; newMed.PatientID = id; //PatientTable currPat = (from x in medicationDB.PatientTables.Local // where x.PatientID == id // select x).FirstOrDefault(); medicationDB.MedicationListTables.Add(newMed); medicationDB.SaveChanges(); } }