Пример #1
0
        public static void InsertTrainingRequest(TrainingRequest TrainingRequest)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                SqlCommand insertCommand = new SqlCommand("INSERT INTO TrainingRequests (TrainingID, UserID, Status) VALUES (@TrainingID, @UserID, 0)", connection);

                insertCommand.Parameters.AddWithValue("@UserID", TrainingRequest.UserID);
                insertCommand.Parameters.AddWithValue("@TrainingID", TrainingRequest.TrainingID);

                connection.Open();
                insertCommand.ExecuteNonQuery();
            }
        }
Пример #2
0
        public static void UpdateTrainingRequest(TrainingRequest TrainingRequest)
        {
            using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                SqlCommand updateCommand = new SqlCommand("UPDATE [TrainingRequests] SET [TrainingID] = @TrainingID, [UserID] = @UserID, Status = @Status WHERE [ID] = @ID", connection);

                updateCommand.Parameters.AddWithValue("@UserID", TrainingRequest.UserID);
                updateCommand.Parameters.AddWithValue("@TrainingID", TrainingRequest.TrainingID);
                updateCommand.Parameters.AddWithValue("@Status", TrainingRequest.Status);

                updateCommand.Parameters.AddWithValue("@ID", TrainingRequest.ID);

                connection.Open();
                updateCommand.ExecuteNonQuery();
            }
        }