Exemple #1
0
        private void UpdateQuantities()
        {
            foreach (Animal a in Parent.Cart)
            {
                foreach (Animal animal in AnimalCollection)
                {
                    if (a.PetID == animal.PetID)
                    {
                        animal.Quantity = (int.Parse(animal.Quantity) - int.Parse(a.PurchasedAmount)).ToString();
                        PostgreSQL.editPet(animal);
                    }
                }

                foreach (Account acc in AccountList)
                {
                    if (acc.id == LoggedInShopper.id)
                    {
                        foreach (Animal o in LoggedInShopper.CartContent.ToList())
                        {
                            if (o.PetID == a.PetID)
                            {
                                //LoggedInShopper.PreviousPurchases.Add(o);
                                LoggedInShopper.CartContent.Remove(o);
                            }
                        }
                        LoggedInShopper.CartTotal = "0";
                        LoggedInShopper.CartItems = "0";
                    }
                }
            }
        }
Exemple #2
0
        private void SavePetToDatabase(object sender, RoutedEventArgs e)
        {
            petType     = PetTypeEntry.Text;
            petSize     = PetSizeEntry.Text;
            petAge      = PetAgeEntry.Text;
            petQuantity = PetQuantityEntry.Text;
            petPrice    = PetPriceEntry.Text;
            petZip      = PetZipEntry.Text;

            if (CheckEntries())
            {
                MessageBox.Show("Updating database...");
                Animal a = new Animal(petID, LoggedInSeller.id, petType, petAge, petSize, petQuantity, petPrice, petZip);
                PostgreSQL.editPet(a);
                PostgreSQL.editSeller(LoggedInSeller, a);
                SellerHome sh = new SellerHome(LoggedInSeller);
                sh.Show();
                this.Close();
            }
        }