Example #1
0
        private void infoButton_Click(object sender, EventArgs e)
        {
            if (NoSelectedOrEmptyList())
            {
                int     index = productListBox.SelectedIndex;
                Product p     = (Product)productListBox.Items[index];

                ProductForm prodForm = new ProductForm(p, false);
                prodForm.Enabled();
                prodForm.ShowDialog();
            }
        }
Example #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Product product = new Product();

            var prodForm = new ProductForm(product, true);


            if (prodForm.ShowDialog() == DialogResult.OK)
            {
                productListBox.Items.Add(product);
            }
        }
Example #3
0
        private void editButton_Click(object sender, EventArgs e)
        {
            if (NoSelectedOrEmptyList())
            {
                int index = productListBox.SelectedIndex;

                Product p = productListBox.SelectedItem as Product;

                ProductForm prodForm = new ProductForm(p, false);

                if (prodForm.ShowDialog() == DialogResult.OK)
                {
                    productListBox.Items.RemoveAt(index);
                    productListBox.Items.Insert(index, p);
                    productListBox.SelectedIndex = index;
                }
            }
        }