예제 #1
0
 //ToDo: save exhibit info to the database
 public void Update(Exhibit exhibit)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         connection.Open();
         SqlCommand cmd = new SqlCommand(
             " UPDATE Exhibit " +
             " SET Title = @title, [Description] = @description, FeaturedImg = @featuredImg, ThumbnailImg = @thumbnailImg, " +
             " ExhibitStartDate = @exhibitStartDate, ExhibitStartTime = @exhibitStartTime, ExhibitEndDate = @exhibitEndDate, ExhibitEndTime = @exhibitEndTime, " +
             " RegistrationStartDate = @registrationStartDate, RegistrationStartTime = @registrationStartTime, RegistrationEndDate = @registrationEndDate, RegistrationEndTime = @registrationEndTime, " +
             " ReceptionDate = @receptionDate, ReceptionStartTime = @receptionStartTime, ReceptionEndTime = @receptionEndTime, " +
             " AdditionalComments = @additionalComments " +
             " WHERE ExhibitID = @exhibitID",
             connection);
         cmd.Parameters.AddWithValue("@exhibitID", exhibit.getId());
         cmd.Parameters.AddWithValue("@title", exhibit.getTitle());
         cmd.Parameters.AddWithValue("@description", exhibit.getDescription());
         cmd.Parameters.AddWithValue("@featuredImg", exhibit.getFeaturedImg());
         cmd.Parameters.AddWithValue("@thumbnailImg", exhibit.getThumbnailImg());
         cmd.Parameters.AddWithValue("@exhibitStartDate", exhibit.getExhibitStartDate());
         cmd.Parameters.AddWithValue("@exhibitStartTime", exhibit.getExhibitStartTime());
         cmd.Parameters.AddWithValue("@exhibitEndDate", exhibit.getExhibitEndDate());
         cmd.Parameters.AddWithValue("@exhibitEndTime", exhibit.getExhibitEndTime());
         cmd.Parameters.AddWithValue("@registrationStartDate", exhibit.getRegistrationStartDate());
         cmd.Parameters.AddWithValue("@registrationStartTime", exhibit.getRegistrationStartTime());
         cmd.Parameters.AddWithValue("@registrationEndDate", exhibit.getRegistrationEndDate());
         cmd.Parameters.AddWithValue("@registrationEndTime", exhibit.getExhibitEndTime());
         cmd.Parameters.AddWithValue("@receptionDate", exhibit.getReceptionDate());
         cmd.Parameters.AddWithValue("@receptionStartTime", exhibit.getReceptionStartTime());
         cmd.Parameters.AddWithValue("@receptionEndTime", exhibit.getReceptionEndTime());
         cmd.Parameters.AddWithValue("@additionalComments", exhibit.getAdditionalComments());
         cmd.ExecuteNonQuery();
         connection.Close();
     }
 }
예제 #2
0
        //function to store a new exhibit in the database
        public void Insert(Exhibit exhibit)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand(
                    "INSERT INTO Exhibit" +
                    "(Title, [Description], FeaturedImg, ThumbnailImg," +
                    "ExhibitStartDate, ExhibitStartTime, ExhibitEndDate, ExhibitEndTime," +
                    "RegistrationStartDate, RegistrationStartTime, RegistrationEndDate, RegistrationEndTime," +
                    "ReceptionDate, ReceptionStartTime, ReceptionEndTime, AdditionalComments) " +
                    "VALUES(@title, @description, @featuredImg, @thumbnailImg," +
                    "@exhibitStartDate, @exhibitStartTime, @exhibitEndDate, @exhibitEndTime," +
                    "@registrationStartDate, @registrationStartTime, @registrationEndDate, @registrationEndTime," +
                    "@receptionDate, @receptionStartTime, @receptionEndTime, @additionalComments)",
                    connection);

                cmd.Parameters.AddWithValue("@title", exhibit.getTitle());
                cmd.Parameters.AddWithValue("@description", exhibit.getDescription());
                cmd.Parameters.AddWithValue("@featuredImg", exhibit.getFeaturedImg());
                cmd.Parameters.AddWithValue("@thumbnailImg", exhibit.getThumbnailImg());

                cmd.Parameters.AddWithValue("@exhibitStartDate", exhibit.getExhibitStartDate());
                cmd.Parameters.AddWithValue("@exhibitStartTime", exhibit.getExhibitStartTime());
                cmd.Parameters.AddWithValue("@exhibitEndDate", exhibit.getExhibitEndDate());
                cmd.Parameters.AddWithValue("@exhibitEndTime", exhibit.getExhibitEndTime());

                cmd.Parameters.AddWithValue("@registrationStartDate", exhibit.getRegistrationStartDate());
                cmd.Parameters.AddWithValue("@registrationStartTime", exhibit.getRegistrationStartTime());
                cmd.Parameters.AddWithValue("@registrationEndDate", exhibit.getRegistrationEndDate());
                cmd.Parameters.AddWithValue("@registrationEndTime", exhibit.getExhibitEndTime());

                cmd.Parameters.AddWithValue("@receptionDate", exhibit.getReceptionDate());
                cmd.Parameters.AddWithValue("@receptionStartTime", exhibit.getReceptionStartTime());
                cmd.Parameters.AddWithValue("@receptionEndTime", exhibit.getReceptionEndTime());

                cmd.Parameters.AddWithValue("@additionalComments", exhibit.getAdditionalComments());

                cmd.ExecuteNonQuery();
            }
        }