Hinzufügen und entfernen eingebaut
This commit is contained in:
parent
e272f62629
commit
a922563849
5 changed files with 36 additions and 9 deletions
|
@ -11,6 +11,9 @@ namespace TimeScheduler.Domain
|
||||||
/// <param name="date">Der Tag für den Werte gesucht werden sollen</param>
|
/// <param name="date">Der Tag für den Werte gesucht werden sollen</param>
|
||||||
/// <returns>Die Daten, für den angefragten Tag</returns>
|
/// <returns>Die Daten, für den angefragten Tag</returns>
|
||||||
IEnumerable<ITimeItem> GetItems(DateTime date);
|
IEnumerable<ITimeItem> GetItems(DateTime date);
|
||||||
|
/// <summary>Erzeugt ein neues <see cref="ITimeItem"/>-Element</summary>
|
||||||
|
/// <returns>Ein neues <see cref="ITimeItem"/>-Element</returns>
|
||||||
|
ITimeItem NewItem();
|
||||||
|
|
||||||
/// <summary>Ermittelt die gültigen Kostenstellen</summary>
|
/// <summary>Ermittelt die gültigen Kostenstellen</summary>
|
||||||
/// <returns>Liste der gültigen Kostenstellen</returns>
|
/// <returns>Liste der gültigen Kostenstellen</returns>
|
||||||
|
|
|
@ -88,6 +88,8 @@ namespace TimeScheduler.Domain.Impl
|
||||||
.OrderBy(x => x.From)
|
.OrderBy(x => x.From)
|
||||||
.Cast<ITimeItem>();
|
.Cast<ITimeItem>();
|
||||||
}
|
}
|
||||||
|
ITimeItem IDomain.NewItem() { return new TimeItem(); }
|
||||||
|
|
||||||
|
|
||||||
Dictionary<int, string> IDomain.GetCostUnits()
|
Dictionary<int, string> IDomain.GetCostUnits()
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace TimeScheduler.Domain.Impl
|
||||||
{
|
{
|
||||||
#region Konstruktion
|
#region Konstruktion
|
||||||
/// <summary>Standard-Konstruktor</summary>
|
/// <summary>Standard-Konstruktor</summary>
|
||||||
public TimeItem() { key_ = -1; }
|
public TimeItem() { key_ = -1; From = DateTime.Now.Date; Till = From; }
|
||||||
|
|
||||||
/// <summary>Konstruktor</summary>
|
/// <summary>Konstruktor</summary>
|
||||||
/// <param name="description">Beschreibung</param>
|
/// <param name="description">Beschreibung</param>
|
||||||
|
|
|
@ -28,6 +28,12 @@
|
||||||
<DatePicker DockPanel.Dock="Top" Margin="5" SelectedDate="{Binding Path=CurrentDate}"/>
|
<DatePicker DockPanel.Dock="Top" Margin="5" SelectedDate="{Binding Path=CurrentDate}"/>
|
||||||
<ListBox x:Name="lbTimeElements" Margin="5" HorizontalContentAlignment="Stretch"
|
<ListBox x:Name="lbTimeElements" Margin="5" HorizontalContentAlignment="Stretch"
|
||||||
ItemsSource="{Binding TimeItems}" SelectedItem="{Binding SelectedTimeItem}">
|
ItemsSource="{Binding TimeItems}" SelectedItem="{Binding SelectedTimeItem}">
|
||||||
|
<ListBox.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Command="{Binding AddNewCommand}" Header="Neues Element"/>
|
||||||
|
<MenuItem Command="{Binding DeleteCommand}" Header="Lösche selektiertes Element"/>
|
||||||
|
</ContextMenu>
|
||||||
|
</ListBox.ContextMenu>
|
||||||
<ListBox.ItemContainerStyle>
|
<ListBox.ItemContainerStyle>
|
||||||
<Style TargetType="ListBoxItem">
|
<Style TargetType="ListBoxItem">
|
||||||
<Setter Property="Background">
|
<Setter Property="Background">
|
||||||
|
@ -117,12 +123,16 @@
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.Resources>
|
<Grid.Resources>
|
||||||
<Style TargetType="TextBlock">
|
<Style TargetType="TextBlock">
|
||||||
<Setter Property="Margin" Value="15,10"/>
|
<Setter Property="Margin" Value="15,10"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Margin" Value="15,10"/>
|
||||||
|
</Style>
|
||||||
<Style TargetType="DatePicker">
|
<Style TargetType="DatePicker">
|
||||||
<Setter Property="Margin" Value="15,10"/>
|
<Setter Property="Margin" Value="15,10"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
@ -134,18 +144,21 @@
|
||||||
</Style>
|
</Style>
|
||||||
</Grid.Resources>
|
</Grid.Resources>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="Von:"/>
|
<TextBlock Grid.Column="0" Grid.Row="0" Text="Beschreibung:"/>
|
||||||
<DatePickerTextBox Grid.Column="1" Grid.Row="0" Text="{Binding From,StringFormat=g}"/>
|
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=Description}"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="Bis:"/>
|
<TextBlock Grid.Column="0" Grid.Row="1" Text="Von:"/>
|
||||||
<DatePickerTextBox Grid.Column="1" Grid.Row="1" Text="{Binding Till,StringFormat=g}"/>
|
<DatePickerTextBox Grid.Column="1" Grid.Row="1" Text="{Binding From,StringFormat=g}"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Kostenstelle:"/>
|
<TextBlock Grid.Column="0" Grid.Row="2" Text="Bis:"/>
|
||||||
<ComboBox Grid.Column="1" Grid.Row="2" DisplayMemberPath="Value" SelectedValuePath="Key"
|
<DatePickerTextBox Grid.Column="1" Grid.Row="2" Text="{Binding Till,StringFormat=g}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Grid.Row="3" Text="Kostenstelle:"/>
|
||||||
|
<ComboBox Grid.Column="1" Grid.Row="3" DisplayMemberPath="Value" SelectedValuePath="Key"
|
||||||
ItemsSource="{Binding Source={StaticResource proxy},Path=Data.CostUnits}" SelectedValue="{Binding CostUnit}"/>
|
ItemsSource="{Binding Source={StaticResource proxy},Path=Data.CostUnits}" SelectedValue="{Binding CostUnit}"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="3" Text="Typ:"/>
|
<TextBlock Grid.Column="0" Grid.Row="4" Text="Typ:"/>
|
||||||
<ComboBox Grid.Column="1" Grid.Row="3" DisplayMemberPath="Value" SelectedValuePath="Key"
|
<ComboBox Grid.Column="1" Grid.Row="4" DisplayMemberPath="Value" SelectedValuePath="Key"
|
||||||
ItemsSource="{Binding Source={StaticResource proxy},Path=Data.ItemTypes}" SelectedValue="{Binding ItemType}"/>
|
ItemsSource="{Binding Source={StaticResource proxy},Path=Data.ItemTypes}" SelectedValue="{Binding ItemType}"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -62,6 +62,8 @@ namespace TimeScheduler.ViewModel
|
||||||
private void CreateCommands()
|
private void CreateCommands()
|
||||||
{
|
{
|
||||||
RefreshCommand = new RelayCommand(Refresh);
|
RefreshCommand = new RelayCommand(Refresh);
|
||||||
|
AddNewCommand = new RelayCommand(AddNew);
|
||||||
|
DeleteCommand = new RelayCommand(Delete, CanDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand RefreshCommand { get; private set; }
|
public ICommand RefreshCommand { get; private set; }
|
||||||
|
@ -110,6 +112,13 @@ namespace TimeScheduler.ViewModel
|
||||||
|
|
||||||
SelectedTimeItem = TimeItems.FirstOrDefault();
|
SelectedTimeItem = TimeItems.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICommand AddNewCommand { get; private set; }
|
||||||
|
private void AddNew() { TimeItems.Add(Provider.NewItem()); }
|
||||||
|
|
||||||
|
public ICommand DeleteCommand { get; private set; }
|
||||||
|
private void Delete() { TimeItems.Remove(SelectedTimeItem); }
|
||||||
|
public bool CanDelete() { return SelectedTimeItem != null; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Hilfsfunktionen
|
#region Hilfsfunktionen
|
||||||
|
|
Loading…
Reference in a new issue