protected void addDetailsButtonClick(object sender, EventArgs e) { String titleText = ""; String firstText = ""; String lastText = ""; String dateOfBirth = ""; String sexText = ""; String clinicText = ""; String mrnText = ""; String billingText = ""; titleText = titleBox.Text; firstText = firstNameBox.Value; lastText = lastNameBox.Value; dateOfBirth = dobBox.Value; sexText = gender.Text; clinicText = clinicBox.Value; mrnText = MRNBox.Value; billingText = billingBox.Value; using (var db = new UniversityMHIProjectContext()) { var patientDet = new PatientDetails { BillingDetails = billingText, Clinic = clinicText, DateOfBirth = dateOfBirth, FirstName = firstText, LastName = lastText, Gender = sexText, MRN = mrnText, ReferringPhyscian = "", Signature = "" }; db.PatientDetails.Add(patientDet); db.SaveChanges(); } Response.Redirect("ReturningPatient.aspx"); }
protected void dropDrownSelectionIndexChanged(object sender, EventArgs e) { patientTestJunc.Clear(); int selectedIndex = ddlMainPatient.SelectedIndex - 1; PatientDetails ptDet = null; using (var db = new UniversityMHIProjectContext()) { List <PatientDetails> list = db.PatientDetails.ToList(); ptDet = list.ElementAt(selectedIndex); foreach (PatientTestJunction ptJunc in db.PatientTestJunction) { if (ptJunc.PatientId == ptDet.PatientId) { ptJunc.Diagnosis = db.DiagnosisTest.Where(x => x.DiagnosisTestID == ptJunc.DiagnosisTestID).FirstOrDefault(); patientTestJunc.Add(ptJunc); } } } if (ptDet != null) { aspGenderTextBox.Text = ptDet.Gender; aspBillingTextBox.Text = ptDet.BillingDetails; aspClinicTextBox.Text = ptDet.Clinic; aspDOBTextBox.Text = ptDet.DateOfBirth; aspFirstNameTextBox.Text = ptDet.FirstName; aspLastNameTextBox.Text = ptDet.LastName; aspMRNTextBox.Text = ptDet.MRN; aspTitleTextBox.Text = "Mr."; } }