Exemplo n.º 1
0
 /// <summary>
 /// Adds a new item to item list
 /// Automatically creates a code for the new item
 /// Gets cost from user input in addCostTextBox
 /// Gets description from user input in addDescriptionTextBox
 /// Updates database with new item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     if (evaluateUserInput(addCostTextBox.Text, addDescriptionTextBox.Text))
     {
         string cost = addCostTextBox.Text.Trim('$');
         string desc = "\'" + addDescriptionTextBox.Text + "\'";
         itemDao.addItem(sql.addItem(cost, desc));
         itemList.Add(new Item((itemList.Count + 1).ToString(), addDescriptionTextBox.Text, "$" + cost));
         itemsDataGrid.ItemsSource = itemList;
         itemsDataGrid.Items.Refresh();
     }
 }