public static Identity GetLastIdentity() { // set up dal settings DAL settings = new DAL(); // init new identity object Identity identity = new Identity() { lastId = ZERO }; using (SqlConnection connection = new SqlConnection(DALUtility.BuildConnectionString())) { // open connection connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = settings.GET_LAST_PT; command.CommandType = CommandType.StoredProcedure; try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { identity = new Identity(reader, true); } } } catch (Exception exception) { string parameters = identity.lastId.ToString(); Shields_Error_Logger.LogError(exception, "GetAllIdentities(string lastId)", parameters); } } return(identity); }
public static List <Identity> GetAllIdentities() { // init dal settings DAL settings = new DAL(); // make new list of identities List <Identity> identities = new List <Identity>(); using (SqlConnection connection = new SqlConnection(DALUtility.BuildConnectionString())) { // open connection connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = settings.GET_ALL_PATIENTS; command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@LASTID", DBNull.Value); try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { identities.Add(new Identity(reader)); } } } catch (Exception exception) { string parameters = "all patients"; Shields_Error_Logger.LogError(exception, "GetAllIdentities(string lastId)", parameters); } } return(identities); }