Ejemplo n.º 1
0
 /// <summary>
 /// Updates item in item list
 /// Keeps previous code for item selected
 /// Gets cost from user input in updateCostTextBox
 /// Gets description from user input in updateDescriptionTextBox
 /// Updates database with updated item
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void updateButton_Click(object sender, RoutedEventArgs e)
 {
     if (evaluateUserInput(updateCostTextBox.Text, updateDescriptionTextBox.Text))
     {
         int    index = itemList.IndexOf(currentItem);
         string cost  = updateCostTextBox.Text.Trim('$');
         string desc  = "\'" + updateDescriptionTextBox.Text + "\'";
         string code  = itemList[index].Item_Code;
         currentItem.Item_Code        = code;
         currentItem.Item_Description = desc.Trim('\'');
         currentItem.Item_Cost        = "$" + cost;
         itemDao.updateItem(sql.updateItem(code, cost, desc));
         itemsDataGrid.ItemsSource = itemList;
         itemsDataGrid.Items.Refresh();
     }
 }