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>
|
||||
/// <returns>Die Daten, für den angefragten Tag</returns>
|
||||
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>
|
||||
/// <returns>Liste der gültigen Kostenstellen</returns>
|
||||
|
|
|
@ -88,6 +88,8 @@ namespace TimeScheduler.Domain.Impl
|
|||
.OrderBy(x => x.From)
|
||||
.Cast<ITimeItem>();
|
||||
}
|
||||
ITimeItem IDomain.NewItem() { return new TimeItem(); }
|
||||
|
||||
|
||||
Dictionary<int, string> IDomain.GetCostUnits()
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace TimeScheduler.Domain.Impl
|
|||
{
|
||||
#region Konstruktion
|
||||
/// <summary>Standard-Konstruktor</summary>
|
||||
public TimeItem() { key_ = -1; }
|
||||
public TimeItem() { key_ = -1; From = DateTime.Now.Date; Till = From; }
|
||||
|
||||
/// <summary>Konstruktor</summary>
|
||||
/// <param name="description">Beschreibung</param>
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
<DatePicker DockPanel.Dock="Top" Margin="5" SelectedDate="{Binding Path=CurrentDate}"/>
|
||||
<ListBox x:Name="lbTimeElements" Margin="5" HorizontalContentAlignment="Stretch"
|
||||
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>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Background">
|
||||
|
@ -117,12 +123,16 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Margin" Value="15,10"/>
|
||||
</Style>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Margin" Value="15,10"/>
|
||||
</Style>
|
||||
<Style TargetType="DatePicker">
|
||||
<Setter Property="Margin" Value="15,10"/>
|
||||
</Style>
|
||||
|
@ -134,18 +144,21 @@
|
|||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="Von:"/>
|
||||
<DatePickerTextBox Grid.Column="1" Grid.Row="0" Text="{Binding From,StringFormat=g}"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="Beschreibung:"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=Description}"/>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="Von:"/>
|
||||
<DatePickerTextBox Grid.Column="1" Grid.Row="1" Text="{Binding From,StringFormat=g}"/>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="Bis:"/>
|
||||
<DatePickerTextBox Grid.Column="1" Grid.Row="1" Text="{Binding Till,StringFormat=g}"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Bis:"/>
|
||||
<DatePickerTextBox Grid.Column="1" Grid.Row="2" Text="{Binding Till,StringFormat=g}"/>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Kostenstelle:"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="2" DisplayMemberPath="Value" SelectedValuePath="Key"
|
||||
<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}"/>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="3" Text="Typ:"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="3" DisplayMemberPath="Value" SelectedValuePath="Key"
|
||||
<TextBlock Grid.Column="0" Grid.Row="4" Text="Typ:"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="4" DisplayMemberPath="Value" SelectedValuePath="Key"
|
||||
ItemsSource="{Binding Source={StaticResource proxy},Path=Data.ItemTypes}" SelectedValue="{Binding ItemType}"/>
|
||||
|
||||
</Grid>
|
||||
|
|
|
@ -62,6 +62,8 @@ namespace TimeScheduler.ViewModel
|
|||
private void CreateCommands()
|
||||
{
|
||||
RefreshCommand = new RelayCommand(Refresh);
|
||||
AddNewCommand = new RelayCommand(AddNew);
|
||||
DeleteCommand = new RelayCommand(Delete, CanDelete);
|
||||
}
|
||||
|
||||
public ICommand RefreshCommand { get; private set; }
|
||||
|
@ -110,6 +112,13 @@ namespace TimeScheduler.ViewModel
|
|||
|
||||
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
|
||||
|
||||
#region Hilfsfunktionen
|
||||
|
|
Loading…
Reference in a new issue