コード例 #1
0
ファイル: Session.cs プロジェクト: nfearnley/ADD
 public Session()
 {
     course = new Course();
     instructor = new Instructor();
     room = new Room();
 }
コード例 #2
0
ファイル: Instructor.cs プロジェクト: nfearnley/ADD
        // Add Instructor, return InstructorID
        public static int AddInstructor(Instructor instructor)
        {
            int instructorID = -1;

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

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

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

            return instructorID;
        }
コード例 #3
0
ファイル: Instructor.cs プロジェクト: nfearnley/ADD
        // Update Instructor, return number of rows affected
        public static int UpdateInstructor(Instructor instructor, Instructor oldInstructor)
        {
            int rowsAffected = 0;

            // Setup Connection
            using (DatabaseConnection db = new DatabaseConnection("dbo.UpdateInstructor"))
            {
                // Set Parameters
                AddParameters(instructor, db.comm);
                AddOldParameters(oldInstructor, db.comm);

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

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

            return rowsAffected;
        }
コード例 #4
0
ファイル: Instructor.cs プロジェクト: nfearnley/ADD
 // Set Parameters
 private static void AddParameters(Instructor instructor, SqlCommand comm)
 {
     comm.Parameters.AddWithValue("AddressCity", instructor.InstructorAddressCity);
     comm.Parameters.AddWithValue("AddressCountry", instructor.InstructorAddressCountry);
     comm.Parameters.AddWithValue("AddressLine1", instructor.InstructorAddressLine1);
     comm.Parameters.AddWithValue("AddressLine2", instructor.InstructorAddressLine2 == null ? (object)DBNull.Value : instructor.InstructorAddressLine2); // Check for null
     comm.Parameters.AddWithValue("AddressPostalCode", instructor.InstructorAddressPostalCode);
     comm.Parameters.AddWithValue("AddressRegion", instructor.InstructorAddressRegion);
     comm.Parameters.AddWithValue("AltPhone", instructor.InstructorAltPhone == null ? (object)DBNull.Value : instructor.InstructorAltPhone); // Check for null
     comm.Parameters.AddWithValue("FirstName", instructor.InstructorFirstName);
     comm.Parameters.AddWithValue("HomePhone", instructor.InstructorHomePhone);
     comm.Parameters.AddWithValue("LastName", instructor.InstructorLastName);
 }
コード例 #5
0
ファイル: Instructor.cs プロジェクト: nfearnley/ADD
 public static Instructor ReadInstructor(SqlDataReader reader)
 {
     Instructor instructor = new Instructor();
     instructor.InstructorID = (int)reader["InstructorID"];
     instructor.InstructorAddressCity = (string)reader["InstructorAddressCity"];
     instructor.InstructorAddressCountry = (string)reader["InstructorAddressCountry"];
     instructor.InstructorAddressLine1 = (string)reader["InstructorAddressLine1"];
     instructor.InstructorAddressLine2 = reader["InstructorAddressLine2"] as string; // Allow null
     instructor.InstructorAddressPostalCode = (string)reader["InstructorAddressPostalCode"];
     instructor.InstructorAddressRegion = (string)reader["InstructorAddressRegion"];
     instructor.InstructorAltPhone = reader["InstructorAltPhone"] as string; // Allow null
     instructor.InstructorFirstName = (string)reader["InstructorFirstName"];
     instructor.InstructorHomePhone = (string)reader["InstructorHomePhone"];
     instructor.InstructorLastName = (string)reader["InstructorLastName"];
     return instructor;
 }