示例#1
0
        private void listBox_Clients_DoubleClick(object sender, EventArgs e)
        {
            ProductToForm(listBox_product.SelectedItem as Product);

            CategoryProductArr categoryProductArrChoosed = new CategoryProductArr();

            ProductDetailsArr productDetailsArr = new ProductDetailsArr();

            productDetailsArr.Fill();

            productDetailsArr = productDetailsArr.Filter((listBox_product.SelectedItem as Product));

            categoryProductArrChoosed = productDetailsArr.GetCategoryProductArr();
            CategoryProductArrToForm(categoryProductArrChoosed, listBox_category_choosed);

            CategoryProductArr categoryProductArrNotChoosed = new CategoryProductArr();

            categoryProductArrNotChoosed.Fill();

            categoryProductArrNotChoosed.Remove(categoryProductArrChoosed);
            CategoryProductArrToForm(categoryProductArrNotChoosed, listBox_category_potential);
        }
示例#2
0
        private void Save(object sender, EventArgs e)
        {
            if (!CheckGood())
            {
                MessageBox.Show("You didn't write right", "TRY AGAIN", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                All_White();
            }
            else
            {
                Product           product = FormToProduct();
                ProductDetailsArr productDetailsArr_new;
                ProductDetailsArr productDetailsArr_old = new ProductDetailsArr();

                ProductArr productArr_new = new ProductArr();
                productArr_new.Fill();

                if (product.ID == 0)
                {
                    if (product.Insert())
                    {
                        ProductArr productArr = new ProductArr();
                        productArr.Fill();
                        product = productArr.GetProductWithMaxId();
                        productDetailsArr_new = FormToProductDetailsArr(product);
                        productDetailsArr_new.Insert();

                        CategoryProductArr categoryProductArr = productDetailsArr_new.GetCategoryProductArr();
                        categoryProductArr.Update();

                        MessageBox.Show("Products Details Saved");
                        CleanForm();
                        ProductArrToForm();
                        CategoryProductArrToForm();
                    }
                    else
                    {
                        MessageBox.Show("Cannot Save Products Details");
                    }
                }
                else
                {
                    if (product.Update())
                    {
                        productDetailsArr_new = FormToProductDetailsArr(product);
                        productDetailsArr_old.Fill();
                        productDetailsArr_old = productDetailsArr_old.Filter(product);

                        productDetailsArr_old.Delete();
                        productDetailsArr_new.Insert();

                        //(listBox_category_choosed.DataSource as CategoryProductArr).Update();
                        //(listBox_category_potential.DataSource as CategoryProductArr).Update();

                        MessageBox.Show("Products Details UPDATED");
                        CleanForm();
                        ProductArrToForm();
                    }
                    else
                    {
                        MessageBox.Show("Cannot UPDATE Products Details");
                    }
                }
            }
        }