Beispiel #1
0
        private void retrieveInvoiceBtn_Click(object sender, EventArgs e)
        {
            //The "Retrieve Entire Invoice" button allows the user to retrieve all Items under the selected Invoice.

            MySqlCommand  cmd       = new MySqlCommand();
            DBQueries     queries   = new DBQueries();
            List <string> itemNames = new List <string>();
            List <int>    itemIDS   = new List <int>();
            int           invNum    = invoiceNum;

            custContList = queries.getCustStorageOrder(connection, customer.getID());

            //Check to ensure that there is an Invoice to retrieve.
            if (custContList.Count <= 0)
            {
                MessageBox.Show("No Invoices to retrieve!");
                return;
            }

            //If there is an Invoice, retrieve all Items from it.
            for (int i = 0; i < custContList.Count; i++)
            {
                queries.retrieveEntireInvoice(connection, custContList[i].getID());
            }

            //Once Items have been retrieved, delete the associated Invoice data from the database.
            queries.deleteInvoice(connection, invNum, customer.getID());

            //Clear the DGV as the Invoice has now been deleted.
            orderView.Rows.Clear();

            //Alert user that all Items have been successfully retrieved.
            MessageBox.Show("All items under Invoice Number: " + invoiceNum + " have been successfully retrieved!");
        }
Beispiel #2
0
        private void mainCustScreen_Load(object sender, EventArgs e)
        {
            //Variables for DB Connection, querying, and passing information between methods.
            greetingLabel.Text = "Hello " + customer.getName() + ", please select an option below:";
            double orderTotal = 0;

            new DBConnect(out connection);
            DBQueries  queries         = new DBQueries();
            List <int> containerIDList = new List <int>();

            if (!isReturningCustomer)
            {
                int invNum;
                //This set of queries inserts a new customer.
                queries.insertNewCustomer(customer, connection);
                customer = queries.getCustomer(connection, customer.getFName(), customer.getLName());

                //Retrieves invoice number for newly created invoice.
                invNum = queries.createInvoice(connection, customer.getID(), contList);

                //Inserts Container objects created on previous Forms into the Database
                queries.insertContainers(connection, contList, customer.getID(), invNum);
                containerIDList = (queries.getContainerID(connection, customer.getID()));

                //Inserts Item objects created on previous Forms into the Database
                queries.insertItems(connection, itemList, containerIDList);
            }
            else //handle returning customer
            {
                /* TO DO */
            }

            //Retrieve the  current customers Storage Orders
            contList = queries.getCustStorageOrder(connection, customer.getID());

            //Calculate the total dollar amount for the Customers Storage Orders
            for (int i = 0; i < contList.Count; i++)
            {
                orderTotal += contList[i].getPrice();
            }

            //Display amount owing.
            curTotalLabel.Text += "$" + orderTotal;

            //Get Invoice Numbers for current Customer
            custInvNums = new List <int>();
            custInvNums = queries.getCustInvoices(connection, customer.getID());

            //Set visual for DataGridView
            mainScreenView.ColumnCount     = 1;
            mainScreenView.Columns[0].Name = "Invoice Number:";

            //Display info to user.
            for (int i = 0; i < custInvNums.Count(); i++)
            {
                mainScreenView.Rows.Add(custInvNums[i].ToString());
            }

            mainScreenView.AutoResizeColumns();
        }
Beispiel #3
0
        private void viewOrderBtn_Click(object sender, EventArgs e)
        {
            //The "View Order" button first checks to enusre that the customer has an Invoice to display. If they do, it
            //queries the database to get all of the Containers associated with the Invoice Number, and then displays
            //the Containers and the Items within them in a new Form to the user.

            new DBConnect(out connection);
            DBQueries        queries       = new DBQueries();
            List <Container> containerList = queries.getCustStorageOrder(connection, customer.getID());

            //If no Invoices, alert user and return to Main Screen.
            if (containerList.Count <= 0)
            {
                MessageBox.Show("No Invoices to show!");
                return;
            }

            int invNum = containerList[0].getInvoiceNumber();

            //Pass all applicable info to the orderViewForm to be displayed to the user.
            orderViewForm orderView = new orderViewForm(containerList, customer, invNum);

            orderView.Show();
            this.Hide();
        }
Beispiel #4
0
        private void retrieveAllOfOneBtn_Click(object sender, EventArgs e)
        {
            //The "Retrieve All of One Item" button retrieves all of a user-selected Item from the Warehouse.

            MySqlCommand cmd     = new MySqlCommand();
            DBQueries    queries = new DBQueries();

            //If an invalid Item Name is selected, alert user and return to orderViewForm.
            if (orderView.SelectedCells[0].Value == null)
            {
                MessageBox.Show("Invalid Item Name selected, please select an Item Name and try again.");
                return;
            }

            string itemName = orderView.SelectedCells[0].Value.ToString();

            //If an invalid Item Name is selected, alert user and return to orderViewForm.
            if (orderView.Columns[orderView.CurrentCell.ColumnIndex].Name == orderView.Columns["Container ID:"].Name || orderView.Columns[orderView.CurrentCell.ColumnIndex].Name == orderView.Columns["Item Quantity:"].Name || itemName == "")
            {
                MessageBox.Show("Invalid Item Name selected, please select an Item Name and try again.");
                return;
            }

            //Get necessary Customer Info from database
            int itemID = queries.getItemID(connection, itemName);
            int contID = queries.getSingleContainerID(connection, itemID);
            int custID = customer.getID();

            //Retrieve all of specified Item from warehouse
            queries.retrieveAllOfOneItem(connection, itemID, custID, contID);


            //Refresh the DGV, displaying the newly updated Invoice with Item removed.
            custContList = queries.getCustStorageOrder(connection, custID);

            orderView.Rows.Clear();

            for (int i = 0; i < custContList.Count(); i++)
            {
                itemList = custContList[i].getItemList();
                orderView.Rows.Add(custContList[i].getID().ToString(), "", "");

                for (int j = 0; j < itemList.Count(); j++)
                {
                    orderView.Rows.Add("", itemList[j].getName(), itemList[j].getQuantity());
                }
            }

            //Alert user that Item has been retrieved successfully.
            MessageBox.Show("Item: " + itemName + " has been successfully retrieved.");
        }
Beispiel #5
0
        private void submitBtn_Click(object sender, EventArgs e)
        {
            if (!fNameText.Text.Equals("") || !lNameText.Text.Equals(""))
            {
                string firstName = fNameText.Text;
                string lastName  = lNameText.Text;

                new DBConnect(out connection);
                DBQueries dbQ = new DBQueries();

                Customer cus = dbQ.getCustomer(connection, firstName, lastName);

                mainCustScreen mainScreen = new mainCustScreen(cus);
                mainScreen.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Error: please fill out the fields with correct information.");
            }
        }
Beispiel #6
0
        private void retrieveXBtn_Click(object sender, EventArgs e)
        {
            //The "Retrieve X Of One Item" button retrieves a specified quantity of a specific Item that the user has selected.

            MySqlCommand cmd     = new MySqlCommand();
            DBQueries    queries = new DBQueries();

            //If an invalid Item Name is selected, alert user and return to orderViewForm.
            if (orderView.SelectedCells[0].Value == null)
            {
                MessageBox.Show("Invalid Item Name selected, please select an Item Name and try again.");
                return;
            }

            string itemName = orderView.SelectedCells[0].Value.ToString();

            //If an invalid Item Name is selected, alert user and return to orderViewForm.
            if (orderView.Columns[orderView.CurrentCell.ColumnIndex].Name == orderView.Columns["Container ID:"].Name || orderView.Columns[orderView.CurrentCell.ColumnIndex].Name == orderView.Columns["Item Quantity:"].Name || itemName == "")
            {
                MessageBox.Show("Invalid Item Name selected, please select an Item Name and try again.");
                return;
            }

            //Get necessary info from database
            int    curItemQuantity = queries.getItemQuantity(connection, itemName);
            int    itemID          = queries.getItemID(connection, itemName);
            string value           = "";
            int    numOfItems;


            //Prompt user to enter the quantity of Items they wish to retrieve.
            if (Dialog.InputBox("Enter the number of Items you would like to retrieve:", "Number of Items:", ref value) == DialogResult.OK)
            {
                numOfItems = int.Parse(value);

                int newQty = curItemQuantity - numOfItems;

                //If the user-entered quantity is larger than that remaining in the warehouse, alert user and return to orderViewForm
                if (newQty < 0)
                {
                    MessageBox.Show("Not enough quantity remaining to retrieve " + numOfItems + " of Item: " + itemName + ", please enter a quantity less than " + curItemQuantity);
                    return;
                }

                //Update quantity in the database.
                queries.retrieveXOfOneItem(connection, newQty, itemID);

                custContList = queries.getCustStorageOrder(connection, customer.getID());

                //Refresh the DGV, displaying the newly updated Invoice with Item quantity updated.
                orderView.Rows.Clear();

                for (int i = 0; i < custContList.Count(); i++)
                {
                    itemList = custContList[i].getItemList();
                    orderView.Rows.Add(custContList[i].getID().ToString(), "", "");

                    for (int j = 0; j < itemList.Count(); j++)
                    {
                        orderView.Rows.Add("", itemList[j].getName(), itemList[j].getQuantity());
                    }
                }

                //Alert the user that the quantity they have requested has been retrieved.
                MessageBox.Show("Quantity: " + numOfItems.ToString() + " of Item: " + itemName + " successfully retrieved.");
            }
        }