У меня есть код Linq-to-SQL, который передает данные в базу данных в соответствующей таблице,
PatientInformation
и ResponsibleParty
:
public void addPatientInformation() {
using(DbClassesDataContext myDb = new DbClassesDataContext(dbPath)){
PatientInfo patientInfo = new PatientInfo();
patientInfo.Phy_ID = physcianID;
patientInfo.Pat_First_Name = txtFirstName.Text;
patientInfo.Pat_Middle_Name = txtMiddleName.Text;
patientInfo.Pat_Last_Name = txtLastName.Text;
patientInfo.Pat_Gender = cmbGender.Text;
patientInfo.Pat_Marital_Status = cmbMaritalStatus.Text;
patientInfo.Pat_Date_Of_Birth = dtpDOB.Value;
patientInfo.Pat_Home_Add = txtHomeAdd.Text;
patientInfo.Pat_Home_Num = txtPhone.Text;
patientInfo.Pat_Work_Add = txtWorkAdd.Text;
patientInfo.Pat_Work_Num = txtWorkPhone.Text;
patientInfo.Pat_Prim_Physician = txtPrimPhysician.Text;
patientInfo.Pat_Ref_Physician = txtRefePhysician.Text;
myDb.PatientInfos.InsertOnSubmit(patientInfo);
myDb.SubmitChanges();
}
}
public void addResponsiblePartyInformation() {
using(DbClassesDataContext myDb = new DbClassesDataContext(dbPath)){
ResponsibleParty responsibleParty = new ResponsibleParty();
responsibleParty.Res_First_Name = txtResFirstName.Text;
responsibleParty.Res_Middle_Init = txtResMiddleName.Text;
responsibleParty.Res_Last_Name = txtResLName.Text;
responsibleParty.Res_Gender = cmbResGender.Text;
responsibleParty.Res_Marital_Status = cmbResMaritalStatus.Text;
responsibleParty.Res_Date_Of_Birth = dtpResDOB.Value;
responsibleParty.Res_Home_Add = txtResHomeAdd.Text;
responsibleParty.Res_Home_Num = txtResPhone.Text;
responsibleParty.Res_Work_Add = txtResWorkAdd.Text;
responsibleParty.Res_Work_Num = txtResWorkPhone.Text;
myDb.ResponsibleParties.InsertOnSubmit(responsibleParty);
myDb.SubmitChanges();
}
И метод с именем
public void submitInformationToDatabase() {
addPatientInformation();
addResponsiblePartyInformation();
MessageBox.Show("Patient Demographics Has Been added.");
}
Есть ли способ, которым я мог бы представить их сразу?