public Patient SavePatient(Patient patient) { string myConn = "Data Source=ANANTH-PC\\HEGDE;Initial Catalog=EMR;Integrated Security=True"; SqlConnection myConnection = new SqlConnection(myConn); SqlCommand command = myConnection.CreateCommand(); command.CommandText = "INSERT INTO Patient(familyname,fname,lname,age,dateofbirth,sex,address,city,state,email,phone)" + "VALUES(@familyname,@fname,@lname,@age,@dob,@sex,@address,@city,@state,@email,@phone)"; command.Parameters.AddWithValue("@familyname", patient.familyName.Trim()); command.Parameters.AddWithValue("@fname", patient.firstName); command.Parameters.AddWithValue("@lname", (patient.lastName == null) ? string.Empty : patient.lastName); command.Parameters.AddWithValue("@age", patient.age); command.Parameters.AddWithValue("@dob", patient.dob); command.Parameters.AddWithValue("@sex", patient.sex); command.Parameters.AddWithValue("@address", (patient.address == null) ? string.Empty : patient.address); command.Parameters.AddWithValue("@city", (patient.city == null) ? string.Empty : patient.city); command.Parameters.AddWithValue("@state", (patient.state == null) ? string.Empty : patient.state); command.Parameters.AddWithValue("@email", patient.email); command.Parameters.AddWithValue("@phone", patient.phone); command.Connection = myConnection; command.Connection.Open(); command.ExecuteNonQuery(); string query2 = "Select @@Identity"; command.CommandText = query2; patient.patientid = command.ExecuteScalar().ToString(); command.Connection.Close(); return patient; }
public CreateUserResponse CreateAccount(Patient patient) { CreateUserResponse response = new CreateUserResponse(); Account account; AccountBO registrationBO = new AccountBO(); account = registrationBO.CreateAccount(patient); response.account = account; return response; }
public Account CreateAccount(Patient patient) { AccountDAO accountDAO = new AccountDAO(); Account account = new Account(); account.password = CreateRandomPassword(5); account.userID = CreateRegistrationnumber(5); using (TransactionScope scope = new TransactionScope()) { patient = accountDAO.SavePatient(patient); accountDAO.SaveRegisteration(account, patient.patientid); scope.Complete(); } return account; }