Fixed missing buttons for deletion

This commit is contained in:
2024-05-05 18:20:50 +02:00
parent 04f7e998cb
commit a3f6121eda
5 changed files with 35 additions and 7 deletions

View File

@@ -16,10 +16,16 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
public Customer SelectedCustomer public Customer SelectedCustomer
{ {
get { return selectedCustomer; } get { return selectedCustomer; }
set { SetProperty(ref selectedCustomer, value); (UpdateCustomerCommand as RelayCommand).NotifyCanExecuteChanged(); } set
{
SetProperty(ref selectedCustomer, value);
(UpdateCustomerCommand as RelayCommand).NotifyCanExecuteChanged();
(DeleteCustomerCommand as RelayCommand).NotifyCanExecuteChanged();
}
} }
public ICommand UpdateCustomerCommand { get; set; } public ICommand UpdateCustomerCommand { get; set; }
public ICommand DeleteCustomerCommand { get; set; }
public static bool IsInDesignMode public static bool IsInDesignMode
{ {
@@ -44,6 +50,15 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
{ {
return SelectedCustomer != null; return SelectedCustomer != null;
}); });
DeleteCustomerCommand = new RelayCommand(() =>
{
Customers.Delete(SelectedCustomer.ID);
},
() =>
{
return SelectedCustomer != null;
});
} }
} }
} }

View File

@@ -22,11 +22,13 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
SetProperty(ref selectedMaintainerTeam, value); SetProperty(ref selectedMaintainerTeam, value);
(UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); (UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged();
(GetColleaguesCommand as RelayCommand).NotifyCanExecuteChanged(); (GetColleaguesCommand as RelayCommand).NotifyCanExecuteChanged();
(DeleteMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged();
} }
} }
public ICommand UpdateMaintainerTeamCommand { get; set; } public ICommand UpdateMaintainerTeamCommand { get; set; }
public ICommand GetColleaguesCommand { get; set; } public ICommand GetColleaguesCommand { get; set; }
public ICommand DeleteMaintainerTeamCommand { get; set; }
public static bool IsInDesignMode public static bool IsInDesignMode
{ {
@@ -52,6 +54,15 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
return SelectedMaintainerTeam != null; return SelectedMaintainerTeam != null;
}); });
DeleteMaintainerTeamCommand = new RelayCommand(() =>
{
MaintainerTeams.Delete(SelectedMaintainerTeam.ID);
},
() =>
{
return SelectedMaintainerTeam != null;
});
GetColleaguesCommand = new RelayCommand(() => GetColleaguesCommand = new RelayCommand(() =>
{ {
Window window = new GetColleagues(SelectedMaintainerTeam); Window window = new GetColleagues(SelectedMaintainerTeam);

View File

@@ -13,8 +13,8 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="9*" /> <RowDefinition Height="8*" />
<RowDefinition Height="1*" /> <RowDefinition Height="2*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListBox ItemsSource="{Binding Customers}" Grid.Row="0" SelectedItem="{Binding SelectedCustomer}"> <ListBox ItemsSource="{Binding Customers}" Grid.Row="0" SelectedItem="{Binding SelectedCustomer}">
<ListBox.ItemContainerStyle> <ListBox.ItemContainerStyle>
@@ -68,8 +68,9 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<UniformGrid Rows="2" Grid.Row="1"> <UniformGrid Rows="3" Grid.Row="1">
<Button Content="Edit selected" Command="{Binding UpdateCustomerCommand}"/> <Button Content="Edit selected" Command="{Binding UpdateCustomerCommand}"/>
<Button Content="Delete selected" Command="{Binding DeleteCustomerCommand}"/>
<Button Content="Create new" Click="CreateNewCustomer" /> <Button Content="Create new" Click="CreateNewCustomer" />
</UniformGrid> </UniformGrid>
</Grid> </Grid>

View File

@@ -64,10 +64,11 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<UniformGrid Rows="3" Grid.Row="1"> <UniformGrid Rows="2" Grid.Row="1">
<Button Content="Edit selected" Command="{Binding UpdateMaintainerTeamCommand}"/> <Button Content="Edit selected" Command="{Binding UpdateMaintainerTeamCommand}"/>
<Button Content="Create new" Click="CreateNewMaintainerTeam" /> <Button Content="Delete selected" Command="{Binding DeleteMaintainerTeamCommand}"/>
<Button Content="Who works in this team" Command="{Binding GetColleaguesCommand}" /> <Button Content="Who works in this team" Command="{Binding GetColleaguesCommand}" />
<Button Content="Create new" Click="CreateNewMaintainerTeam" />
</UniformGrid> </UniformGrid>
</Grid> </Grid>
</Window> </Window>

View File

@@ -86,11 +86,11 @@
<UniformGrid Rows="3" Grid.Row="1"> <UniformGrid Rows="3" Grid.Row="1">
<Button Content="Edit selected" Command="{Binding UpdateServiceCommand}"/> <Button Content="Edit selected" Command="{Binding UpdateServiceCommand}"/>
<Button Content="Create new" Click="CreateNewService" />
<Button Content="Delete selected" Command="{Binding DeleteServiceCommand}"/> <Button Content="Delete selected" Command="{Binding DeleteServiceCommand}"/>
<Button Content="Get responsible employee" Command="{Binding GetResponsibleEmployeeCommand}"/> <Button Content="Get responsible employee" Command="{Binding GetResponsibleEmployeeCommand}"/>
<Button Content="Get all maintainers" Command="{Binding GetMaintainersCommand}"/> <Button Content="Get all maintainers" Command="{Binding GetMaintainersCommand}"/>
<Button Content="Who uses this service" Command="{Binding GetUserCommand}"/> <Button Content="Who uses this service" Command="{Binding GetUserCommand}"/>
<Button Content="Create new" Click="CreateNewService" />
</UniformGrid> </UniformGrid>
</Grid> </Grid>
</Window> </Window>