Exemple #1
0
        public static int AddCourse(Course course)
        {
            int courseID = -1;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.AddCourse"))
            {
                // Set Parameters
                AddParameters(course, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                courseID = Convert.ToInt32(db.comm.ExecuteScalar());
            }

            return courseID;
        }
Exemple #2
0
 public Session()
 {
     course = new Course();
     instructor = new Instructor();
     room = new Room();
 }
Exemple #3
0
        public static int UpdateCourse(Course course, Course oldCourse)
        {
            int rowsAffected = 0;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.UpdateCourse"))
            {
                // Set Parameters
                AddParameters(course, db.comm);
                AddOldParameters(oldCourse, db.comm);

                // Open Connection
                db.conn.Open();

                // Execute Command and Read Response
                rowsAffected = db.comm.ExecuteNonQuery();
            }

            return rowsAffected;
        }
Exemple #4
0
 private static void AddParameters(Course course, SqlCommand comm)
 {
     comm.Parameters.AddWithValue("CourseCode", course.CourseCode);
     comm.Parameters.AddWithValue("Description", course.CourseDescription);
     comm.Parameters.AddWithValue("Outline", course.CourseOutline);
     comm.Parameters.AddWithValue("Price", course.CoursePrice);
 }
Exemple #5
0
 public static Course ReadCourse(SqlDataReader reader)
 {
     Course course = new Course();
     course.CourseID = (int)reader["CourseID"];
     course.CourseCode = (string)reader["CourseCode"];
     course.CourseDescription = (string)reader["CourseDescription"];
     course.CourseOutline = (string)reader["CourseOutline"];
     course.CoursePrice = (decimal)reader["CoursePrice"];
     return course;
 }