Пример #1
0
        private void CancelButton_Click(object sender, EventArgs e)
        {
            //Code which changes visisbilty of Form.
            QuantityValuesTextBox.Focus();
            QuantityValuesTextBox.SelectAll();
            AddToCartButton.Focus();
            DataGridViewPanel.Visible = false;
            DataGridCart.Rows.Clear();
            TotalCostValueTextBox.Clear();

            // Local variable declaraion.
            int BeerNameIndexSelected = int.Parse(BeerNamesListBox.SelectedIndex.ToString());
            int BeerSizeIndexSelected = int.Parse(BeerSubTypeListBox.SelectedIndex.ToString());
            int QuantityEntered       = int.Parse(QuantityValuesTextBox.Text);

            //Decison construct to check quantity is more than 0.
            if (QuantityEntered > 0)
            {
                //code to reduce the stock added while confirming.
                TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] = TempStockArray[BeerNameIndexSelected, BeerSizeIndexSelected] + QuantityEntered;
                FinalValue = 0;
                DataGridCart.Rows.Clear();
                QuantityValuesTextBox.Clear();
            }
            //decison construct to check qunatity is less than 0.
            else if (QuantityEntered <= 0)
            {
                MessageBox.Show("Please input qunatity correctly", "Input quantity box", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void ClearButton_Click(object sender, EventArgs e)
        {
            // code which clears the selected value and changes visisbility of form.
            QuantityValuesTextBox.Focus();
            QuantityValuesTextBox.SelectAll();
            ButtonPanelOne.Visible    = true;
            CancelButton.Visible      = true;
            DataGridViewPanel.Visible = false;
            DataGridCart.ClearSelection();
            DataGridCart.Rows.Clear();
            TotalCostValueTextBox.Text = "0";
            FinalValue = 0;
            QuantityValuesTextBox.Clear();
            ExitButton.Focus();
            BeerNamesListBox.SelectedItems.Clear();
            BeerSubTypeListBox.SelectedItems.Clear();
            PriceForBeerListBox.SelectedItems.Clear();
            DataGridCart.Visible          = false;
            TotalCostValueTextBox.Visible = false;
            TotalcostLabel.Visible        = false;

            DataGridCart.ClearSelection();
            DataGridCart.Rows.Clear();
        }