Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string tableName = cboTableNames.SelectedValue.ToString();

            if (tableName == "Products")
            {
                frmAddUpdateProducts addProductForm = new frmAddUpdateProducts();
                addProductForm.addProduct = true;
                DialogResult result = addProductForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentProd = addProductForm.product;
                    this.DisplayProductData();
                }
            }
            else if (tableName == "Suppliers")
            {
                frmAddUpdateSuppliers addSupplierForm = new frmAddUpdateSuppliers();
                addSupplierForm.addSupplier = true;
                DialogResult result = addSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentSupplier = addSupplierForm.supplier;
                    this.DisplaySupplierData();
                }
            }
            else if (tableName == "Products_Suppliers")
            {
                frmAddUpdateProductSupplier addProductSupplierForm = new frmAddUpdateProductSupplier();
                addProductSupplierForm.addProductSupplier = true;
                DialogResult result = addProductSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentProductSupplier = addProductSupplierForm.productSupplier;
                    this.DisplayProductSupplierData();
                }
            }
            else if (tableName == "Packages")
            {
                frmAddUpdatePackages addPackageForm = new frmAddUpdatePackages();
                addPackageForm.addPackage = true;
                DialogResult result = addPackageForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentPackage = addPackageForm.package;
                    this.DisplayPackages();
                    this.DisplayProductSupplierData();
                }
            }
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string tableName = cboTableNames.SelectedValue.ToString();

            if (tableName == "Products")
            {
                frmAddUpdateProducts updateProductForm = new frmAddUpdateProducts();
                updateProductForm.addProduct = false;
                updateProductForm.product    = currentProd;
                DialogResult result = updateProductForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentProd = updateProductForm.product;
                    this.DisplayProductData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentProd = ProductsDB.GetProductById(currentProd.ProductId);
                    if (currentProd != null)
                    {
                        this.DisplayProductData();
                    }
                }
            }
            else if (tableName == "Suppliers")
            {
                frmAddUpdateSuppliers updateSupplierForm = new frmAddUpdateSuppliers();
                updateSupplierForm.addSupplier = false;
                updateSupplierForm.supplier    = currentSupplier;
                DialogResult result = updateSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentSupplier = updateSupplierForm.supplier;
                    this.DisplaySupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentSupplier = SuppliersDB.GetSupplierById(currentSupplier.SupplierId);
                    if (currentSupplier != null)
                    {
                        this.DisplaySupplierData();
                    }
                }
            }
            else if (tableName == "Products_Suppliers")
            {
                frmAddUpdateProductSupplier updateProductSupplierForm = new frmAddUpdateProductSupplier();
                updateProductSupplierForm.addProductSupplier = false;
                updateProductSupplierForm.productSupplier    = currentProductSupplier;
                DialogResult result = updateProductSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.DisplayCurrentProductSupplierData();
                    this.DisplayProductSupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(currentProductSupplier.ProductSupplierId);
                    if (currentProductSupplier != null)
                    {
                        this.DisplayCurrentProductSupplierData();
                    }
                    this.DisplayProductSupplierData();
                }
            }
            else if (tableName == "Packages")
            {
                frmAddUpdatePackages updatePackageForm = new frmAddUpdatePackages();
                updatePackageForm.addPackage = false;
                updatePackageForm.package    = currentPackage;
                updatePackageForm.currentProductSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(currentPackage.PackageId);
                DialogResult result = updatePackageForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.DisplayPackages();
                    DisplayCurrentPackageProductSupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentPackage = PackagesDB.GetPackageById(currentPackage.PackageId);
                    if (currentPackage != null)
                    {
                        DisplayCurrentPackageProductSupplierData();
                    }
                    this.DisplayPackages();
                }
            }
        }