示例#1
0
        public void AdminPageTest()
        {
            List <Item> list = new List <Item>();

            pointofsale_application.AdminPage admin = new pointofsale_application.AdminPage("admin");
            admin.PrintSubTotal();
            admin.PrintTax();
            admin.PrintTotal();
            admin.AddItem("Jim Beam");
            admin.RemoveItem("African Children");
            admin.CreateReceipt();
            admin.FillCategoryColumn();
            admin.InitializeBestSellersList();
            admin.InitializeDrinkList("Wine", list);
            admin.InitializeItemList();
        }
示例#2
0
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to cancel the transaction?", "confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (permission.Equals("admin"))
         {
             AdminPage adminpage = new AdminPage(permission);
             adminpage.Show();
             App.Current.MainWindow = adminpage;
             this.Close();
         }
         else if (permission.Equals("basic"))
         {
             HomePage homepage = new HomePage(permission);
             homepage.Show();
             App.Current.MainWindow = homepage;
             this.Close();
         }
     }
 }
示例#3
0
        private void CheckOutButton_Click(object sender, RoutedEventArgs e)
        {
            //Will go through the cart list and for each item in there, it will decrease the quantity of that specific item by 1 in the database.
            for (int i = 0; i < cart.Count; i++)
            {
                int qty = 0;

                SqlCommand categories = new SqlCommand("SELECT QtyOnHand FROM Inventory WHERE SKU = @param1", db.AccessDB());
                categories.Parameters.Add("@param1", SqlDbType.Int).Value = cart[i].SKU;

                SqlDataReader rd;
                rd = categories.ExecuteReader();
                while (rd.Read())
                {
                    qty = rd.GetInt32(rd.GetOrdinal("QtyOnHand"));
                }

                cart[i].NumPurchased += 1;
                SqlCommand createItem = new SqlCommand("UPDATE Inventory SET QtyOnHand = @param2, NumPurchased = @param3 WHERE SKU = @param1", db.AccessDB());
                createItem.Parameters.Add("@param1", SqlDbType.Int).Value = cart[i].SKU;
                createItem.Parameters.Add("@param2", SqlDbType.Int).Value = qty - 1;
                createItem.Parameters.Add("@param3", SqlDbType.Int).Value = cart[i].NumPurchased;

                try
                {
                    createItem.ExecuteNonQuery();
                }
                catch (SqlException y)
                {
                    MessageBox.Show(y.Message.ToString(), "Error Message");
                }
            }
            MessageBoxResult popUp = MessageBox.Show("Transaction Record" + Environment.NewLine + " Change Due: " + ChangeDue.Text, "Check Out");

            //Compares the Cart to Inventory to find duplicates and adds the qty to the duplicates array

            for (int i = 0; i < Inventory.Count; i++)
            {
                int dupCount = 0;

                for (int j = 0; j < cart.Count; j++)
                {
                    if (Inventory[i].SKU == cart[j].SKU && i < cart.Count)
                    {
                        dupCount++;
                        if (duplicates.Contains(Inventory[i].Name + "," + (dupCount - 1)) == true)
                        {
                            duplicates.Remove(Inventory[i].Name + "," + (dupCount - 1));
                            duplicates.Add(Inventory[i].Name + "," + dupCount);
                        }
                        else
                        {
                            duplicates.Add(Inventory[i].Name + "," + dupCount);
                        }
                    }
                }
            }

            SubmitTx();
            SaveTx();

            Reports.tillCount -= Total;
            SqlCommand ttlUpdate = new SqlCommand("UPDATE TillCount SET Till = Till " + "+" + Total, db.AccessDB());

            try
            {
                ttlUpdate.ExecuteNonQuery();
            }
            catch (SqlException y)
            {
                MessageBox.Show(y.Message.ToString(), "Error Message");
            }

            if (permission.Equals("admin"))
            {
                AdminPage adminpage = new AdminPage(permission);
                adminpage.Show();
                App.Current.MainWindow = adminpage;
                this.Close();
            }
            else if (permission.Equals("basic"))
            {
                HomePage homepage = new HomePage(permission);
                homepage.Show();
                App.Current.MainWindow = homepage;
                this.Close();
            }
        }