Esempio n. 1
0
        /// <summary>
        /// Edit the customer information
        /// </summary>
        /// <param name="customer"></param> A collection of customers
        /// <param name="CustomerID"></param> The customer's ID
        /// <param name="changeAddress"></param>  The customer's new addrress
        public void EditCustomer(List <Customer> customer, int CustomerID, string changeAddress)
        {
            /// intiate a xml document
            XmlDocument doc = new XmlDocument();

            /// Change the list of customer's into a array for searching

            Customer[] CustomerInstance = customer.ToArray();

            /// Loop through the customer array

            for (int i = 0; i < CustomerInstance.Length; i++)
            {
                /// Match the Customer ID with the one provided by the user

                if (CustomerID == CustomerInstance[i].ThisCustomerID)
                {
                    /// Change the customer Address to equal the new address
                    CustomerInstance[i].thisCustomerAddress = changeAddress;
                }
            }

            /// returns array back into customer list
            customer = CustomerInstance.ToList();

            // Save the new customer information
            Savexml.CustomerInformaiton(customer, "CustomerList.xml");
        }
Esempio n. 2
0
        ///Method to assign artwork to artist
        public void AssignArtworkToArtist(List <Artist> artistx, List <Artwork> art)
        {
            // set up the lists as arrays so we can search through them
            Artist[]  arrayofArtist  = artistx.ToArray();
            Artwork[] arrayofArtwork = art.ToArray();

            /// Search through the arrays
            for (int i = 0; i < arrayofArtist.Length; i++)
            {
                for (int t = 0; t < arrayofArtwork.Length; t++)
                {
                    /// Matches the artist ID with the Artist ID in the artwork array
                    if (arrayofArtist[i].ArtistID == arrayofArtwork[t].HoldArtistID)
                    {
                        /// Assigns the new artwork to the artist
                        arrayofArtist[i].ArtistArtwork.Add(arrayofArtwork[t]);
                    }
                }
            }
            /// Return artist array back into a list
            artistx = arrayofArtist.ToList();

            // Save the assigned artwork
            Savexml.SaveData(artistx, "ArtistList.xml");
        }
Esempio n. 3
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Savexml x = new Savexml();

                // Loads artist information

                if (File.Exists("ArtistList.xml"))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(List <Artist>));
                    StreamReader  textReader   = new StreamReader("ArtistList.xml");
                    ArtistList = (List <Artist>)deserializer.Deserialize(textReader);
                    textReader.Close();
                }


                /// Creates a artist instance
                var artist = new Artist();
                // Sets variable values
                artist.ThisArtistName   = ArtistName.Text;
                artist.thisArtistAddres = ArtistAddress.Text;

                // Adds the artist instance into artistlist
                ArtistList.Add(artist);
                for (int i = 0; i < ArtistList.Count(); i++)
                {
                    foreach (var artistx in ArtistList)
                    {
                        //set ID
                        if (ArtistList.Count() == 1)
                        {
                            artist.ThisArtistID = ArtistList.Count();
                        }
                        else
                        {
                            artist.ThisArtistID = ArtistList.Count();
                        }
                    }
                }

                /// Save artist Information
                Savexml.SaveData(ArtistList, "ArtistList.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        // method to create a receipt, where the sales person inputes the artworkID and CustomerID
        public void Receipt(int ArtworkID, int CustomerID, DateTime now, string TypeSold)

        {
            var receipt             = new SalesRecord();
            List <SalesRecord> Sale = new List <SalesRecord>();

            receipt.artworkSold = TypeSold;
            receipt.ArtworkID   = ArtworkID;
            receipt.customerID  = CustomerID;

            Sale.Add(receipt);

            //save to a xml file where you can print the receipt
            Savexml.Receipt(Sale, "Receipt.xml");
        }
Esempio n. 5
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");
        }
Esempio n. 6
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");
                }
            }
        }
Esempio n. 7
0
        private void SaveNewCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                /// Loads customer information
                if (File.Exists("CustomerList.xml"))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(List <Customer>));
                    StreamReader  textReader   = new StreamReader("CustomerList.xml");
                    CustomerList = (List <Customer>)deserializer.Deserialize(textReader);
                    textReader.Close();
                }
                // Create a new instance for customer
                var customer = new Customer();
                // Give variables a value
                customer.thisCustomerAddress = CustomerAddressTextbox.Text;
                customer.ThisCustomerName    = CustomerName.Text;
                /// Add new customer to the list
                CustomerList.Add(customer);

                /// Loop through the customer list
                for (int i = 0; i < CustomerList.Count; i++)
                {
                    foreach (var customerr in CustomerList)
                    {
                        /// Sets customer ID
                        if (CustomerList.Count == 1)
                        {
                            customer.ThisCustomerID = CustomerList.Count;
                        }
                        else
                        {
                            customer.ThisCustomerID = CustomerList.Count;
                        }
                        // Saves the new customer
                        Savexml.CustomerInformaiton(CustomerList, "CustomerList.xml");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Make sure all fields are filled");
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Edit the artist's Address /// </summary>
        /// <param name="artist"></param> A collection of artist
        /// <param name="ID"></param>
        /// <param name="changeAddress"></param>
        public void editArtist(List <Artist> artist, int ID, string changeAddress)
        {
            /// Change Artist list into a array for searching
            Artist[] ArtistInstance = artist.ToArray();

            /// Search through the array with a loop
            for (int i = 0; i < ArtistInstance.Length; i++)
            {
                /// Matches the Artist ID with the one provided
                if (ID == ArtistInstance[i].ArtistID)
                {
                    /// Sets the new address
                    ArtistInstance[i].Address = changeAddress;
                }
            }
            /// Return array into artist List
            artist = ArtistInstance.ToList();

            /// Save changes to the artist's Address
            Savexml.SaveData(artist, "ArtistList.xml");
        }
Esempio n. 9
0
        /// <summary>
        /// Change the price of the artwork
        /// </summary>
        /// <param name="artwork"></param> A collection of artwork
        /// <param name="ID"></param> Artwork ID
        /// <param name="newPrice"></param> The new price of the artwork
        public void changeArtworkPrice(List <Artwork> artwork, int ID, decimal newPrice)
        {
            // Changes collection of artwork into a array

            Artwork[] artworks = artwork.ToArray();

            // Loop through the array
            for (int i = 0; i < artworks.Length; i++)
            {
                /// Matches the artwork ID with the ID provided
                if (artworks[i].ThisArtworkID == ID)
                {
                    /// Changes price of the artwork
                    artworks[i].ThisArtworkPrice = newPrice;
                }
            }
            /// Changes array back into a list
            artwork = artworks.ToList();

            Savexml.SaveArtworkData(artworks, "ArtworkList.xml");
        }
Esempio n. 10
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");
        }
Esempio n. 11
0
        private void SaveArtwork(object sender, RoutedEventArgs e)
        {
            try
            {
                /// Load the artwork list
                if (File.Exists("ArtworkList.xml"))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(List <Artwork>));
                    StreamReader  textReader   = new StreamReader("ArtworkList.xml");
                    ArtworkList = (List <Artwork>)deserializer.Deserialize(textReader);
                    textReader.Close();
                }

                /// User input of the artist ID
                int ArtistID = int.Parse(ArtistID1textBOX.Text);

                /// Sends artistlist to array
                Artist[] artistx = ArtistList.ToArray();
                var      array   = artistx;
                var      artwork = new Artwork();


                var artistt = ArtistList.Any(p => p.ThisArtistID == ArtistID);
                artwork.HoldArtistID           = ArtistID;
                artwork.ThisArtworkDescription = DescriptionTextBox.Text;
                artwork.ThisArtworkPrice       = decimal.Parse(PriceTextBox.Text);
                ArtworkList.Add(artwork);
                /// Search through list
                for (int i = 0; i < ArtworkList.Count(); i++)
                {
                    foreach (var Artwork in ArtworkList)
                    {
                        /// sets the ID value
                        if (ArtworkList.Count() == 1)
                        {
                            Artwork.ThisArtworkID = ArtworkList.Count();
                        }
                        else
                        {
                            artwork.ThisArtworkID = ArtworkList.Count() - 1;
                        }
                    }
                }

                /// Save artwork Data
                Savexml.SaveArtworkData(ArtworkList, "ArtworkList.xml");

                ///assign to the artist


                if (File.Exists("ArtistList.xml"))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(List <Artist>));
                    TextReader    textReader   = new StreamReader("ArtistList.xml");
                    ArtistList = (List <Artist>)deserializer.Deserialize(textReader);
                    textReader.Close();
                }


                Artist a = new Artist();
                a.AssignArtworkToArtist(ArtistList, ArtworkList);
            }



            catch (Exception ex)
            {
                MessageBox.Show("Artist ID and price are numbers");
            }
        }