public int AddPatient(PolyclinicBL.Patient patient) { int patientsId; using (SqlConnection connection = new SqlConnection(Settings.Default.PolyclinicDBConnect)) { using (SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[Patient] ([LastName], [FirstName], [Patronymic], [Birth],[Gender],[Region],[Address],[RegistrationDate]) output INSERTED.ID VALUES( @LN, @FN, @Patronymic, @Birth, @Gender, @Region, @Address, @RegistrationDate)", connection)) { cmd.Parameters.AddWithValue("@LN", patient.LastName); cmd.Parameters.AddWithValue("@FN", patient.FirstName); cmd.Parameters.AddWithValue("@Patronymic", patient.Patronymic); cmd.Parameters.AddWithValue("@Birth", patient.Birth); cmd.Parameters.AddWithValue("@Gender", patient.Gender); cmd.Parameters.AddWithValue("@Region", patient.Region); cmd.Parameters.AddWithValue("@Address", patient.Address); cmd.Parameters.AddWithValue("@RegistrationDate", patient.RegistrationDate); connection.Open(); patientsId = (int)cmd.ExecuteScalar(); connection.Close(); } } return(patientsId); }
private void IRegistrationView_SaveChanges(object sender, EventArgs e) { //Adding the patient to the DataBase or somewhere PolyclinicBL.Patient patient = iRegistrationView.GetNewPatient(); int patientsId = iRegistrationModel.AddPatient(patient); patient.id = patientsId; //Creating patients medical card iMedicalCardManager.CreateMedicalCard(patient); //Cheking streets register iRegistrationModel.CheckStreets(Editor.GetStreet(patient.Address), patient.Region); }