Added Edit Transaction
This commit is contained in:
@@ -105,6 +105,7 @@
|
|||||||
<Compile Include="Model\Person.cs" />
|
<Compile Include="Model\Person.cs" />
|
||||||
<Compile Include="ViewModel\Dialogs\AddTransactionViewModel.cs" />
|
<Compile Include="ViewModel\Dialogs\AddTransactionViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Dialogs\DatabaseSelectorDialogViewModel.cs" />
|
<Compile Include="ViewModel\Dialogs\DatabaseSelectorDialogViewModel.cs" />
|
||||||
|
<Compile Include="ViewModel\Dialogs\EditTransactionDialogViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Dialogs\NewPersonDialogViewModel.cs" />
|
<Compile Include="ViewModel\Dialogs\NewPersonDialogViewModel.cs" />
|
||||||
<Compile Include="ViewModel\MainViewModel.cs" />
|
<Compile Include="ViewModel\MainViewModel.cs" />
|
||||||
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
||||||
@@ -114,6 +115,9 @@
|
|||||||
<Compile Include="View\Dialogs\DatabaseSelectorDialogView.xaml.cs">
|
<Compile Include="View\Dialogs\DatabaseSelectorDialogView.xaml.cs">
|
||||||
<DependentUpon>DatabaseSelectorDialogView.xaml</DependentUpon>
|
<DependentUpon>DatabaseSelectorDialogView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="View\Dialogs\EditTransactionDialogView.xaml.cs">
|
||||||
|
<DependentUpon>EditTransactionDialogView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="View\Dialogs\NewPersonDialogView.xaml.cs">
|
<Compile Include="View\Dialogs\NewPersonDialogView.xaml.cs">
|
||||||
<DependentUpon>NewPersonDialogView.xaml</DependentUpon>
|
<DependentUpon>NewPersonDialogView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -132,6 +136,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="View\Dialogs\EditTransactionDialogView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="View\Dialogs\NewPersonDialogView.xaml">
|
<Page Include="View\Dialogs\NewPersonDialogView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace DebtMgr.View.Dialogs
|
|||||||
DataContext = App.Locator.AddTransactionView;
|
DataContext = App.Locator.AddTransactionView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region TextBox_OnKeyUp()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// <summary> Event handler. Called by TextBox for on key up events. </summary>
|
/// <summary> Event handler. Called by TextBox for on key up events. </summary>
|
||||||
///
|
///
|
||||||
@@ -41,6 +43,9 @@ namespace DebtMgr.View.Dialogs
|
|||||||
App.Locator.AddTransactionView.AddTransactionButtonClickCommand.Execute(null);
|
App.Locator.AddTransactionView.AddTransactionButtonClickCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region Window_OnKeyUp()
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// <summary> Event handler. Called by Window for on key up events. </summary>
|
/// <summary> Event handler. Called by Window for on key up events. </summary>
|
||||||
///
|
///
|
||||||
@@ -54,5 +59,7 @@ namespace DebtMgr.View.Dialogs
|
|||||||
if (e.Key.Equals(Key.Escape))
|
if (e.Key.Equals(Key.Escape))
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
49
View/Dialogs/EditTransactionDialogView.xaml
Normal file
49
View/Dialogs/EditTransactionDialogView.xaml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<Window x:Class="DebtMgr.View.Dialogs.EditTransactionDialogView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:DebtMgr.View.Dialogs"
|
||||||
|
xmlns:currencyTextBoxControl="clr-namespace:CurrencyTextBoxControl;assembly=CurrencyTextBoxControl"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Icon="../../Content/moneybag.ico"
|
||||||
|
Name="EditTransactionViewWindow"
|
||||||
|
Title="{Binding WindowTitle}" Height="300" Width="300"
|
||||||
|
KeyUp="Window_KeyUp">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Vertical">
|
||||||
|
<Label Content="{Binding ElementName=EditTransactionViewWindow, Path=Title}" FontWeight="Bold" FontSize="18"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10 0">
|
||||||
|
<currencyTextBoxControl:CurrencyTextBox KeyUp="TextBox_OnKeyUp" Name="Amount" Number="{Binding AmountTextBoxText}" StringFormat="0.00 Eur" FontSize="16" Margin="0 0 0 -5"></currencyTextBoxControl:CurrencyTextBox>
|
||||||
|
<Label Content="Amount in EUR"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="2" Orientation="Vertical" Margin="10 0">
|
||||||
|
<TextBox KeyUp="TextBox_OnKeyUp" Name="Description" Text="{Binding DescriptionTextBoxText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 -5"></TextBox>
|
||||||
|
<Label Content="Description"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Vertical" Margin="10 0">
|
||||||
|
<DatePicker KeyUp="TextBox_OnKeyUp" SelectedDate="{Binding DatePickerSelectedDate}"></DatePicker>
|
||||||
|
<Label Content="Date"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="4" Orientation="Vertical" Margin="10 0">
|
||||||
|
<Label Content="{Binding PersonNameLabelContent}" FontSize="14"></Label>
|
||||||
|
<Label Content="Person"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
<Grid Grid.Row="5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Grid.Column="1" Content="Save" FontSize="14" Padding="5" Margin="10 -10" Command="{Binding SaveTransactionButtonClickCommand}"></Button>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
72
View/Dialogs/EditTransactionDialogView.xaml.cs
Normal file
72
View/Dialogs/EditTransactionDialogView.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using DebtMgr.Extensions;
|
||||||
|
|
||||||
|
namespace DebtMgr.View.Dialogs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaktionslogik für EditTransactionDialogView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class EditTransactionDialogView : Window
|
||||||
|
{
|
||||||
|
public EditTransactionDialogView(Guid transactionId)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.CenterOnParent();
|
||||||
|
|
||||||
|
App.Locator.EditTransactionDialogView.RequestClose += (s, e) => Close();
|
||||||
|
App.Locator.EditTransactionDialogView.ClearView();
|
||||||
|
App.Locator.EditTransactionDialogView.TransactionId = transactionId;
|
||||||
|
App.Locator.EditTransactionDialogView.LoadTransaction();
|
||||||
|
|
||||||
|
DataContext = App.Locator.EditTransactionDialogView;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Window_KeyUp()
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// <summary> Event handler. Called by Window for key up events. </summary>
|
||||||
|
///
|
||||||
|
/// <remarks> Andre Beging, 12.09.2017. </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="sender"> Source of the event. </param>
|
||||||
|
/// <param name="e"> Key event information. </param>
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
private void Window_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key.Equals(Key.Escape))
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region TextBox_OnKeyUp()
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// <summary> Event handler. Called by TextBox for on key up events. </summary>
|
||||||
|
///
|
||||||
|
/// <remarks> Andre Beging, 12.09.2017. </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="sender"> Source of the event. </param>
|
||||||
|
/// <param name="e"> Key event information. </param>
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
private void TextBox_OnKeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return))
|
||||||
|
App.Locator.EditTransactionDialogView.SaveTransactionButtonClickCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -120,6 +120,7 @@
|
|||||||
</ListView.View>
|
</ListView.View>
|
||||||
<ListBox.Resources>
|
<ListBox.Resources>
|
||||||
<ContextMenu x:Key="TransactionHistoryListViewContextMenu">
|
<ContextMenu x:Key="TransactionHistoryListViewContextMenu">
|
||||||
|
<MenuItem Header="Edit Transaction" Command="{Binding EditTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
|
||||||
<MenuItem Header="Add charge" Command="{Binding AddChargeContextMenuCommand}" />
|
<MenuItem Header="Add charge" Command="{Binding AddChargeContextMenuCommand}" />
|
||||||
<MenuItem Header="Add deposit" Command="{Binding AddDepositContextMenuCommand}" />
|
<MenuItem Header="Add deposit" Command="{Binding AddDepositContextMenuCommand}" />
|
||||||
<MenuItem Header="Delete Transaction" Command="{Binding DeleteTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
|
<MenuItem Header="Delete Transaction" Command="{Binding DeleteTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
|
||||||
|
|||||||
243
ViewModel/Dialogs/EditTransactionDialogViewModel.cs
Normal file
243
ViewModel/Dialogs/EditTransactionDialogViewModel.cs
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using DebtMgr.Model;
|
||||||
|
using GalaSoft.MvvmLight;
|
||||||
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using SQLiteNetExtensions.Extensions;
|
||||||
|
|
||||||
|
namespace DebtMgr.ViewModel.Dialogs
|
||||||
|
{
|
||||||
|
public class EditTransactionDialogViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
public event EventHandler RequestClose;
|
||||||
|
|
||||||
|
public Guid TransactionId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private Transaction _transaction;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region WindowTitle (string) Property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Privater Teil von <see cref="WindowTitle" />
|
||||||
|
/// </summary>
|
||||||
|
private string _windowTitle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
///</summary>
|
||||||
|
public string WindowTitle
|
||||||
|
{
|
||||||
|
get { return _windowTitle; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_windowTitle = value;
|
||||||
|
RaisePropertyChanged(() => WindowTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region AmountTextBoxText (string) Property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Privater Teil von <see cref="AmountTextBoxText" />
|
||||||
|
/// </summary>
|
||||||
|
private string _amountTextBoxText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
///</summary>
|
||||||
|
public string AmountTextBoxText
|
||||||
|
{
|
||||||
|
get { return _amountTextBoxText; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_amountTextBoxText = value;
|
||||||
|
RaisePropertyChanged(() => AmountTextBoxText);
|
||||||
|
SaveTransactionButtonClickCommand.RaiseCanExecuteChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// <summary> Gets the amount text box text as number representation. </summary>
|
||||||
|
///
|
||||||
|
/// <value> The amount text box text number representation. </value>
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
public double AmountTextBoxTextNumberRepresentation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_amountTextBoxText)) return 0.0;
|
||||||
|
return double.Parse(_amountTextBoxText, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region PersonNameLabelContent (string) Property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Privater Teil von <see cref="PersonNameLabelContent" />
|
||||||
|
/// </summary>
|
||||||
|
private string _personNameLabelContent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
///</summary>
|
||||||
|
public string PersonNameLabelContent
|
||||||
|
{
|
||||||
|
get { return _personNameLabelContent; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_personNameLabelContent = value;
|
||||||
|
RaisePropertyChanged(() => PersonNameLabelContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region DescriptionTextBoxText (string) Property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Privater Teil von <see cref="DescriptionTextBoxText" />
|
||||||
|
/// </summary>
|
||||||
|
private string _descriptionTextBoxText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
///</summary>
|
||||||
|
public string DescriptionTextBoxText
|
||||||
|
{
|
||||||
|
get { return _descriptionTextBoxText; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_descriptionTextBoxText = value;
|
||||||
|
RaisePropertyChanged(() => DescriptionTextBoxText);
|
||||||
|
SaveTransactionButtonClickCommand.RaiseCanExecuteChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region DatePickerSelectedDate (DateTime?) Property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Privater Teil von <see cref="DatePickerSelectedDate" />
|
||||||
|
/// </summary>
|
||||||
|
private DateTime? _datePickerSelectedDate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
///</summary>
|
||||||
|
public DateTime? DatePickerSelectedDate
|
||||||
|
{
|
||||||
|
get { return _datePickerSelectedDate; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_datePickerSelectedDate = value;
|
||||||
|
RaisePropertyChanged(() => DatePickerSelectedDate);
|
||||||
|
SaveTransactionButtonClickCommand.RaiseCanExecuteChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SaveTransactionButtonClickCommand Command
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Private member backing variable for <see cref="SaveTransactionButtonClickCommand" />
|
||||||
|
/// </summary>
|
||||||
|
private RelayCommand _saveTransactionButtonClickCommand = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
/// </summary>
|
||||||
|
public RelayCommand SaveTransactionButtonClickCommand => _saveTransactionButtonClickCommand ?? (_saveTransactionButtonClickCommand = new RelayCommand(SaveTransactionButtonClickCommand_Execute, SaveTransactionButtonClickCommand_CanExecute));
|
||||||
|
|
||||||
|
private bool SaveTransactionButtonClickCommand_CanExecute()
|
||||||
|
{
|
||||||
|
if (_transaction == null) return false;
|
||||||
|
if (AmountTextBoxTextNumberRepresentation < 0.01) return false;
|
||||||
|
if (string.IsNullOrWhiteSpace(DescriptionTextBoxText)) return false;
|
||||||
|
if (DatePickerSelectedDate == null) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveTransactionButtonClickCommand_Execute()
|
||||||
|
{
|
||||||
|
if (SaveTransactionButtonClickCommand_CanExecute())
|
||||||
|
{
|
||||||
|
var transaction = App.Database.Get<Transaction>(TransactionId);
|
||||||
|
|
||||||
|
if (DatePickerSelectedDate != null)
|
||||||
|
{
|
||||||
|
transaction.Amount = AmountTextBoxTextNumberRepresentation;
|
||||||
|
transaction.Description = DescriptionTextBoxText;
|
||||||
|
transaction.Time = DatePickerSelectedDate.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Database.InsertOrReplace(transaction);
|
||||||
|
RequestClose?.Invoke(null, null);
|
||||||
|
App.Locator.MainView.UpdatePersonsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LoadTransaction()
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// <summary> Loads the transaction. </summary>
|
||||||
|
///
|
||||||
|
/// <remarks> Andre Beging, 12.09.2017. </remarks>
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
public void LoadTransaction()
|
||||||
|
{
|
||||||
|
if (TransactionId == Guid.Empty) return;
|
||||||
|
_transaction = App.Database.Get<Transaction>(TransactionId);
|
||||||
|
|
||||||
|
if (_transaction == null) return;
|
||||||
|
App.Database.GetChildren(_transaction);
|
||||||
|
|
||||||
|
PersonNameLabelContent = string.Format("{0} {1}", _transaction.Person.FirstName,
|
||||||
|
_transaction.Person.LastName);
|
||||||
|
AmountTextBoxText = _transaction.Amount.ToString(CultureInfo.InvariantCulture);
|
||||||
|
DescriptionTextBoxText = _transaction.Description;
|
||||||
|
DatePickerSelectedDate = _transaction.Time;
|
||||||
|
|
||||||
|
if (_transaction.Type == TransactionType.Charge)
|
||||||
|
WindowTitle = "Edit Charge";
|
||||||
|
else if (_transaction.Type == TransactionType.Deposit)
|
||||||
|
WindowTitle = "Edit Deposit";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region ClearView()
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// <summary> Clears the view. </summary>
|
||||||
|
///
|
||||||
|
/// <remarks> Andre Beging, 12.09.2017. </remarks>
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
public void ClearView()
|
||||||
|
{
|
||||||
|
PersonNameLabelContent = string.Empty;
|
||||||
|
AmountTextBoxText = string.Empty;
|
||||||
|
DescriptionTextBoxText = string.Empty;
|
||||||
|
DatePickerSelectedDate = null;
|
||||||
|
|
||||||
|
TransactionId = Guid.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -174,6 +174,7 @@ namespace DebtMgr.ViewModel
|
|||||||
_transactionHistoryListViewSelectedItem = value;
|
_transactionHistoryListViewSelectedItem = value;
|
||||||
RaisePropertyChanged(() => TransactionHistoryListViewSelectedItem);
|
RaisePropertyChanged(() => TransactionHistoryListViewSelectedItem);
|
||||||
DeleteTransactionContextMenuCommand.RaiseCanExecuteChanged();
|
DeleteTransactionContextMenuCommand.RaiseCanExecuteChanged();
|
||||||
|
EditTransactionContextMenuCommand.RaiseCanExecuteChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,6 +390,34 @@ namespace DebtMgr.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region EditTransactionContextMenuCommand Command
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Private member backing variable for <see cref="EditTransactionContextMenuCommand" />
|
||||||
|
/// </summary>
|
||||||
|
private RelayCommand _editTransactionContextMenuCommand = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
/// </summary>
|
||||||
|
public RelayCommand EditTransactionContextMenuCommand => _editTransactionContextMenuCommand ?? (_editTransactionContextMenuCommand = new RelayCommand(EditTransactionContextMenuCommand_Execute, EditTransactionContextMenuCommand_CanExecute));
|
||||||
|
|
||||||
|
private bool EditTransactionContextMenuCommand_CanExecute()
|
||||||
|
{
|
||||||
|
if (TransactionHistoryListViewSelectedItem != null)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditTransactionContextMenuCommand_Execute()
|
||||||
|
{
|
||||||
|
if (TransactionHistoryListViewSelectedItem == null) return;
|
||||||
|
|
||||||
|
var window = new EditTransactionDialogView(TransactionHistoryListViewSelectedItem.Id);
|
||||||
|
window.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SwitchDatabaseMenuCommand Command
|
#region SwitchDatabaseMenuCommand Command
|
||||||
@@ -416,7 +445,6 @@ namespace DebtMgr.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region OpenDatabaseLocationMenuCommand Command
|
#region OpenDatabaseLocationMenuCommand Command
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ namespace DebtMgr.ViewModel
|
|||||||
SimpleIoc.Default.Register<NewPersonDialogViewModel>();
|
SimpleIoc.Default.Register<NewPersonDialogViewModel>();
|
||||||
SimpleIoc.Default.Register<AddTransactionViewModel>();
|
SimpleIoc.Default.Register<AddTransactionViewModel>();
|
||||||
SimpleIoc.Default.Register<DatabaseSelectorDialogViewModel>();
|
SimpleIoc.Default.Register<DatabaseSelectorDialogViewModel>();
|
||||||
|
SimpleIoc.Default.Register<EditTransactionDialogViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainViewModel MainView => ServiceLocator.Current.GetInstance<MainViewModel>();
|
public MainViewModel MainView => ServiceLocator.Current.GetInstance<MainViewModel>();
|
||||||
public NewPersonDialogViewModel NewPersonDialogView => ServiceLocator.Current.GetInstance<NewPersonDialogViewModel>();
|
public NewPersonDialogViewModel NewPersonDialogView => ServiceLocator.Current.GetInstance<NewPersonDialogViewModel>();
|
||||||
public AddTransactionViewModel AddTransactionView => ServiceLocator.Current.GetInstance<AddTransactionViewModel>();
|
public AddTransactionViewModel AddTransactionView => ServiceLocator.Current.GetInstance<AddTransactionViewModel>();
|
||||||
public DatabaseSelectorDialogViewModel DatabaseSelectorDialogView => ServiceLocator.Current.GetInstance<DatabaseSelectorDialogViewModel>();
|
public DatabaseSelectorDialogViewModel DatabaseSelectorDialogView => ServiceLocator.Current.GetInstance<DatabaseSelectorDialogViewModel>();
|
||||||
|
public EditTransactionDialogViewModel EditTransactionDialogView => ServiceLocator.Current.GetInstance<EditTransactionDialogViewModel>();
|
||||||
|
|
||||||
public static void Cleanup()
|
public static void Cleanup()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user