/// <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); }
/// <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); } }
/// <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); } }
/// <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); } }