Exemplo n.º 1
0
        private void btnLock_Click(object sender, EventArgs e)
        {
            //locks register and clears any user entry
            if (btnLock.Text == "Lock")
            {
                LockForm();
                txtInput.Clear();
                TxtCashOut.Clear();
                label12.Text     = "Lock";
                txtInput.Enabled = false;

                return;
            }

            //enables the form to be ulocked
            if (btnLock.Text == "Unlock")
            {
                groupBoxLock.Visible   = false;
                groupBoxUnlock.Visible = true;
                groupBoxUnlock.BringToFront();
                BtnLogOff.Visible = false;
                label12.Text      = "Unlock";
                TxtUnlock.Focus();
            }
        }
Exemplo n.º 2
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            //Clears everything back into the default view
            if (BtnCash.Visible == true || TxtCashOut.Visible == true)
            {
                BtnCash.Visible = false;
                BtnEFT.Visible  = false;

                TxtCashOut.Visible = false;
                TxtCashOut.Clear();
                TxtUnlock.Clear();
                txtInput.Focus();

                BtnCoupon.Visible      = true;
                btnLock.Visible        = true;
                btnVoid.Visible        = true;
                btnRegOptions.Visible  = true;
                btnTender.Visible      = true;
                BtnPay.Visible         = false;
                BtnEnterCoupon.Visible = false;

                groupBoxTenderTotal.Visible = false;
            }
            //clear user entry
            txtInput.Clear();
            qty            = 1;
            lblQty.Visible = false;
        }
Exemplo n.º 3
0
        private void BtnLogOff_Click(object sender, EventArgs e)
        {
            //allows the user to log out of their current session as long as there are is not a transaction in progress
            if (listViewGrocery.Items.Count < 1)
            {
                groupBoxUnlock.Visible = true;
                groupBoxUnlock.BringToFront();
                groupBoxLock.Visible = false;

                //groupBoxPad.Enabled = true;
                label12.Text = "Log Off";
                TxtUnlock.Focus();
                txtInput.Enabled = false;
            }
            else
            {
                MessageBox.Show("Transaction in Progress!" + Environment.NewLine + "Unable to Log Out");
            }
        }
Exemplo n.º 4
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            //There are multiple uses for this button, all set to different conditions

            try
            {
                //This code will validate the password input field
                //if the password matches, the form is unlocked, if not, it resets
                if (groupBoxUnlock.Visible == true)
                {
                    if (TxtUnlock.Text == Global.Password)
                    {
                        //If the Unlock groupbox text is set to "Log Off", it will close the current form and launch
                        //the initial LogIn Form
                        if (label12.Text == "Log Off")
                        {
                            this.Hide();
                            LogIn logIn = new LogIn();
                            logIn.FormClosed += (s, args) => this.Close();
                            logIn.Show();
                            return;
                        }

                        //Unlocks the form and enables all the necessary fields
                        groupBoxLock.Visible   = false;
                        groupBoxUnlock.Visible = false;

                        BtnCoupon.Enabled = true;
                        btnVoid.Enabled   = true;
                        btnTender.Enabled = true;
                        btnQty.Enabled    = true;

                        TxtUnlock.Clear();
                        btnLock.Text     = "Lock";
                        txtInput.Enabled = true;
                        txtInput.Focus();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Incorrect Password!");
                        TxtUnlock.Clear();
                    }

                    return;
                }

                //calls the BtnPay click event
                if (TxtCashOut.Visible == true)
                {
                    BtnPay_Click(sender, e);
                    return;
                }


                //Establish Connection
                DataAccess db = new DataAccess();

                //Gets the appropriate grocery based on the look up entry from the input textbox
                Grocery grocery = db.GetGrocery(Convert.ToInt16(txtInput.Text));

                //Add first item
                if (grocery.Name != null) //will not run if the user types in an invalid lookup number
                {
                    txtInput.Clear();
                    lblQty.Visible = false;
                    label1.Text    = "Total:";

                    //set up an array for the ListView
                    string[]     arr = new string[5];
                    ListViewItem itm;
                    decimal      result;

                    //TRY Parse the boolean data for validation
                    bool.TryParse(grocery.Identification18.ToString(), out bool id18);
                    bool.TryParse(grocery.Identification21.ToString(), out bool id21);

                    if (id18 == true && id21 == true)
                    {
                        DialogResult dialogResult21 = MessageBox.Show("Is the customer 21 years or older?", "Please Ask For ID", MessageBoxButtons.YesNo);
                        if (dialogResult21 == DialogResult.Yes)
                        {
                            //will resume as normal if the customer is 21 years or older
                        }
                        else if (dialogResult21 == DialogResult.No)
                        {
                            return; //End execution
                        }
                    }
                    else if (id18 == true && id21 == false)
                    {
                        DialogResult dialogResult18 = MessageBox.Show("Is the customer 18 years or older?", "Please Ask For ID", MessageBoxButtons.YesNo);
                        if (dialogResult18 == DialogResult.Yes)
                        {
                            //will resume as normal if the customer is 18 years or older
                        }
                        else if (dialogResult18 == DialogResult.No)
                        {
                            return; //End execution
                        }
                    }

                    //assign the data to the appropriate fileds
                    arr[0] = grocery.Name;
                    arr[1] = grocery.Price.ToString();
                    arr[2] = qty.ToString();

                    //TRY Parse the boolean data for validation
                    bool.TryParse(grocery.Taxable.ToString(), out bool taxable);

                    //Parse Price into a decimal
                    decimal.TryParse(grocery.Price.ToString(), out decimal price);

                    // if taxable, will calculate the price of the item, quantity, and the tax constant
                    if (taxable == true)
                    {
                        arr[4] = "Y";
                        tax    = (price * qty * _tax);
                        decimal.Round(tax, 2, MidpointRounding.AwayFromZero);
                        result = ((price * qty) + tax);
                    }
                    else
                    {
                        arr[4] = "N";
                        result = (price * qty);
                    }

                    arr[3] = result.ToString("#.##");

                    //add items inside arr array into the ListView
                    itm = new ListViewItem(arr);
                    listViewGrocery.Items.Add(itm);
                }
                else
                {
                    MessageBox.Show("Invalid Input!");
                    txtInput.Clear();
                    return;
                }

                //Reset total
                TotalCount();

                //Reset quantity
                qty = 1;

                btnBack_Click(sender, e);
            }
            catch
            {
                MessageBox.Show("Invalid Input!");
                txtInput.Clear();
            }
        }