Beispiel #1
0
        private void productsWithSuppliersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Create a list of open forms and bool result
            List <Form> openForms = new List <Form>();
            bool        formIsNew = true;

            // Fill up a list of forms
            foreach (Form f in Application.OpenForms)
            {
                openForms.Add(f);
            }

            // Check if there is a the same form that user tries to open
            foreach (Form f in openForms)
            {
                if (f.Name == "ProductsWithSuppliers")
                {
                    f.Focus();
                    formIsNew = false;
                }
            }

            // If form is not opened yet open a new one
            if (formIsNew == true)
            {
                ProductsWithSuppliers supplierForm = new ProductsWithSuppliers();
                supplierForm.MdiParent = this;
                supplierForm.Show();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int success = 0;

            if (ProductBox.Text == " ")
            {
                MessageBox.Show("Please Select a Product");
            }
            else if (SuppliersBox.Text == " ")
            {
                MessageBox.Show("Please select a Supplier");
            }
            else
            {
                product  = ProductBox.Text;
                supplier = SuppliersBox.Text;
            }

            success = SuppliersFunctions.AddSuppliers(Convert.ToInt32(ProductBox.SelectedValue), Convert.ToInt32(SuppliersBox.SelectedValue));

            if (success == 1)
            {
                MessageBox.Show("Data inserted Correctly");

                ProductsWithSuppliers form = new ProductsWithSuppliers();
                form.MdiParent = this.MdiParent;
                form.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Data was not inserted. It already exists");
            }

            this.Close();
        }