Beispiel #1
0
 //Form State Update Methods
 public bool updateViewItemState(viewItemState state)
 {
     if (state == viewItemState.Buy)
     {
         uiBuyItemButton.Show();
         return(true);
     }
     else if (state == viewItemState.Restock)
     {
         uiRestockItemButton.Show();
         return(true);
     }
     else if (state == viewItemState.View)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public viewNutrition(int productID, Branch currentBranch, viewItemState state)
        {
            InitializeComponent();

            if (!base.updateViewItemState(state) || !(currentBranch.findProduct(productID) is Nutrition))
            {
                Console.WriteLine("Form: New View Item. Error: Form not implemented.");
                MessageBox.Show("Form Aborting. Called improperly.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Abort;
                this.Close();
            }
            else
            {
                product = (Nutrition)currentBranch.findProduct(productID);
                base.updateProductAvailability(product.availableForSale);
                base.updateSupplierName(currentBranch.findProductSupplier(productID).Name() ?? "Not Found");
                base.updateProductID(productID.ToString() ?? "Not Found");
                base.updateProductName(product.Name ?? "Not Found");
                base.updateProductCost(product.Cost.ToString("C2") ?? "Not Found");
                base.updateProductStockLevel(product.StockLevel.ToString() ?? "Not Found");
                base.updateProductRestockLevel(product.RestockLevel.ToString() ?? "Not Found");
                this.updateSpecificAttributes(product);
            }
        }