Logical delete of berths and ships in RoleEditor.
The deleted rows will still be shown however a little grayed out
This commit is contained in:
parent
ba424b18b0
commit
378274a176
@ -260,12 +260,23 @@
|
||||
<Button Content="Import excel" Margin="2" x:Name="buttonImportBerths" Click="buttonImportBerths_Click" Width="100" HorizontalAlignment="Left" Grid.Row="0"/>
|
||||
<local:ENIDataGrid x:Name="dataGridBerths" Grid.Row="1" SelectionMode="Single" IsReadOnly="True" AlternatingRowBackground="LightBlue" AutoGenerateColumns="False"
|
||||
CanUserAddRows="False" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
||||
<local:ENIDataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Deleted}" Value="1">
|
||||
<Setter Property="Foreground" Value="DarkGray"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</local:ENIDataGrid.RowStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Id" Binding="{Binding Path=Id}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" IsReadOnly="True"/>
|
||||
<DataGridCheckBoxColumn Header="Lock" Binding="{Binding Path=Lock}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Terminal" Binding="{Binding Path=Terminal, Mode=OneWay}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Authority" Binding="{Binding Path=Authority_Text, Mode=OneWay}" IsReadOnly="True" />
|
||||
<DataGridTextColumn Header="Deleted" Binding="{Binding Path=Deleted, Mode=OneWay}" IsReadOnly="True" />
|
||||
</DataGrid.Columns>
|
||||
</local:ENIDataGrid>
|
||||
</Grid>
|
||||
@ -279,6 +290,15 @@
|
||||
<Button Content="Import excel" Margin="2" x:Name="buttonImportShipss" Click="buttonImportShipss_Click" Width="100" HorizontalAlignment="Left" Grid.Row="0"/>
|
||||
<local:ENIDataGrid x:Name="dataGridShips" Grid.Row="1" SelectionMode="Single" IsReadOnly="True" AlternatingRowBackground="LightBlue" AutoGenerateColumns="False"
|
||||
CanUserAddRows="False" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
||||
<local:ENIDataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Deleted}" Value="1">
|
||||
<Setter Property="Foreground" Value="DarkGray"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</local:ENIDataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Id" Binding="{Binding Path=Id}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" IsReadOnly="True"/>
|
||||
@ -288,6 +308,7 @@
|
||||
<DataGridTextColumn Header="Callsign" Binding="{Binding Path=Callsign}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Length" Binding="{Binding Path=Length}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Width" Binding="{Binding Path=Width}" IsReadOnly="True"/>
|
||||
<DataGridTextColumn Header="Deleted" Binding="{Binding Path=Deleted, Mode=OneWay}" IsReadOnly="True" />
|
||||
</DataGrid.Columns>
|
||||
</local:ENIDataGrid>
|
||||
</Grid>
|
||||
|
||||
@ -131,11 +131,14 @@ namespace RoleEditor
|
||||
|
||||
#region ship context menu callbacks
|
||||
|
||||
private void DataGridShips_DeleteRequested(DbEntity obj)
|
||||
private async void DataGridShips_DeleteRequested(DbEntity obj)
|
||||
{
|
||||
if (obj is Ship s)
|
||||
{
|
||||
await s.Delete(this._dbManager);
|
||||
this._ships.Remove(s);
|
||||
}
|
||||
}
|
||||
|
||||
private async void DataGridShips_EditRequested(DbEntity obj)
|
||||
{
|
||||
@ -172,11 +175,14 @@ namespace RoleEditor
|
||||
|
||||
#region berth context menu callbacks
|
||||
|
||||
private void DataGridBerths_DeleteRequested(DbEntity obj)
|
||||
private async void DataGridBerths_DeleteRequested(DbEntity obj)
|
||||
{
|
||||
if (obj is Berth b)
|
||||
{
|
||||
await b.Delete(this._dbManager);
|
||||
this._berths.Remove(b);
|
||||
}
|
||||
}
|
||||
|
||||
private async void DataGridBerths_EditRequested(DbEntity obj)
|
||||
{
|
||||
|
||||
@ -31,6 +31,8 @@ namespace brecal.model
|
||||
|
||||
public string? Authority_Text { get { if (Authority != null) return Authority.Name; else return "n/a"; } }
|
||||
|
||||
public int? Deleted { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region public static methods
|
||||
@ -46,7 +48,7 @@ namespace brecal.model
|
||||
|
||||
public static void SetLoadQuery(IDbCommand cmd, params object?[] list)
|
||||
{
|
||||
cmd.CommandText = "SELECT id, name, owner_id, authority_id, `lock`, created, modified FROM berth";
|
||||
cmd.CommandText = "SELECT id, name, owner_id, authority_id, `lock`, created, modified, deleted FROM berth";
|
||||
}
|
||||
|
||||
public static List<DbEntity> LoadElems(IDataReader reader)
|
||||
@ -62,6 +64,7 @@ namespace brecal.model
|
||||
if (!reader.IsDBNull(4)) b.Lock = reader.GetBoolean(4);
|
||||
if (!reader.IsDBNull(5)) b.Created = reader.GetDateTime(5);
|
||||
if (!reader.IsDBNull(6)) b.Modified = reader.GetDateTime(6);
|
||||
if (!reader.IsDBNull(7)) b.Deleted = reader.GetInt16(7);
|
||||
result.Add(b);
|
||||
}
|
||||
return result;
|
||||
@ -79,7 +82,7 @@ namespace brecal.model
|
||||
|
||||
public override void SetDelete(IDbCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "DELETE FROM berth WHERE id = @ID";
|
||||
cmd.CommandText = "UPDATE berth set Deleted = 1 WHERE id = @ID";
|
||||
|
||||
IDataParameter idParam = cmd.CreateParameter();
|
||||
idParam.ParameterName = "ID";
|
||||
|
||||
@ -26,6 +26,8 @@ namespace brecal.model
|
||||
|
||||
public double? Width { get; set; }
|
||||
|
||||
public int? Deleted { get; set; }
|
||||
|
||||
public bool IsTug { get { return Participant_Id != null; } }
|
||||
|
||||
public string? TugCompany
|
||||
@ -48,7 +50,7 @@ namespace brecal.model
|
||||
|
||||
public static void SetLoadQuery(IDbCommand cmd, params object?[] list)
|
||||
{
|
||||
cmd.CommandText = "SELECT id, name, imo, callsign, participant_id, length, width, created, modified FROM ship";
|
||||
cmd.CommandText = "SELECT id, name, imo, callsign, participant_id, length, width, created, modified, deleted FROM ship";
|
||||
}
|
||||
|
||||
public static List<DbEntity> LoadElems(IDataReader reader)
|
||||
@ -66,6 +68,7 @@ namespace brecal.model
|
||||
if (!reader.IsDBNull(6)) s.Width = reader.GetFloat(6);
|
||||
if (!reader.IsDBNull(7)) s.Created = reader.GetDateTime(7);
|
||||
if (!reader.IsDBNull(8)) s.Modified = reader.GetDateTime(8);
|
||||
if (!reader.IsDBNull(9)) s.Deleted = reader.GetInt16(9);
|
||||
result.Add(s);
|
||||
}
|
||||
return result;
|
||||
@ -83,7 +86,7 @@ namespace brecal.model
|
||||
|
||||
public override void SetDelete(IDbCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "DELETE FROM ship WHERE id = @ID";
|
||||
cmd.CommandText = "UPDATE ship set Deleted = 1 WHERE id = @ID";
|
||||
|
||||
IDataParameter idParam = cmd.CreateParameter();
|
||||
idParam.ParameterName = "ID";
|
||||
|
||||
Reference in New Issue
Block a user