diff --git a/src/RoleEditor/EditBerthDialog.xaml b/src/RoleEditor/EditBerthDialog.xaml
index d143baf..78ef683 100644
--- a/src/RoleEditor/EditBerthDialog.xaml
+++ b/src/RoleEditor/EditBerthDialog.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoleEditor"
mc:Ignorable="d"
- Title="Edit berth" Height="150" Width="450" Loaded="Window_Loaded">
+ Title="Edit berth" Height="160" Width="450" Loaded="Window_Loaded">
@@ -19,11 +19,20 @@
-
+
-
+
+
+
+
+
+
+
+
-
+
diff --git a/src/RoleEditor/EditBerthDialog.xaml.cs b/src/RoleEditor/EditBerthDialog.xaml.cs
index a8648aa..41cf0ad 100644
--- a/src/RoleEditor/EditBerthDialog.xaml.cs
+++ b/src/RoleEditor/EditBerthDialog.xaml.cs
@@ -1,17 +1,6 @@
using brecal.model;
-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;
namespace RoleEditor
{
@@ -27,6 +16,8 @@ namespace RoleEditor
public Berth Berth { get; set; } = new Berth();
+ public List Participants { get; } = new List();
+
private void buttonCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
@@ -38,8 +29,10 @@ namespace RoleEditor
this.Berth.Name = this.textBoxName.Text.Trim();
this.Berth.Lock = this.checkBoxLock.IsChecked;
this.Berth.Participant = this.comboBoxParticipants.SelectedItem as Participant;
- if(this.Berth.Participant != null)
+ if (this.Berth.Participant != null)
this.Berth.Participant_Id = this.Berth.Participant.Id;
+ else
+ this.Berth.Participant_Id = null;
this.DialogResult = true;
this.Close();
}
@@ -47,6 +40,12 @@ namespace RoleEditor
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.DataContext = this.Berth;
+ this.comboBoxParticipants.ItemsSource = this.Participants;
+ }
+
+ private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxParticipants.SelectedItem = null;
}
}
}
diff --git a/src/RoleEditor/EditShipDialog.xaml b/src/RoleEditor/EditShipDialog.xaml
index b389a7a..c29a5a3 100644
--- a/src/RoleEditor/EditShipDialog.xaml
+++ b/src/RoleEditor/EditShipDialog.xaml
@@ -4,9 +4,49 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoleEditor"
+ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
- Title="Edit ship" Height="450" Width="800">
-
+ Title="Edit ship" Height="250" Width="500" Loaded="Window_Loaded">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/RoleEditor/EditShipDialog.xaml.cs b/src/RoleEditor/EditShipDialog.xaml.cs
index f018e6e..2bab982 100644
--- a/src/RoleEditor/EditShipDialog.xaml.cs
+++ b/src/RoleEditor/EditShipDialog.xaml.cs
@@ -1,16 +1,6 @@
-using System;
+using brecal.model;
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;
namespace RoleEditor
{
@@ -23,5 +13,43 @@ namespace RoleEditor
{
InitializeComponent();
}
+
+ public Ship Ship { get; set; } = new Ship();
+
+ public List Participants { get; } = new List();
+
+ private void buttonCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+
+ private void buttonOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.Ship.Name = this.textBoxName.Text.Trim();
+
+ this.Ship.Participant = this.comboBoxParticipants.SelectedItem as Participant;
+ if (this.Ship.Participant != null)
+ this.Ship.Participant_Id = this.Ship.Participant.Id;
+ else
+ this.Ship.Participant_Id = null;
+ this.Ship.IMO = this.integerUpDownIMO.Value;
+ this.Ship.Callsign = this.textBoxCallsign.Text.Trim();
+ this.Ship.Length = this.doubleUpDownLength.Value;
+ this.Ship.Width = this.doubleUpDownWidth.Value;
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.DataContext = this.Ship;
+ this.comboBoxParticipants.ItemsSource = this.Participants;
+ }
+
+ private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxParticipants.SelectedItem = null;
+ }
}
}
diff --git a/src/RoleEditor/MainWindow.xaml b/src/RoleEditor/MainWindow.xaml
index ca78039..ad6e5d9 100644
--- a/src/RoleEditor/MainWindow.xaml
+++ b/src/RoleEditor/MainWindow.xaml
@@ -170,10 +170,10 @@
@@ -222,10 +222,10 @@
@@ -249,10 +249,10 @@
-
-
-
-
+
+
+
+
@@ -267,14 +267,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/RoleEditor/MainWindow.xaml.cs b/src/RoleEditor/MainWindow.xaml.cs
index 99f9b1a..1582448 100644
--- a/src/RoleEditor/MainWindow.xaml.cs
+++ b/src/RoleEditor/MainWindow.xaml.cs
@@ -119,17 +119,35 @@ namespace RoleEditor
this._ships.Remove(s);
}
- private void DataGridShips_EditRequested(DbEntity obj)
+ private async void DataGridShips_EditRequested(DbEntity obj)
{
if(obj is Ship s)
{
-
+ EditShipDialog esd = new();
+ esd.Ship = s;
+ esd.Participants.AddRange(this._participants);
+ if (esd.ShowDialog() ?? false)
+ {
+ await s.Save(_dbManager);
+ this.dataGridShips.ItemsSource = null;
+ this.dataGridShips.ItemsSource = _ships;
+ }
}
}
- private void DataGridShips_CreateRequested()
+ private async void DataGridShips_CreateRequested()
{
- Ship s = new Ship();
+ Ship s = new();
+ EditShipDialog esd = new();
+ esd.Ship = s;
+ esd.Participants.AddRange(this._participants);
+ if(esd.ShowDialog() ?? false)
+ {
+ _ships.Add(s);
+ await s.Save(_dbManager);
+ this.dataGridShips.ItemsSource = null;
+ this.dataGridShips.ItemsSource = _ships;
+ }
}
#endregion
@@ -146,22 +164,30 @@ namespace RoleEditor
{
if(obj is Berth b)
{
- EditBerthDialog ebd = new EditBerthDialog();
+ EditBerthDialog ebd = new();
ebd.Berth = b;
+ ebd.Participants.AddRange(this._participants);
if (ebd.ShowDialog() ?? false)
+ {
await b.Save(_dbManager);
+ this.dataGridBerths.ItemsSource = null; // extreme stupidity for me not wanting to implement INotifyPropertyChanged
+ this.dataGridBerths.ItemsSource = _berths;
+ }
}
}
private async void DataGridBerths_CreateRequested()
{
- Berth b = new Berth();
- EditBerthDialog ebd = new EditBerthDialog();
+ Berth b = new();
+ EditBerthDialog ebd = new();
ebd.Berth = b;
- if(ebd.ShowDialog() ?? false)
+ ebd.Participants.AddRange(this._participants);
+ if (ebd.ShowDialog() ?? false)
{
_berths.Add(b);
await b.Save(_dbManager);
+ this.dataGridBerths.ItemsSource = null;
+ this.dataGridBerths.ItemsSource = _berths;
}
}
diff --git a/src/RoleEditor/RoleEditor.csproj b/src/RoleEditor/RoleEditor.csproj
index 8cede2c..24a3f9e 100644
--- a/src/RoleEditor/RoleEditor.csproj
+++ b/src/RoleEditor/RoleEditor.csproj
@@ -26,6 +26,10 @@
+
+
+
+
diff --git a/src/brecal.model/Ship.cs b/src/brecal.model/Ship.cs
index 5800ca2..ba0d73b 100644
--- a/src/brecal.model/Ship.cs
+++ b/src/brecal.model/Ship.cs
@@ -93,7 +93,7 @@ namespace brecal.model
public override void SetUpdate(IDbCommand cmd)
{
- cmd.CommandText = "UPDATE ship SET name = @NAME, imo = @IMO, callsign = @CALLSIGN, participant_id = @PID, length = @LENGTH, widht = @WIDTH WHERE id = @ID";
+ cmd.CommandText = "UPDATE ship SET name = @NAME, imo = @IMO, callsign = @CALLSIGN, participant_id = @PID, length = @LENGTH, width = @WIDTH WHERE id = @ID";
this.SetParameters(cmd);
}