/// <summary> /// Updates a record in the Registration table. /// </summary> public void Update() { SqlConnection scon = DBHandling.GetConnection(); SqlCommand scom = new SqlCommand("RegistrationUpdate", scon); scom.CommandType = CommandType.StoredProcedure; scom.Parameters.Add("@StudentID", SqlDbType.Int, 4); scom.Parameters.Add("@Name", SqlDbType.VarChar, 500); scom.Parameters.Add("@DateOfBirth", SqlDbType.DateTime, 8); scom.Parameters.Add("@GradePointAvg", SqlDbType.Decimal, 9); scom.Parameters.Add("@Active", SqlDbType.Bit, 1); scom.Parameters["@StudentID"].Value = studentID; scom.Parameters["@Name"].Value = name; scom.Parameters["@DateOfBirth"].Value = dateOfBirth; scom.Parameters["@GradePointAvg"].Value = gradePointAvg; scom.Parameters["@Active"].Value = active; scon.Open(); scom.ExecuteNonQuery(); scon.Close(); }
/// <summary> /// Deletes a record from the Registration table by its primary key. /// </summary> public void Delete() { SqlConnection scon = DBHandling.GetConnection(); SqlCommand scom = new SqlCommand("RegistrationDelete", scon); scom.CommandType = CommandType.StoredProcedure; scom.Parameters.Add("@StudentID", SqlDbType.Int, 4); scom.Parameters["@StudentID"].Value = studentID; scon.Open(); scom.ExecuteNonQuery(); scon.Close(); }
/// <summary> /// Selects all records from the Registration table. /// </summary> public static List <Registration> SelectAll() { SqlConnection scon = DBHandling.GetConnection(); SqlCommand scom = new SqlCommand("RegistrationSelectAll", scon); scom.CommandType = CommandType.StoredProcedure; scon.Open(); List <Registration> registrationList = new List <Registration>(); using (SqlDataReader dataReader = scom.ExecuteReader()){ while (dataReader.Read()) { Registration registration = MakeRegistration(dataReader); registrationList.Add(registration); } } scon.Close(); return(registrationList); }
/// <summary> /// Selects a single record from the Registration table. /// </summary> public static Registration Select(int studentID_Incoming) { Registration Registrationins = new Registration(); SqlConnection scon = DBHandling.GetConnection(); SqlCommand scom = new SqlCommand("RegistrationSelect", scon); scom.CommandType = CommandType.StoredProcedure; scon.Open(); scom.Parameters.Add("@StudentID", SqlDbType.Int, 4); scom.Parameters["@StudentID"].Value = studentID_Incoming; using (SqlDataReader dataReader = scom.ExecuteReader()){ if (dataReader.Read()) { Registrationins = MakeRegistration(dataReader); } else { Registrationins = null; } } scon.Close(); return(Registrationins); }