private void LstViewTravelPackages_SelectedIndexChanged(object sender, EventArgs e) { TravelPackageDB packageDetails = new TravelPackageDB(); packageDetails.ShowSelectedOrder(lstViewTravelPackages, lblPackageID, lblPackageName, lblStartDate, lblEndDate, lblDescription, lblBasePrice, lblCommission); ShowLabels(); btnEditPackage.Enabled = true; btnDeletePackage.Enabled = true; int packageId = Convert.ToInt32(lblPackageID.Text); List <Package> packageProducts = TravelPackageDB.GetPackageProducts(lstProducts, packageId); }
// lists all products in package and available products not yet added public AddProductForm(int packageId, string packageName) { InitializeComponent(); lblPackageName.Text = packageName; lblPackageId.Text = Convert.ToString(packageId); if (lstProducts.Items != null) { List <Package> packageProducts = TravelPackageDB.GetPackageProducts(lstProducts, packageId); List <Package> showProducts = TravelPackageDB.ShowAllProducts(lstAllProducts, packageId); } }
// remove product from package private void BtnRemoveProduct_Click(object sender, EventArgs e) { if (lstProducts.SelectedItem == null) { MessageBox.Show("A product must be selected to remove"); } else { int packageId = Convert.ToInt32(lblPackageId.Text); int productId = Convert.ToInt32(lblProductId.Text); TravelPackageDB removeProduct = new TravelPackageDB(); removeProduct.RemovePackageProduct(productId, packageId); List <Package> refreshProducts = TravelPackageDB.GetPackageProducts(lstProducts, packageId); List <Package> showProducts = TravelPackageDB.ShowAllProducts(lstAllProducts, packageId); } }
// add product to package private void BtnAdd_Click(object sender, EventArgs e) { if (lstAllProducts.SelectedItem == null) { MessageBox.Show("A product must be selected to add"); } else { int packageId = Convert.ToInt32(lblPackageId.Text); int productId = Convert.ToInt32(lblListNewProd.Text); TravelPackageDB getProdSupplierId = new TravelPackageDB(); int supplierId = getProdSupplierId.GetSupplierId(productId); getProdSupplierId.AddPackageToProd(Convert.ToInt32(lblPackageId.Text), supplierId); List <Package> refreshProducts = TravelPackageDB.GetPackageProducts(lstProducts, packageId); List <Package> showProducts = TravelPackageDB.ShowAllProducts(lstAllProducts, packageId); } }