[chore:] added CSV-Separator Settings.cs

This commit is contained in:
Elias Fierke
2025-10-09 08:39:49 +02:00
parent 4ee852b37c
commit 316c9511d3
3 changed files with 34 additions and 0 deletions

View File

@@ -248,6 +248,13 @@
TextChanged="TbSettingsCustomerDescription_OnTextChanged"
x:Name="TbSettingsCustomerDescription" />
</Grid>
<Grid ColumnDefinitions="150,*">
<Label Content="CSV-Trennzeichen" />
<TextBox Grid.Column="1" Watermark=","
HorizontalAlignment="Stretch"
TextChanged="TbSettingsCustomerCsvSeparator_OnTextChanged"
x:Name="TbSettingsCustomerCsvSeparator" />
</Grid>
<Grid ColumnDefinitions="150,*">
<Label Content="Address-Patch-Info" />
<TextBlock Grid.Column="1"

View File

@@ -230,6 +230,7 @@ public partial class MainWindow : Window
private void TbSettingsCustomerName_OnTextChanged(object? sender, TextChangedEventArgs e)
{
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
foreach (var customer in Settings._instance.customers.customers)
if (customer.ID == Settings._instance.customers.current)
customer.name = TbSettingsCustomerName.Text;
@@ -247,6 +248,7 @@ public partial class MainWindow : Window
{
TbSettingsCustomerDescription.Text = customer.description;
TbSettingsCustomerName.Text = customer.name;
TbSettingsCustomerCsvSeparator.Text = customer.separator.ToString();
if (customer.patch != null)
TbSettingsCustomerPatchInfo.Text = customer.patch.ToString();
else
@@ -277,6 +279,7 @@ public partial class MainWindow : Window
private void TbSettingsCustomerDescription_OnTextChanged(object? sender, TextChangedEventArgs e)
{
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
foreach (var customer in Settings._instance.customers.customers)
if (customer.ID == Settings._instance.customers.current)
customer.description = TbSettingsCustomerDescription.Text;
@@ -417,4 +420,26 @@ public partial class MainWindow : Window
Settings.Save();
}
private void TbSettingsCustomerCsvSeparator_OnTextChanged(object? sender, TextChangedEventArgs e)
{
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
var sep = !string.IsNullOrEmpty(TbSettingsCustomerCsvSeparator.Text)
? TbSettingsCustomerCsvSeparator.Text
: ",";
foreach (var customer in Settings._instance.customers.customers)
if (customer.ID == Settings._instance.customers.current)
try
{
customer.separator = Convert.ToChar(sep);
}
catch (FormatException ex)
{
MessageBox.Show(this, "Error while converting: " + ex.Message, "Could not parse");
}
catch (Exception ex)
{
MessageBox.Show(this, "Unknown Error: " + ex.Message, "Error");
}
}
}

View File

@@ -74,6 +74,7 @@ public class Global
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
"global.config"), json);
}
public static void Load()
{
// if (!File.Exists(Path.Combine(
@@ -121,6 +122,7 @@ public class Customer
public string name { get; set; } = "";
public string description { get; set; } = "";
public AddressPatch patch { get; set; }
public char separator { get; set; } = ',';
public int ID { get; }
public static int GetIDByCustomerListItem(string item_content)