private void Menu_EditItem_Click(object sender, RoutedEventArgs e) { ItemCatalogue items = (ItemCatalogue)Resources["itemCatalogue"]; int index = items.CurrentIndex; try { //create Window to prompt user for data. var editItemWindow = new EditItemWindow(items[index]); //if 'OK' pressed if (editItemWindow.ShowDialog() == true) { //Get data from create-window. int ID = editItemWindow.ID; string Name = editItemWindow.Name; int Price = editItemWindow.Price; //Create new item with data. Item item = new Item(ID, Name, Price); //Replace item with edited item. items[index] = item; } } catch { MessageBox.Show("Please choose an item from the catalogue to edit."); } }
public void ShowEdit(ItsBeen.App.Model.ItemModel item) { EditItemWindow window = new EditItemWindow(); window.Owner = System.Windows.Application.Current.MainWindow; window.ShowDialog(); }
protected override void NewItem(object parameter) { log.Debug("New " + ItemName + " button"); ProductCategoryEntity Item = new ProductCategoryEntity(); EditProductCategoryViewModel EPVM = new EditProductCategoryViewModel(Item, true, ItemName); EditItemWindow EIV = new EditItemWindow() { DataContext = EPVM }; EIV.ShowDialog(); if (EPVM.SaveEdit) { Item = EPVM.Item; NotificationProvider.Info("Product category added", string.Format("Category name:{0}", Item.Category)); RefreshList(parameter); foreach (var p in List) { if (Item.Id == p.Id) { SelectedItem = p; } } } }
protected override void EditItem(object parameter) { log.Debug("Edit " + ItemName + " button"); PartnerEntity Item = new PartnerEntity(); EntityCloner.CloneProperties <PartnerEntity>(SelectedItem, Item); EditPartnerViewModel EPVM = new EditPartnerViewModel(Item, false, ItemName); EditItemWindow EIV = new EditItemWindow() { DataContext = EPVM }; EIV.ShowDialog(); if (EPVM.SaveEdit) { Item = EPVM.Item; NotificationProvider.Info("Partner saved", string.Format("Partner name:{0}", Item.Name)); RefreshList(parameter); foreach (var p in List) { if (Item.Id == p.Id) { SelectedItem = p; } } } }
protected override void NewItem(object parameter) { log.Debug("New " + ItemName + " button"); TransactionHeadListEntity Item = new TransactionHeadListEntity(); Item.Head = new TransactionHeadEntity(); Item.Head.Incoming = this.Incoming; Item.Head.Date = DateTime.Now.Date; EditTransactionViewModel ETVM = new EditTransactionViewModel(Item, true, ItemName); EditItemWindow EIV = new EditItemWindow() { DataContext = ETVM }; EIV.ShowDialog(); if (ETVM.SaveEdit) { Item = ETVM.Item; NotificationProvider.Info("Transaction added", string.Format("Id: {0}\nDate: {1}\nPartner name: {2}", Item.Head.Id, Item.Head.Date.ToString("d"), Item.Partner.Name)); RefreshList(parameter); foreach (var t in List) { if (Item.Head.Id == t.Head.Id) { SelectedItem = t; } } } }
protected override void EditItem(object parameter) { log.Debug("Edit " + ItemName + " button"); TransactionHeadListEntity Item = new TransactionHeadListEntity(); EntityCloner.CloneProperties <TransactionHeadListEntity>(SelectedItem, Item); EditTransactionViewModel ETVM = new EditTransactionViewModel(Item, false, ItemName); EditItemWindow EIV = new EditItemWindow() { DataContext = ETVM }; EIV.ShowDialog(); if (ETVM.SaveEdit) { Item = ETVM.Item; NotificationProvider.Info("Transaction saved", string.Format("Id: {0}\nDate: {1}\nPartner name: {2}", Item.Head.Id, Item.Head.Date.ToString("d"), Item.Partner.Name)); RefreshList(parameter); foreach (var t in List) { if (Item.Head.Id == t.Head.Id) { SelectedItem = t; } } } }
private void EditButton_Click(object sender, RoutedEventArgs e) { EditItemWindow EditWindow = new EditItemWindow() { Title = "Edit Item", Text = (ContentList.SelectedItem as CheckLabel).Text.ToString() }; EditWindow.ShowDialog(); HandleItemChanged(ContentList.SelectedItem, new CheckLabelEventArgs( EditWindow.Text + ToHexColor(EditWindow.Text), (ContentList.SelectedItem as CheckLabel).Tag.ToString())); (ContentList.SelectedItem as CheckLabel).Text = EditWindow.Text; (ContentList.SelectedItem as CheckLabel).Tag = EditWindow.Text + ToHexColor(EditWindow.Text); EditWindow.Close(); }
private void AddButton_Click(object sender, RoutedEventArgs e) { EditItemWindow AddWindow = new EditItemWindow() { Title = "Add Item" }; AddWindow.ShowDialog(); if (!string.IsNullOrWhiteSpace(AddWindow.Text)) { CheckLabel newCL = new CheckLabel { Text = AddWindow.Text, Tag = AddWindow.Text + ToHexColor(AddWindow.Text) }; ContentList.Items.Add(newCL); HandleItemAdded(newCL, new CheckLabelEventArgs(newCL.Tag.ToString())); CheckItemCount(); } AddWindow.Close(); }