private void Btn_unSelectedItem_Click(object sender, RoutedEventArgs e) {//unselect item try { itemUnitOffer = dg_selectedItems.SelectedItem as ItemUnitOffer; ItemUnit i = new ItemUnit(); if (itemUnitOffer != null) { i = allItemsSource.Where(s => s.itemUnitId == itemUnitOffer.iuId.Value).FirstOrDefault(); allItems.Add(i); selectedItems.Remove(itemUnitOffer); dg_allItems.ItemsSource = allItems; dg_selectedItems.ItemsSource = selectedItems; dg_allItems.Items.Refresh(); dg_selectedItems.Items.Refresh(); } } catch (Exception ex) { SectionData.ExceptionMessage(ex, this); } }
private void Btn_selectedItem_Click(object sender, RoutedEventArgs e) {//select item try { itemUnit = dg_allItems.SelectedItem as ItemUnit; if (itemUnit != null) { ItemUnitOffer iUO = new ItemUnitOffer(); iUO.ioId = 0; iUO.iuId = itemUnit.itemUnitId; iUO.offerId = offerId; iUO.createUserId = MainWindow.userID; iUO.quantity = 1; iUO.offerName = offer.name; iUO.unitName = itemUnit.unitName; iUO.itemName = itemUnit.itemName; iUO.itemId = itemUnit.itemId; iUO.unitId = itemUnit.unitId; allItems.Remove(itemUnit); selectedItems.Add(iUO); dg_allItems.ItemsSource = allItems; dg_selectedItems.ItemsSource = selectedItems; dg_allItems.Items.Refresh(); dg_selectedItems.Items.Refresh(); } } catch (Exception ex) { SectionData.ExceptionMessage(ex, this); } }