Esempio n. 1
0
        // edit the selected item
        public void EditItem(object sender, RoutedEventArgs e)
        {
            try // check for valid selected item
            {
                Item item = (Item)ItemTable.SelectedItem;
                if (item != null) // check for not null
                {
                    // same screen as AddItem => give item as var to know difference
                    Window window = new EditAddItemView(item);
                    window.Title = "Edit Item with id: " + item.Id;
                    window.ShowDialog();

                    if (window.DialogResult == true)
                    {
                        FillItemTable();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                string mesg = "You did not select an item!";
                MessageBox.Show(mesg);
            }
        }
Esempio n. 2
0
        // add a new item
        public void AddItem(object sender, RoutedEventArgs e)
        {
            // same screen as EditItem => give null as var to know difference
            Window window = new EditAddItemView(null);

            window.Title = "Add Item";
            window.ShowDialog();

            if (window.DialogResult == true)
            {
                FillItemTable();
            }
        }