Added flag-type editing to participant type, allowing participant to include several types
This commit is contained in:
parent
383f6a38c7
commit
6e764aa043
@ -4,6 +4,7 @@
|
||||
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="Bremen calling admin editor" Height="650" Width="800" Icon="Resources/lock_preferences.ico" Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
@ -66,7 +67,7 @@
|
||||
<TextBox x:Name="textBoxParticipantPostalCode" Grid.Row="2" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxParticipantCity" Grid.Row="3" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<CheckBox x:Name="checkboxParticipantActive" Grid.Row="4" Grid.Column="2" VerticalAlignment="Center" />
|
||||
<ComboBox x:Name="comboBoxParticipantType" Grid.Row="5" Grid.Column="2" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
|
||||
<xctk:CheckComboBox x:Name="comboBoxParticipantType" Grid.Row="5" Grid.Column="2" Margin="2" SelectedValue="Key" DisplayMemberPath="Value" />
|
||||
<TextBox x:Name="textBoxParticipantCreated" Grid.Row="6" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxParticipantModified" Grid.Row="7" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<Button x:Name="buttonParticipantSave" Grid.Row="8" Grid.Column="2" Click="buttonParticipantSave_Click" Margin="2">
|
||||
|
||||
@ -209,7 +209,18 @@ namespace RoleEditor
|
||||
p.Street = this.textBoxParticipantStreet.Text.Trim();
|
||||
p.PostalCode = this.textBoxParticipantPostalCode.Text.Trim();
|
||||
p.City = this.textBoxParticipantCity.Text.Trim();
|
||||
p.Type = (Participant.ParticipantType) Enum.Parse(typeof(Participant.ParticipantType), (string) this.comboBoxParticipantType.SelectedValue);
|
||||
|
||||
p.Type = 0;
|
||||
for(int i = 0; i < this.comboBoxParticipantType?.SelectedItems.Count; i++)
|
||||
{
|
||||
object? v = this.comboBoxParticipantType?.SelectedItems[i];
|
||||
if (v != null)
|
||||
{
|
||||
KeyValuePair<string, string> kvp = (KeyValuePair<string, string>)v;
|
||||
Participant.ParticipantType pType = (Participant.ParticipantType)Enum.Parse(typeof(Participant.ParticipantType), kvp.Key);
|
||||
p.SetFlag(true, pType);
|
||||
}
|
||||
}
|
||||
await p.Save(_dbManager);
|
||||
this.listBoxParticipant.ItemsSource = null;
|
||||
this.listBoxParticipant.ItemsSource = _participants;
|
||||
@ -357,7 +368,7 @@ namespace RoleEditor
|
||||
|
||||
private async void listBoxParticipant_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Participant? p = this.listBoxParticipant.SelectedItem as Participant;
|
||||
Participant? p = this.listBoxParticipant.SelectedItem as Participant;
|
||||
|
||||
this.textBoxParticipantName.Text = (p != null) ? p.Name : string.Empty;
|
||||
this.textBoxParticipantStreet.Text = (p != null) ? p.Street : string.Empty;
|
||||
@ -366,8 +377,24 @@ namespace RoleEditor
|
||||
// this.checkboxParticipantActive.Checked = (p != null) ? p.
|
||||
this.textBoxParticipantCreated.Text = (p != null) ? p.Created.ToString() : string.Empty;
|
||||
this.textBoxParticipantModified.Text = (p != null) ? p.Modified.ToString() : string.Empty;
|
||||
this.comboBoxParticipantType.SelectedValue = (p != null) ? p.Type : 0;
|
||||
|
||||
this.comboBoxParticipantType.SelectedItems.Clear();
|
||||
if (p != null)
|
||||
{
|
||||
foreach (Participant.ParticipantType pType in Enum.GetValues(typeof(Participant.ParticipantType)))
|
||||
{
|
||||
if (p.IsFlagSet(pType))
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in this.comboBoxParticipantType.Items)
|
||||
{
|
||||
if (kvp.Key.Equals(pType.ToString()))
|
||||
{
|
||||
this.comboBoxParticipantType.SelectedItems.Add(kvp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// -> load users for this participant selection
|
||||
this._users.Clear();
|
||||
if (p != null)
|
||||
@ -556,7 +583,7 @@ namespace RoleEditor
|
||||
|
||||
#endregion
|
||||
|
||||
#region private static helper
|
||||
#region private static helper
|
||||
|
||||
private static BitmapImage? LoadImage(byte[] imageData)
|
||||
{
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// Copyright (c) 2023- schick Informatik
|
||||
// Description: Container for participants (Teilnehmer)
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace brecal.model
|
||||
{
|
||||
@ -46,7 +43,7 @@ namespace brecal.model
|
||||
|
||||
public string? City { get; set; }
|
||||
|
||||
public ParticipantType Type { get; set;}
|
||||
public uint Type { get; set;}
|
||||
|
||||
public uint Flags { get; set; }
|
||||
|
||||
@ -74,7 +71,7 @@ namespace brecal.model
|
||||
if (!reader.IsDBNull(2)) p.Street = reader.GetString(2);
|
||||
if (!reader.IsDBNull(3)) p.PostalCode = reader.GetString(3);
|
||||
if (!reader.IsDBNull(4)) p.City = reader.GetString(4);
|
||||
if (!reader.IsDBNull(5)) p.Type = (ParticipantType) reader.GetInt32(5);
|
||||
if (!reader.IsDBNull(5)) p.Type = (uint) reader.GetInt32(5);
|
||||
if (!reader.IsDBNull(6)) p.Flags = (uint)reader.GetInt32(6);
|
||||
if (!reader.IsDBNull(7)) p.Created = reader.GetDateTime(7);
|
||||
if (!reader.IsDBNull(8)) p.Modified = reader.GetDateTime(8);
|
||||
@ -100,7 +97,7 @@ namespace brecal.model
|
||||
|
||||
public override void SetCreate(IDbCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "INSERT INTO participant (name, street, postal_code, city, flags) VALUES ( @NAME, @STREET, @POSTAL_CODE, @CITY, @TYPE, @FLAGS)";
|
||||
cmd.CommandText = "INSERT INTO participant (name, street, postal_code, city, type, flags) VALUES ( @NAME, @STREET, @POSTAL_CODE, @CITY, @TYPE, @FLAGS)";
|
||||
this.SetParameters(cmd);
|
||||
}
|
||||
|
||||
@ -171,13 +168,13 @@ namespace brecal.model
|
||||
|
||||
public bool IsFlagSet(ParticipantType flag)
|
||||
{
|
||||
return (this.Flags & (uint)flag) != 0;
|
||||
return (this.Type & (uint)flag) != 0;
|
||||
}
|
||||
|
||||
public void SetFlag(bool value, ParticipantType flag)
|
||||
{
|
||||
if (value) this.Flags |= (uint)flag;
|
||||
else this.Flags &= (uint)~flag;
|
||||
if (value) this.Type |= (uint)flag;
|
||||
else this.Type &= (uint)~flag;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
15
src/brecal.model/brecal.model.licenseheader
Normal file
15
src/brecal.model/brecal.model.licenseheader
Normal file
@ -0,0 +1,15 @@
|
||||
extensions: designer.cs generated.cs
|
||||
extensions: .cs .cpp .h
|
||||
// Copyright (c) 2023- schick Informatik
|
||||
// Description:
|
||||
|
||||
extensions: .aspx .ascx
|
||||
<%--
|
||||
Copyright (c) 2023- schick Informatik
|
||||
--%>
|
||||
extensions: .vb
|
||||
'Sample license text.
|
||||
extensions: .xml .config .xsd
|
||||
<!--
|
||||
Sample license text.
|
||||
-->
|
||||
Reference in New Issue
Block a user