fixed some bugs in the dialog, but still cannot save a ship
This commit is contained in:
parent
86b2380cb2
commit
722ea94ae0
1385
misc/BreCalApi.cs
1385
misc/BreCalApi.cs
File diff suppressed because it is too large
Load Diff
@ -531,7 +531,7 @@ components:
|
|||||||
nullable: true
|
nullable: true
|
||||||
draft:
|
draft:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: double
|
||||||
nullable: true
|
nullable: true
|
||||||
tidal_window_from:
|
tidal_window_from:
|
||||||
type: string
|
type: string
|
||||||
@ -733,11 +733,11 @@ components:
|
|||||||
description: Optional reference to participant (tug role)
|
description: Optional reference to participant (tug role)
|
||||||
length:
|
length:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: double
|
||||||
nullable: true
|
nullable: true
|
||||||
width:
|
width:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: double
|
||||||
nullable: true
|
nullable: true
|
||||||
is_tug:
|
is_tug:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|||||||
@ -4,9 +4,11 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:BreCalClient"
|
xmlns:local="clr-namespace:BreCalClient"
|
||||||
|
xmlns:p = "clr-namespace:BreCalClient.Resources"
|
||||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}"
|
mc:Ignorable="d"
|
||||||
Title="Edit ship" Height="250" Width="500" Loaded="buttonOK_Click">
|
Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}"
|
||||||
|
Title="{x:Static p:Resources.textEditShip}" Height="250" Width="500" Loaded="Window_Loaded" ResizeMode="NoResize">
|
||||||
<Grid x:Name="shipGrid">
|
<Grid x:Name="shipGrid">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width=".3*" />
|
<ColumnDefinition Width=".3*" />
|
||||||
@ -24,27 +26,27 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Label Content="Name" HorizontalAlignment="Right" />
|
<Label Content="Name" HorizontalAlignment="Right" />
|
||||||
<TextBox x:Name="textBoxName" Grid.Column="1" Margin="2" VerticalContentAlignment="Center" Text="{Binding Name, Mode=OneWay}" />
|
<TextBox x:Name="textBoxName" Grid.Column="1" Margin="2" VerticalContentAlignment="Center" Text="{Binding Name, Mode=OneWay}" />
|
||||||
<Label Content="Participant / Tug company" HorizontalAlignment="Right" Grid.Row="1" />
|
<Label Content="{x:Static p:Resources.textTugCompany}" HorizontalAlignment="Right" Grid.Row="1" />
|
||||||
<Grid Grid.Row="1" Grid.Column="1">
|
<Grid Grid.Row="1" Grid.Column="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="28" />
|
<ColumnDefinition Width="28" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ComboBox x:Name="comboBoxParticipants" Margin="2" SelectedItem="{Binding Participant, Mode=OneWay}" />
|
<ComboBox x:Name="comboBoxParticipants" Margin="2" DisplayMemberPath="Name" />
|
||||||
<Button x:Name="buttonResetParticipant" Grid.Column="1" Margin="2" Click="buttonResetParticipant_Click">
|
<Button x:Name="buttonResetParticipant" Grid.Column="1" Margin="2" Click="buttonResetParticipant_Click">
|
||||||
<Image Source="./Resources/delete2.png"/>
|
<Image Source="./Resources/delete2.png"/>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Label Content="IMO" HorizontalAlignment="Right" Grid.Row="2" />
|
<Label Content="IMO" HorizontalAlignment="Right" Grid.Row="2" />
|
||||||
<xctk:IntegerUpDown Name="integerUpDownIMO" Grid.Column="1" Grid.Row="2" Value="{Binding IMO, Mode=OneWay}" Margin="2" Minimum="1000000" Maximum="9999999" ShowButtonSpinner="False"/>
|
<xctk:IntegerUpDown Name="integerUpDownIMO" Grid.Column="1" Grid.Row="2" Value="{Binding Imo, Mode=OneWay}" Margin="2" Minimum="1000000" Maximum="9999999" ShowButtonSpinner="False"/>
|
||||||
<Label Content="Callsign" HorizontalAlignment="Right" Grid.Row="3" />
|
<Label Content="{x:Static p:Resources.textCallsign}" HorizontalAlignment="Right" Grid.Row="3" />
|
||||||
<TextBox x:Name="textBoxCallsign" Grid.Column="1" Grid.Row="3" Margin="2" VerticalContentAlignment="Center" Text="{Binding Callsign, Mode=OneWay}" />
|
<TextBox x:Name="textBoxCallsign" Grid.Column="1" Grid.Row="3" Margin="2" VerticalContentAlignment="Center" Text="{Binding Callsign, Mode=OneWay}" />
|
||||||
<Label Content="Length" HorizontalAlignment="Right" Grid.Row="4" />
|
<Label Content="{x:Static p:Resources.textLength}" HorizontalAlignment="Right" Grid.Row="4" />
|
||||||
<xctk:DoubleUpDown Name="doubleUpDownLength" Grid.Row="4" Grid.Column="1" Value="{Binding Length, Mode=OneWay}" Margin="2" Minimum="0" />
|
<xctk:DoubleUpDown Name="doubleUpDownLength" Grid.Row="4" Grid.Column="1" Value="{Binding Length, Mode=OneWay}" Margin="2" Minimum="0" />
|
||||||
<Label Content="Width" HorizontalAlignment="Right" Grid.Row="5" />
|
<Label Content="{x:Static p:Resources.textWidth}" HorizontalAlignment="Right" Grid.Row="5" />
|
||||||
<xctk:DoubleUpDown Name="doubleUpDownWidth" Grid.Row="5" Grid.Column="1" Value="{Binding Width, Mode=OneWay}" Margin="2" Minimum="0"/>
|
<xctk:DoubleUpDown Name="doubleUpDownWidth" Grid.Row="5" Grid.Column="1" Value="{Binding Width, Mode=OneWay}" Margin="2" Minimum="0"/>
|
||||||
<StackPanel Grid.Column="1" Grid.Row="7" Orientation="Horizontal" FlowDirection="RightToLeft">
|
<StackPanel Grid.Column="1" Grid.Row="7" Orientation="Horizontal" FlowDirection="RightToLeft">
|
||||||
<Button x:Name="buttonCancel" Width="80" Content="Cancel" Margin="2" Click="buttonCancel_Click" />
|
<Button x:Name="buttonCancel" Width="80" Content="{x:Static p:Resources.textCancel}" Margin="2" Click="buttonCancel_Click" />
|
||||||
<Button x:Name="buttonOK" Width="80" Content="OK" Margin="2" Click="buttonOK_Click"/>
|
<Button x:Name="buttonOK" Width="80" Content="OK" Margin="2" Click="buttonOK_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,10 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
public EditShipDialog()
|
public EditShipDialog()
|
||||||
{
|
{
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ship Ship { get; set; } = new Ship();
|
public Ship Ship { get; set; } = new();
|
||||||
|
|
||||||
public List<Participant> Participants { get; } = new List<Participant>();
|
public List<Participant> Participants { get; } = new List<Participant>();
|
||||||
|
|
||||||
@ -27,32 +27,45 @@ namespace BreCalClient
|
|||||||
|
|
||||||
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
this.Ship.Name = this.textBoxName.Text.Trim();
|
this.Ship.Name = this.textBoxName.Text.Trim();
|
||||||
|
|
||||||
this.Ship.Participant = this.comboBoxParticipants.SelectedItem as Participant;
|
if (this.comboBoxParticipants.SelectedItem != null)
|
||||||
if (this.Ship.Participant != null)
|
{
|
||||||
this.Ship.Participant_Id = this.Ship.Participant.Id;
|
this.Ship.ParticipantId = ((Participant)this.comboBoxParticipants.SelectedItem).Id;
|
||||||
|
this.Ship.IsTug = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this.Ship.Participant_Id = null;
|
{
|
||||||
this.Ship.IMO = this.integerUpDownIMO.Value;
|
this.Ship.IsTug = false;
|
||||||
|
}
|
||||||
|
this.Ship.Imo = this.integerUpDownIMO.Value;
|
||||||
this.Ship.Callsign = this.textBoxCallsign.Text.Trim();
|
this.Ship.Callsign = this.textBoxCallsign.Text.Trim();
|
||||||
this.Ship.Length = this.doubleUpDownLength.Value;
|
this.Ship.Length = (float?) this.doubleUpDownLength.Value;
|
||||||
this.Ship.Width = this.doubleUpDownWidth.Value;
|
this.Ship.Width = (float?) this.doubleUpDownWidth.Value;
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
this.Close();
|
this.Close();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.DataContext = this.Ship;
|
this.DataContext = this.Ship;
|
||||||
// this.comboBoxParticipants.ItemsSource = this.Participants;
|
this.comboBoxParticipants.ItemsSource = this.Participants;
|
||||||
|
|
||||||
|
if(this.Ship.ParticipantId != null)
|
||||||
|
{
|
||||||
|
foreach(Participant p in this.Participants)
|
||||||
|
{
|
||||||
|
if(this.Ship.ParticipantId == p.Id)
|
||||||
|
this.comboBoxParticipants.SelectedItem = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
|
private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// this.comboBoxParticipants.SelectedItem = null;
|
this.comboBoxParticipants.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
</ComboBox.ContextMenu>
|
</ComboBox.ContextMenu>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|
||||||
<Label x:Name="labelBSMDGranted" Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" Content="{x:Static p:Resources.textBSMDGranted}" Visibility="Hidden" FontWeight="DemiBold" />
|
<Label x:Name="labelBSMDGranted" Grid.Row="5" Grid.Column="3" Grid.ColumnSpan="1" Content="{x:Static p:Resources.textBSMDGranted}" Visibility="Hidden" FontWeight="DemiBold" />
|
||||||
<StackPanel Grid.Row="6" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Grid.Row="6" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button Width= "80" Margin="2" Content="{x:Static p:Resources.textOK}" x:Name="buttonOK" Click="buttonOK_Click" IsEnabled="False" />
|
<Button Width= "80" Margin="2" Content="{x:Static p:Resources.textOK}" x:Name="buttonOK" Click="buttonOK_Click" IsEnabled="False" />
|
||||||
<Button Width="80" Margin="2" Content="{x:Static p:Resources.textCancel}" x:Name="buttonCancel" Click="buttonCancel_Click"/>
|
<Button Width="80" Margin="2" Content="{x:Static p:Resources.textCancel}" x:Name="buttonCancel" Click="buttonCancel_Click"/>
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
// Description: Windows dialog to create / edit ship calls
|
// Description: Windows dialog to create / edit ship calls
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using BreCalClient.misc.Api;
|
||||||
using BreCalClient.misc.Model;
|
using BreCalClient.misc.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -37,6 +38,8 @@ namespace BreCalClient
|
|||||||
set { this.buttonEditShips.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
|
set { this.buttonEditShips.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShipApi ShipApi { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Event handler
|
#region Event handler
|
||||||
@ -45,7 +48,7 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
this.comboBoxAgency.ItemsSource = BreCalLists.Participants_Agent;
|
this.comboBoxAgency.ItemsSource = BreCalLists.Participants_Agent;
|
||||||
|
|
||||||
this.comboBoxShip.ItemsSource = BreCalLists.Ships;
|
this.comboBoxShip.ItemsSource = BreCalLists.AllShips;
|
||||||
this.comboBoxCategories.ItemsSource = Enum.GetValues(typeof(ShipcallType));
|
this.comboBoxCategories.ItemsSource = Enum.GetValues(typeof(ShipcallType));
|
||||||
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
|
||||||
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
|
||||||
@ -351,9 +354,16 @@ namespace BreCalClient
|
|||||||
|
|
||||||
private void buttonEditShips_Click(object sender, RoutedEventArgs e)
|
private void buttonEditShips_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ShipListDialog shipListDialog = new ShipListDialog();
|
ShipListDialog shipListDialog = new()
|
||||||
|
{
|
||||||
|
ShipApi = this.ShipApi
|
||||||
|
};
|
||||||
|
|
||||||
shipListDialog.ShowDialog();
|
shipListDialog.ShowDialog();
|
||||||
|
|
||||||
|
// reload combobox
|
||||||
|
this.comboBoxShip.ItemsSource = null;
|
||||||
|
this.comboBoxShip.ItemsSource = BreCalLists.AllShips;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -209,7 +209,8 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
EditShipcallControl esc = new()
|
EditShipcallControl esc = new()
|
||||||
{
|
{
|
||||||
ShipEditingEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD)
|
ShipEditingEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD),
|
||||||
|
ShipApi = _shipApi
|
||||||
};
|
};
|
||||||
if (model != null)
|
if (model != null)
|
||||||
esc.ShipcallModel = model;
|
esc.ShipcallModel = model;
|
||||||
@ -666,6 +667,7 @@ namespace BreCalClient
|
|||||||
EditShipcallControl esc = new()
|
EditShipcallControl esc = new()
|
||||||
{
|
{
|
||||||
ShipcallModel = obj.ShipcallControlModel,
|
ShipcallModel = obj.ShipcallControlModel,
|
||||||
|
ShipApi = _shipApi,
|
||||||
ShipEditingEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD)
|
ShipEditingEnabled = App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
9
src/BreCalClient/Resources/Resources.Designer.cs
generated
9
src/BreCalClient/Resources/Resources.Designer.cs
generated
@ -483,6 +483,15 @@ namespace BreCalClient.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Edit ship.
|
||||||
|
/// </summary>
|
||||||
|
public static string textEditShip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("textEditShip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Edit ship call.
|
/// Looks up a localized string similar to Edit ship call.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -442,6 +442,9 @@
|
|||||||
<data name="textDeleted" xml:space="preserve">
|
<data name="textDeleted" xml:space="preserve">
|
||||||
<value>Gelöscht</value>
|
<value>Gelöscht</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="textEditShip" xml:space="preserve">
|
||||||
|
<value>Schiff bearbeiten</value>
|
||||||
|
</data>
|
||||||
<data name="textTugCompany" xml:space="preserve">
|
<data name="textTugCompany" xml:space="preserve">
|
||||||
<value>Schlepper-Reederei</value>
|
<value>Schlepper-Reederei</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@ -253,6 +253,9 @@
|
|||||||
<data name="textEdit" xml:space="preserve">
|
<data name="textEdit" xml:space="preserve">
|
||||||
<value>Edit</value>
|
<value>Edit</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="textEditShip" xml:space="preserve">
|
||||||
|
<value>Edit ship</value>
|
||||||
|
</data>
|
||||||
<data name="textEditShipcall" xml:space="preserve">
|
<data name="textEditShipcall" xml:space="preserve">
|
||||||
<value>Edit ship call</value>
|
<value>Edit ship call</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
xmlns:p = "clr-namespace:BreCalClient.Resources"
|
xmlns:p = "clr-namespace:BreCalClient.Resources"
|
||||||
xmlns:local="clr-namespace:BreCalClient"
|
xmlns:local="clr-namespace:BreCalClient"
|
||||||
mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}"
|
mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}"
|
||||||
Height="490" Width="800" ResizeMode="CanResize" Icon="Resources/containership.ico">
|
Height="490" Width="800" ResizeMode="CanResize" Icon="Resources/containership.ico" Loaded="Window_Loaded">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -18,22 +18,22 @@
|
|||||||
<local:ENIDataGrid.RowStyle>
|
<local:ENIDataGrid.RowStyle>
|
||||||
<Style TargetType="DataGridRow">
|
<Style TargetType="DataGridRow">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding Deleted}" Value="1">
|
<DataTrigger Binding="{Binding Ship.Deleted}" Value="1">
|
||||||
<Setter Property="Foreground" Value="DarkGray"/>
|
<Setter Property="Foreground" Value="DarkGray"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
</local:ENIDataGrid.RowStyle>
|
</local:ENIDataGrid.RowStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Id" Binding="{Binding Path=Id}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="Id" Binding="{Binding Path=Ship.Id}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="Name" Binding="{Binding Path=Ship.Name}" IsReadOnly="True"/>
|
||||||
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTug}" Binding="{Binding Path=IsTug, Mode=OneWay}" IsReadOnly="True"/>
|
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTug}" Binding="{Binding Path=Ship.IsTug, Mode=OneWay}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="{x:Static p:Resources.textTugCompany}" Binding="{Binding Path=TugCompany, Mode=OneWay}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="{x:Static p:Resources.textTugCompany}" Binding="{Binding Path=TugCompany, Mode=OneWay}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="IMO" Binding="{Binding Path=IMO}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="IMO" Binding="{Binding Path=Ship.Imo}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="{x:Static p:Resources.textCallsign}" Binding="{Binding Path=Callsign}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="{x:Static p:Resources.textCallsign}" Binding="{Binding Path=Ship.Callsign}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="{x:Static p:Resources.textLength}" Binding="{Binding Path=Length}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="{x:Static p:Resources.textLength}" Binding="{Binding Path=Ship.Length}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="{x:Static p:Resources.textWidth}" Binding="{Binding Path=Width}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="{x:Static p:Resources.textWidth}" Binding="{Binding Path=Ship.Width}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="{x:Static p:Resources.textDeleted}" Binding="{Binding Path=Deleted, Mode=OneWay}" IsReadOnly="True" />
|
<DataGridTextColumn Header="{x:Static p:Resources.textDeleted}" Binding="{Binding Path=Ship.Deleted, Mode=OneWay}" IsReadOnly="True" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</local:ENIDataGrid>
|
</local:ENIDataGrid>
|
||||||
<Button Grid.Row="1" x:Name="buttonClose" Content="{x:Static p:Resources.textClose}" HorizontalAlignment="Right" Margin="2" Click="buttonClose_Click"/>
|
<Button Grid.Row="1" x:Name="buttonClose" Content="{x:Static p:Resources.textClose}" HorizontalAlignment="Right" Margin="2" Click="buttonClose_Click"/>
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
using System;
|
// Copyright (c) 2023 schick Informatik
|
||||||
using System.Collections.Generic;
|
// Description: Administration screen for ships
|
||||||
using System.Linq;
|
//
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
using BreCalClient.misc.Api;
|
||||||
|
using BreCalClient.misc.Model;
|
||||||
|
using System;
|
||||||
using System.Windows;
|
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;
|
|
||||||
|
|
||||||
namespace BreCalClient
|
namespace BreCalClient
|
||||||
{
|
{
|
||||||
@ -24,9 +20,97 @@ namespace BreCalClient
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public ShipApi? ShipApi { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event handler
|
||||||
|
|
||||||
private void buttonClose_Click(object sender, RoutedEventArgs e)
|
private void buttonClose_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.dataGridShips.Initialize();
|
||||||
|
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||||
|
|
||||||
|
this.dataGridShips.CreateRequested += DataGridShips_CreateRequested; ;
|
||||||
|
this.dataGridShips.EditRequested += DataGridShips_EditRequested;
|
||||||
|
this.dataGridShips.DeleteRequested += DataGridShips_DeleteRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void DataGridShips_DeleteRequested(object obj)
|
||||||
|
{
|
||||||
|
if (obj is ShipModel shipmodel)
|
||||||
|
{
|
||||||
|
if(this.ShipApi != null)
|
||||||
|
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
|
||||||
|
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
|
||||||
|
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void DataGridShips_EditRequested(object obj)
|
||||||
|
{
|
||||||
|
if (obj is ShipModel shipmodel)
|
||||||
|
{
|
||||||
|
EditShipDialog esd = new()
|
||||||
|
{
|
||||||
|
Ship = shipmodel.Ship
|
||||||
|
};
|
||||||
|
esd.Participants.AddRange(BreCalLists.Participants_Tug);
|
||||||
|
|
||||||
|
if (esd.ShowDialog() ?? false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (this.ShipApi != null)
|
||||||
|
{
|
||||||
|
Id tmpId = await this.ShipApi.ShipUpdateAsync(shipmodel.Ship);
|
||||||
|
}
|
||||||
|
this.dataGridShips.ItemsSource = null;
|
||||||
|
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridShips_CreateRequested()
|
||||||
|
{
|
||||||
|
ShipModel shipModel = new ShipModel(new Ship());
|
||||||
|
EditShipDialog esd = new()
|
||||||
|
{
|
||||||
|
Ship = shipModel.Ship
|
||||||
|
};
|
||||||
|
esd.Participants.AddRange(BreCalLists.Participants_Tug);
|
||||||
|
|
||||||
|
if(esd.ShowDialog() ?? false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.ShipApi?.ShipsCreateAsync(shipModel.Ship);
|
||||||
|
this.dataGridShips.ItemsSource = null;
|
||||||
|
BreCalLists.AllShips.Add(shipModel);
|
||||||
|
BreCalLists.Ships.Add(shipModel);
|
||||||
|
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,16 @@ namespace BreCalClient
|
|||||||
|
|
||||||
public Ship Ship { get; private set; }
|
public Ship Ship { get; private set; }
|
||||||
|
|
||||||
|
public string TugCompany
|
||||||
|
{
|
||||||
|
get { if(this.Ship.ParticipantId.HasValue)
|
||||||
|
{
|
||||||
|
return BreCalLists.ParticipantLookupDict[this.Ship.ParticipantId.Value].Name;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("{0} ({1})", this.Ship.Name, this.Ship.Imo);
|
return String.Format("{0} ({1})", this.Ship.Name, this.Ship.Imo);
|
||||||
|
|||||||
Reference in New Issue
Block a user