Ejemplo n.º 1
0
        /// <summary>
        /// Method used to purchase the artwork
        /// </summary>
        /// <param name="Gallery"></param> A list of artworks within the gallery
        /// <param name="ArtworkID"></param> The artwork ID
        /// <param name="customerCollection"></param> A list of customers
        /// <param name="CustomerID"></param> Customer ID
        public void BuyArtwork(List <Artwork> Gallery, int ArtworkID, List <Customer> customerCollection, int CustomerID)
        {
            /// sets the customer list into a array used for searching

            Customer[] customerArray = customerCollection.ToArray();

            /// set the gallery list into a array used for searching

            Artwork[] artworkondisplayarray = Gallery.ToArray();

            /// Intiate a search through the customer array
            for (int i = 0; i < customerArray.Length; i++)
            {
                /// intiate a search through the artwork array
                for (int t = 0; t < artworkondisplayarray.Length; t++)
                {
                    // Matches the artwork ID with the artwork ID provided by the sales person


                    if (artworkondisplayarray[t].ThisArtworkID == ArtworkID)
                    {
                        /// adds the artwork on display into customer purchase records

                        customerArray[i].boughtarwork.Add(artworkondisplayarray[t]);
                        ///returns the customer array back into a list
                        customerCollection = customerArray.ToList();
                        /// removes Artwork from the gallery

                        Gallery.Remove(artworkondisplayarray[t]);
                        string      sold  = "sold Artwork";
                        SalesRecord solds = new SalesRecord();

                        ///create receipt for customer

                        solds.Receipt(artworkondisplayarray[t].ThisArtworkID, customerArray[i].CustomerID, DateTime.Now, sold);
                    }
                }
            }
            //Saves the new display information
            Savexml.SaveDisplayData(Gallery, "ArtworkOnDisplay.xml");

            /// Save the new customer information with their purchases

            Savexml.CustomerInformaiton(customerCollection, "CustomerList.xml");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes the Artwork from the display
        /// </summary>
        /// <param name="id"></param> The artwork ID
        /// <param name="artworkondisplay"></param> A  collection of artworks on display
        public void RemoveArtworkFromDisplay(int id, List <Artwork> artworkondisplay)
        {
            /// Changes artworks on display into a array
            Artwork[] artworks = artworkondisplay.ToArray();

            /// Loop through the array
            for (int i = 0; i < artworks.Length; i++)
            {
                /// Check whether the IDs match
                if (artworks[i].ThisArtworkID == id)
                {
                    /// Removes the artwork from the display
                    artworkondisplay.Remove(artworks[i]);
                    //Saves the new display information
                    Savexml.SaveDisplayData(artworkondisplay, "ArtworkOnDisplay.xml");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a artwork to the gallery
        /// </summary>
        /// <param name="artwork"></param> A collection of artworks
        /// <param name="ID"></param> Artwork ID
        /// <param name="artworkOndisplay"></param> A collection of artworks on display
        public void AddArtworktoDisplay(List <Artwork> artwork, int ID, List <Artwork> artworkOndisplay)
        {
            /// Changes collection of artwork into a array
            Artwork[] artworks = artwork.ToArray();

            // Loop through the array
            for (int i = 0; i < artworks.Length; i++)
            {
                // Maths the ID provided with the artwork ID
                if (artworks[i].ThisArtworkID == ID)
                {
                    /// Sets the time the Artwork is added to the display
                    artwork[i].TimeaddedtoDisplaynow = DateTime.Now;

                    /// Saves the artwork into the collection of artworks
                    artworkOndisplay.Add(artworks[i]);
                }
            }
            // Save the diplay Information
            Savexml.SaveDisplayData(artworkOndisplay, "ArtworkOnDisplay.xml");
        }