Ejemplo n.º 1
0
        //Button add new Product.
        private void buttonAddProduct_Click(object sender, EventArgs e)
        {
            //Make new Product Object.
            Product addProduct = new Product();

            //Make new ProductAddOrEditForm object and pass a new Product object to the form.
            ProductAddOrEditForm ProductAddOrEditForm = new ProductAddOrEditForm(addProduct);

            ProductAddOrEditForm.FormClosed += Form1_Load;
            ProductAddOrEditForm.Show();
        }
Ejemplo n.º 2
0
        //Button edit Product
        private void buttonEditProduct_Click(object sender, EventArgs e)
        {
            if (comboBoxMainEditProduct.SelectedItem != null)
            {
                //Find selected Product and add it to the Product Object.
                Product addProduct = Program.db.Products.Find(comboBoxMainEditProduct.SelectedValue);

                //Make new ProductAddOrEditForm object and pass the selected Product object to the form.
                ProductAddOrEditForm ProductAddOrEditForm = new ProductAddOrEditForm(addProduct);
                ProductAddOrEditForm.FormClosed += Form1_Load;
                ProductAddOrEditForm.Show();
            }

            //Clears datasource.
            comboBoxMainEditProduct.DataSource = null;

            //Rerun method Dictionary to refresh comboboxes and listview.
            Dictionary();
        }