コード例 #1
0
        /// <summary>
        /// Removes a product within a package from the database
        /// </summary>
        /// <param name="packageId"></param>
        /// <param name="productSupplierId"></param>
        private void RemoveProductInPackage(int packageId, int productSupplierId)
        {
            ProductExtendedDB.DeletePackageProductsById(packageId, productSupplierId);


            GetBindedPackageProducts(PackageSelected.PackageId);
        }
コード例 #2
0
        /// <summary>
        /// Displays products associated with a package
        /// </summary>
        /// <param name="packageID"></param>
        private void GetBindedPackageProducts(int packageID)
        {
            //clear any existing products attached to the package
            if (!Object.Equals(PackageProducts, null))
            {
                PackageProducts.Clear();
            }

            //get the products linked to the package
            foreach (ProductExtended product in ProductExtendedDB.GetPackageProductsById(packageID))
            {
                PackageProducts.Add(product);
            }
        }
コード例 #3
0
        /// <summary>
        /// removes the selected datagrid product from the database
        /// </summary>
        private void RemoveProduct()
        {
            //nothing selected, return.
            if (dtgProducts.SelectedRows.Count == 0)
            {
                return;
            }

            ProductExtended product = (ProductExtended)dtgProducts.CurrentRow.DataBoundItem;

            try
            {
                ProductExtendedDB.DeletePackageProductsById(PackageSelected.PackageId, product.ProductSupplierId);
                GetBindedPackageProducts(PackageSelected.PackageId);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Unable to delete product", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        /// <summary>
        /// Displays products associated with a package
        /// </summary>
        /// <param name="packageID"></param>
        private void GetBindedPackageProducts(int packageID)
        {
            //clear any existing products attached to the package
            if (!Object.Equals(PackageProducts, null))
            {
                PackageProducts.Clear();
            }

            try
            {
                //get the products linked to the package
                foreach (ProductExtended product in ProductExtendedDB.GetPackageProductsById(packageID))
                {
                    PackageProducts.Add(product);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Unable to get package products", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }