예제 #1
0
        public static bool RemoveItemFromInventory(Item item)
        {
            bool result = items.Remove(item);

            InvoFileTools.SaveCurrentFile();
            return(result);
        }
예제 #2
0
        private void saveChangesBtn_Click(object sender, EventArgs e)
        {
            ListBox      listBox       = (ListBox)GetControl("inventoryListBox");
            Item         item          = (Item)listBox.SelectedItem;
            DialogResult confirmResult = MessageBox.Show("Are you sure to edit this item?", "Confirm edit", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                foreach (Control control in editItemPanel.Controls[0].Controls)
                {
                    if (control.Name == "editNameTextBox")
                    {
                        item.Name = control.Text;
                    }
                    if (control.Name == "editPriceTextBox")
                    {
                        item.Price = Convert.ToDecimal(control.Text);
                    }
                    if (control.Name == "editQuantityTextBox")
                    {
                        item.Quantity = Convert.ToInt32(control.Text);
                    }
                }

                InvoFileTools.SaveCurrentFile();
                GetControl("showInventoryPanel").Show();
                GetControl("editItemPanel").Hide();
                FillListBox();
            }
        }
예제 #3
0
 //returns false if item already exists. True if succesful
 static public bool AddItemToInventory(Item item)
 {
     //Check if item already exists first
     foreach (Item i in items)
     {
         if (i.Name == item.Name)
         {
             return(false);
         }
     }
     items.Add(item);
     InvoFileTools.SaveCurrentFile();
     return(true);
 }