Esempio n. 1
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();
        }
Esempio n. 2
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.");
            }
        }