private void loginButton_click(object sender, EventArgs e)
        {
            try{
                // Check for empty username or password
                if(usernameTextbox.Text == "" || passwordTextbox.Text == ""){
                    throw new Exception("You must enter a username and password.");
                }

                // Query the kddb database to check if the username/password combination are valid.
                string queryString = string.Format("SELECT * FROM skrohn_kddb.login WHERE username=\"{0}\" AND pw=\"{1}\"", usernameTextbox.Text, passwordTextbox.Text);
                DataTable dt = DatabaseAccess.selectDB(queryString);

                // Check if the query returned any rows with the specified username and password.
                if(dt.Rows.Count > 0){
                    // Valid username and password
                    MyMessageBox box = new MyMessageBox("Login successful.");
                    box.StartPosition = FormStartPosition.CenterParent;
                    box.ShowDialog();
                    this.Visible = false;
                    EmployeeScreen employeeGUI = new EmployeeScreen(this);
                    employeeGUI.StartPosition = FormStartPosition.CenterParent;
                    employeeGUI.ShowDialog();
                }
                else{
                    MyMessageBox box = new MyMessageBox("Invalid login information.");
                    box.StartPosition = FormStartPosition.CenterParent;
                    box.ShowDialog();
                }
            }
            catch(Exception ex){
                MyMessageBox box = new MyMessageBox(ex.Message);
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
            }
        }
        // Add the order to the database of completed orders, then clear the shopping cart.
        public void checkout()
        {
            if(cart.itemCount() > 0){
                string orderData = "";
                // Check for multiples of the same item to add to orderData string.
                for(int i = 0; i < cart.itemCount(); i++){
                    for(int count = 0; count < cart.getItem(i).itemTwo;  count++){
                        orderData += cart.getItem(i).itemOne.toDataString();
                    }
                }

                // Create the MySql query using the orderData string.
                string queryString = string.Format("INSERT INTO skrohn_kddb.orders (orderdata) VALUES (\"{0}\")", orderData);
                // Submit the query to the database, clear the cart if successful. Display success message.
                if(DatabaseAccess.insertDB(queryString)){
                    cart.emptyCart();
                    MyMessageBox box = new MyMessageBox("Order successfully submitted.");
                    box.StartPosition = FormStartPosition.CenterParent;
                    box.ShowDialog();
                }
            }
            else{
                MyMessageBox box = new MyMessageBox("Your cart is empty.");
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
            }
        }
 private void logoutButton_Click(object sender, EventArgs e)
 {
     this.Close();
     MyMessageBox box = new MyMessageBox("You're now logged out.");
     box.StartPosition = FormStartPosition.CenterParent;
     box.ShowDialog();
     previousForm.Visible = true;
 }
        // Validate username/password, check for existing username, then add new user to database if valid.
        private void createAccountButton_Click(object sender, EventArgs e)
        {
            try{
                // Validate username and password format.
                if(!validUsername(usernameTextbox.Text)){
                    throw new Exception("Invalid username.\nUsername must be alphanumeric.");
                }
                else if(!validPassword(passwordTextbox.Text)){
                    throw new Exception("Invalid password.\nPassword must be at least 6 characters long and contain at least 1 number.");
                }

                // Check if the username already exists in the database.
                string queryString = string.Format("Select * FROM skrohn_kddb.login WHERE username=\"{0}\"", usernameTextbox.Text);
                DataTable dt = DatabaseAccess.selectDB(queryString);
                if(dt.Rows.Count > 0){
                    // If the username exists, throw exception.
                    throw new Exception("Username already exists, please select a new username.");
                }
                else{
                    // If the username didn't exist, add it to the database.
                    string insertString = string.Format("INSERT INTO skrohn_kddb.login (username, pw) VALUES (\"{0}\", \"{1}\")", usernameTextbox.Text, passwordTextbox.Text);
                    DatabaseAccess.insertDB(insertString);
                }

                // Display message if registration was successful.
                MyMessageBox box = new MyMessageBox("Registration successful. Please login with your username and password.");
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
                this.Close();
                previousForm.Visible = true;
            }
            catch(Exception ex){
                MyMessageBox box = new MyMessageBox(ex.Message);
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
            }
        }
        private void addToCartButton_Click(object sender, EventArgs e)
        {
            try{
                if(tabContol.SelectedTab == chalkboardTab){
                    ShoppingCart.Chalkboard board = getChalkboardOrder();
                    for(int i = 0; i < chalkboard_countNumeric.Value; i++){
                        cart.addItem(board);
                    }
                    clearAllChalkboardFields();
                }
                else if(tabContol.SelectedTab == sconceTab){
                    ShoppingCart.Sconce sconce = getSconceOrder();
                    for(int i = 0; i < sconce_countNumeric.Value; i++){
                        cart.addItem(sconce);
                    }
                    clearAllSconceFields();
                }
                else if(tabContol.SelectedTab == boxTab){
                    ShoppingCart.Box weddingBox = getBoxOrder();
                    for(int i = 0; i < box_countNumeric.Value; i++){
                        cart.addItem(weddingBox);
                    }
                    clearAllBoxFields();
                }
                else if(tabContol.SelectedTab == organizerTab){

                }
                else if(tabContol.SelectedTab == masonSconceTab){

                }
                else{
                    throw new Exception("You must select a type of item to add to the cart");
                }
                MyMessageBox box = new MyMessageBox("Item added to cart");
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
            }
            catch(Exception ex){
                MyMessageBox box = new MyMessageBox(ex.Message);
                box.StartPosition = FormStartPosition.CenterParent;
                box.ShowDialog();
            }
        }
 // Pricing for the standard sizes are stored in the database. This fuctions gets those prices based on the size.
 private Pair<double, double> getPricing(double length, double width, ShoppingCart.Chalkboard.Magnetic_Type mag)
 {
     try{
         bool isMagnetic = (mag == ShoppingCart.Chalkboard.Magnetic_Type.Magnetic) ? true:false;
         string queryString = string.Format("SELECT * FROM skrohn_kddb.pricing_chalkboard WHERE length=\"{0}\" AND width=\"{1}\" AND magnetic={2}", length, width, isMagnetic);
         DataTable data = DatabaseAccess.selectDB(queryString);
         return new Pair<double,double>(Convert.ToDouble(data.Rows[0][4]), Convert.ToDouble(data.Rows[0][5]));
     }
     catch(Exception ex){
         MyMessageBox box = new MyMessageBox(ex.Message);
         box.StartPosition = FormStartPosition.CenterParent;
         box.ShowDialog();
     }
     throw new Exception("Unable to locate pricing data.");
 }