Пример #1
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            _selectedIndex = expensesDataGrid.SelectedIndex;

            if (_selectedIndex == -1)
            {
                MessageBox.Show("Please choose a row for edit.");
                return;
            }

            var _selectedRecord = _expenses[_selectedIndex];

            AddEditExpenseWindow addEditExpenseWindow = new AddEditExpenseWindow();

            var result = addEditExpenseWindow.ShowForEdit(_selectedRecord);

            if (result == false)
            {
                return;
            }

            ExpenseRepository.Update(_selectedRecord);

            _expenses[_selectedIndex] = addEditExpenseWindow.Model;

            expensesDataGrid.Items.Refresh();
        }
Пример #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            var addEditExpenseWindow = new AddEditExpenseWindow();

            var result = addEditExpenseWindow.ShowForAdd();

            if (result == false)
            {
                return;
            }

            var newExpense = new Expense();

            newExpense = addEditExpenseWindow.Model;

            ExpenseRepository.Add(newExpense);

            _expenses.Add(newExpense);

            expensesDataGrid.Items.Refresh();
        }