示例#1
0
 private void btnUpdate_Click(object sender, RoutedEventArgs e)
 {
     if (dataGrid.SelectedItem is CatalogItem)
     {
         CatalogItem itm     = (CatalogItem)dataGrid.SelectedItem;
         ItemWindow  itemWin = new ItemWindow(itm);
         itemWin.ShowDialog();
         if (itemWin.DialogResult == true)
         {
             UpdateData(itm);
             DataBind();
             dataGrid.Items.Refresh();
         }
         else
         {
             MessageBox.Show("Unable to update item");
         }
     }
 }
示例#2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            CatalogItem newItem = new CatalogItem();


            ItemWindow itemWin = new ItemWindow(newItem);

            itemWin.ShowDialog();

            if (itemWin.DialogResult == true)
            {
                AddData(newItem);
                DataBind();
                dataGrid.Items.Refresh();
            }
            else
            {
                MessageBox.Show("Unable to add item to catalog.");
            }
        }