diff --git a/ZKuP/AddCardUser.xaml b/ZKuP/AddCardUser.xaml
new file mode 100644
index 0000000..a15db85
--- /dev/null
+++ b/ZKuP/AddCardUser.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/AddCardUser.xaml.cs b/ZKuP/AddCardUser.xaml.cs
new file mode 100644
index 0000000..c399311
--- /dev/null
+++ b/ZKuP/AddCardUser.xaml.cs
@@ -0,0 +1,79 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für AddCardUser.xaml
+ ///
+ public partial class AddCardUser : Window
+ {
+ public AddCardUser(string user = "")
+ {
+ InitializeComponent();
+
+ tbUser.Text = user;
+
+ try
+ {
+ tbTelnr.Text = SQL.ReadSingleValue($"SELECT Tel_Nr_Verantwortlicher_Firma FROM zkup.firmen WHERE Name='{user}'");
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ private async void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ if (tbNummer.Text == "")
+ MessageBox.Show(this, "Kartennummer angeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (cbColor.SelectedIndex == -1)
+ MessageBox.Show(this, "Kartenfarbe auswählen!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (tbUser.Text == "")
+ MessageBox.Show(this, "Firma / Benutzer angeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (tbTelnr.Text == "")
+ MessageBox.Show(this, "Telefonnummer angeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ {
+ try
+ {
+ await SQL.WriteSQL($"REPLACE INTO karten (kartennr,farbe,benutzer,telnr) VALUES ('{tbNummer.Text}','{(cbColor.SelectedItem as ComboBoxItem).Content.ToString()}','{tbUser.Text}','{tbTelnr.Text}')");
+
+ MessageBox.Show(this, "Karte erfolgreich verknüpft", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information);
+
+ ResetValues();
+ //this.Close();
+ }
+ catch (MySql.Data.MySqlClient.MySqlException ex)
+ {
+ if (MessageBox.Show(this, "Beim verknüpfen der Karte ist ein Fehler aufgetreten\n\nMöchten Sie die interne Fehlermeldung anzeigen?", "Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.No) == MessageBoxResult.Yes)
+ MessageBox.Show(this, $"Fehlermeldung:\n\n{ex.Message}", "Fehlermeldung", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+ }
+
+ private void ResetValues()
+ {
+
+ tbNummer.Text = "";
+ tbTelnr.Text = "";
+
+ }
+
+ private void tbUser_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if (tbUser.Text.Length >= 254) e.Handled = true;
+ }
+ }
+}
diff --git a/ZKuP/App.config b/ZKuP/App.config
new file mode 100644
index 0000000..0b6a8eb
--- /dev/null
+++ b/ZKuP/App.config
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 747
+
+
+ 1624
+
+
+ 100
+
+
+ 100
+
+
+ 300
+
+
+ Normal
+
+
+ False
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/App.xaml b/ZKuP/App.xaml
new file mode 100644
index 0000000..7f280ef
--- /dev/null
+++ b/ZKuP/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/ZKuP/App.xaml.cs b/ZKuP/App.xaml.cs
new file mode 100644
index 0000000..c5b8fce
--- /dev/null
+++ b/ZKuP/App.xaml.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace ZKuP
+{
+ ///
+ /// Interaktionslogik für "App.xaml"
+ ///
+ public partial class App : Application
+ {
+ void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
+ {
+ Log.WriteLog(e.Exception.ToString());
+ // Process unhandled exception
+ if(MessageBox.Show(MainWindow, "Es ist ein unbehandelter Fehler aufgetreten\n\nMöchten Sie einen Bericht an den Entwickler der Anwendung senden?", "Unbehandelter Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ Helper.SendMail(e.Exception.ToString());
+ }
+
+ e.Handled = true;
+ }
+
+ private void Application_Startup(object sender, StartupEventArgs e)
+ {
+ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+
+ FirstChanceEx();
+
+ }
+
+ void FirstChanceEx()
+ {
+ AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>
+ {
+ Log.WriteLog(eventArgs.Exception.ToString());
+
+ if (MessageBox.Show(MainWindow, "Es ist ein unbehandelter Fehler aufgetreten\n\nMöchten Sie einen Bericht an den Entwickler der Anwendung senden?", "Unbehandelter Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ Helper.SendMail(eventArgs.Exception.ToString());
+ }
+ };
+ }
+
+ void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ Exception ex = e.ExceptionObject as Exception;
+
+ Log.WriteLog(ex.ToString());
+
+ if (MessageBox.Show(MainWindow, "Es ist ein unbehandelter Fehler aufgetreten\n\nMöchten Sie einen Bericht an den Entwickler der Anwendung senden?", "Unbehandelter Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ Helper.SendMail(ex.ToString());
+ }
+
+ //MessageBox.Show(ex.Message, "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error);
+
+ }
+
+ static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
+ {
+ Log.WriteLog(e.Exception.Message.ToString());
+
+ // Log the exception, display it, etc
+ if (MessageBox.Show("Es ist ein unbehandelter Fehler aufgetreten\n\nMöchten Sie einen Bericht an den Entwickler der Anwendung senden?", "Unbehandelter Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ Helper.SendMail(e.Exception.Message.ToString());
+ }
+
+ }
+ }
+}
diff --git a/ZKuP/Arrivals.xaml b/ZKuP/Arrivals.xaml
new file mode 100644
index 0000000..67a74fb
--- /dev/null
+++ b/ZKuP/Arrivals.xaml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/Arrivals.xaml.cs b/ZKuP/Arrivals.xaml.cs
new file mode 100644
index 0000000..d9022aa
--- /dev/null
+++ b/ZKuP/Arrivals.xaml.cs
@@ -0,0 +1,445 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für Arrivals.xaml
+ ///
+ public partial class Arrivals : Window
+ {
+ List NamesList = new List();
+ int firmenCount = 0;
+ int besucherCount = 0;
+ bool arrivalClicked = false;
+ bool kl_EinweisungClicked = false;
+ string query = "";
+ byte[] _signature = null;
+ Window mainWindow = null;
+
+ public Arrivals(Window main, string Parameter = "")
+ {
+ InitializeComponent();
+ arrivalClicked = false;
+
+ mainWindow = main;
+
+ var list = SQL.ReadListString("Select Name FROM zkup.firmen").Result;
+ list = list.OrderBy(p => p).ToList();
+
+ NamesList.Add("Firmen:");
+ NamesList.Add("------------");
+ NamesList.AddRange(list);
+ NamesList.Add("");
+ NamesList.Add("============");
+ NamesList.Add("");
+
+ firmenCount = NamesList.Count;
+
+
+ list = SQL.ReadListString("Select Name FROM zkup.besucher").Result;
+ list.OrderBy(p => p).ToList();
+
+ NamesList.Add("Besucher:");
+ NamesList.Add("------------");
+ NamesList.AddRange(list);
+
+ besucherCount = NamesList.Count - firmenCount;
+
+
+ cbName.ItemsSource = NamesList;
+
+
+ if (Parameter != "")
+ {
+ cbName.SelectionChanged += CbName_SelectionChanged;
+ cbName.SelectedItem = Parameter;
+ tbAnzahlPersonen.Focus();
+ }
+ else
+ {
+ cbName.SelectionChanged += CbName_SelectionChanged;
+ cbName.IsDropDownOpen = true;
+ }
+
+ if(signoPad._stPad.DeviceGetCount() <= 0)
+ {
+ btnSignature.IsEnabled = false;
+ btnCheck.IsEnabled = true;
+
+ btnSignature.ToolTip = "Kein Unterschriftenpad gefunden";
+ }
+ }
+
+
+
+
+ private async void BtnCheck_Click(object sender, RoutedEventArgs e)
+ {
+ var zutritt = "";
+
+ var einweis = "";
+ var kl_einweis = "";
+ string kat = "1";
+ string asp = "";
+ string anzFzg = "";
+ int klUnterweis = 0;
+ int anzFzgGemeldet = 0;
+
+ DataTable table = new DataTable();
+
+ if (cbName.SelectedIndex < firmenCount)
+ {
+ table = await SQL.ReadSQL("Select * FROM zkup.firmen");
+ kat = "1";
+ }
+ else
+ {
+ table = await SQL.ReadSQL("Select * FROM zkup.besucher");
+ kat = "2";
+ }
+
+ foreach(DataRow row in table.Rows)
+ {
+ if(row.ItemArray[1].ToString() == cbName.SelectedValue.ToString())
+ {
+ DateTime beginnDT;
+ DateTime endeDT;
+ DateTime einweisDT;
+ DateTime kl_einweisDT;
+
+
+ if (kat == "1")
+ {
+ if (string.IsNullOrWhiteSpace(tbAnzahlFzg.Text))
+ {
+ MessageBox.Show(this, "Anzahl Fahrzeuge eingeben", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(tbAnzahlPersonen.Text))
+ {
+ MessageBox.Show(this, "Anzahl Personen eingeben", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+
+ if (DateTime.TryParse(row.ItemArray[7].ToString(), out beginnDT)
+ && DateTime.TryParse(row.ItemArray[8].ToString(), out endeDT))
+ {
+ if (DateTime.Now.Date >= beginnDT.Date && DateTime.Now.Date <= endeDT.Date)
+ zutritt = "OK";
+ else zutritt = "Prüfen!";
+ }
+ else
+ {
+ zutritt = $"Fehler! Bitte bei {row.ItemArray[10]} nachfragen";
+ einweis = $"Fehler! Bitte bei {row.ItemArray[10]} nachfragen";
+ }
+
+ if (Convert.ToInt16(tbAnzahlFzg.Text) <= Convert.ToInt16(row.ItemArray[5]))
+ {
+ anzFzg = "OK";
+ }
+ else
+ {
+ anzFzg = $"Nur {row.ItemArray[5].ToString()} Fahrzeug(e) angemeldet";
+ }
+
+ anzFzgGemeldet = row.ItemArray[5] != null ? Convert.ToInt16(row.ItemArray[5]) : 0;
+
+
+ if (DateTime.TryParse(row.ItemArray[9].ToString(), out einweisDT))
+ {
+ if(row.ItemArray[9].ToString() == "01.01.1903 00:00:00")
+ {
+ einweis = "Nur in Begleitung";
+ }
+ else if (DateTime.Now.Date <= einweisDT)
+ einweis = "OK";
+ else einweis = "Prüfen!";
+ }
+ else
+ {
+ zutritt = $"Fehler! Bitte bei {row.ItemArray[10]} nachfragen";
+ einweis = $"Fehler! Bitte bei {row.ItemArray[10]} nachfragen";
+ }
+
+ if(DateTime.TryParse(row.ItemArray[12].ToString(), out kl_einweisDT))
+ {
+ if (DateTime.Now.Date <= einweisDT)
+ {
+ kl_einweis = "OK";
+ klUnterweis = 1;
+ }
+ else
+ {
+ kl_einweis = "Kleine Unterweisung durchführen!";
+ klUnterweis = 0;
+ }
+ }
+ else
+ {
+ kl_einweis = "Bitte kleine Unterweisung durchführen!";
+ klUnterweis = 0;
+ }
+
+ asp = row.ItemArray[10].ToString();
+ }
+
+ if (kat == "2")
+ {
+ if (DateTime.TryParse(row.ItemArray[5].ToString(), out beginnDT))
+ {
+ if (DateTime.Now.Date == beginnDT)
+ zutritt = "OK";
+ else zutritt = "Prüfen!";
+ }
+ else
+ {
+ zutritt = $"Fehler! Bitte bei {row.ItemArray[7]} nachfragen";
+ einweis = $"Fehler! Bitte bei {row.ItemArray[7]} nachfragen";
+ }
+
+ //if (DateTime.TryParse(row.ItemArray[6].ToString(), out einweisDT))
+ //{
+ // if (DateTime.Now.Date <= einweisDT)
+ // einweis = "OK";
+ // else einweis = "Prüfen!";
+ //}
+ //else
+ //{
+ // zutritt = $"Fehler! Bitte bei {row.ItemArray[7]} nachfragen";
+ // einweis = $"Fehler! Bitte bei {row.ItemArray[7]} nachfragen";
+ //}
+ einweis = "--";
+ anzFzg = "--";
+
+ if (DateTime.TryParse(row.ItemArray[9].ToString(), out kl_einweisDT))
+ {
+ if (DateTime.Now.Date <= kl_einweisDT)
+ {
+ kl_einweis = "OK";
+ klUnterweis = 1;
+ }
+ else
+ {
+ kl_einweis = "Kleine Unterweisung durchführen!";
+ klUnterweis = 0;
+ }
+ }
+ else
+ {
+ kl_einweis = "Kleine Unterweisung durchführen!";
+ klUnterweis = 0;
+ }
+
+ asp = row.ItemArray[7].ToString();
+ }
+ }
+ }
+
+ lblAnmeldung.Content = zutritt;
+ if (zutritt == "OK") lblAnmeldung.Background = new SolidColorBrush(Colors.LightGreen);
+ else if (zutritt == "Prüfen!") lblAnmeldung.Background = new SolidColorBrush(Colors.LightYellow);
+ else lblAnmeldung.Background = new SolidColorBrush(Colors.LightSalmon);
+
+ lblFahrzeuge.Content = anzFzg;
+ if (anzFzg == "OK") lblFahrzeuge.Background = new SolidColorBrush(Colors.LightGreen);
+ else if (anzFzg.StartsWith("Nur")) lblFahrzeuge.Background = new SolidColorBrush(Colors.LightYellow);
+ else if (anzFzg == "--") lblFahrzeuge.Background = new SolidColorBrush(Colors.LightGray);
+ else lblFahrzeuge.Background = new SolidColorBrush(Colors.LightSalmon);
+
+
+ lblEinweisung.Content = einweis;
+ if (einweis == "OK") lblEinweisung.Background = new SolidColorBrush(Colors.LightGreen);
+ else if (einweis == "Prüfen!") lblEinweisung.Background = new SolidColorBrush(Colors.LightYellow);
+ else if (einweis == "--") lblEinweisung.Background = new SolidColorBrush(Colors.LightGray);
+ else lblEinweisung.Background = new SolidColorBrush(Colors.LightSalmon);
+
+ lblKleineUnterweisung.Content = kl_einweis;
+ if (kl_einweis == "OK") lblKleineUnterweisung.Background = new SolidColorBrush(Colors.LightGreen);
+ else if (kl_einweis == "Kleine Unterweisung durchführen!")
+ {
+ lblKleineUnterweisung.Background = new SolidColorBrush(Colors.LightYellow);
+ lblKleineUnterweisung.Content = "↓ " + kl_einweis + " ↓";
+ }
+ else lblKleineUnterweisung.Background = new SolidColorBrush(Colors.LightSalmon);
+
+
+ var AnzPers = "0";
+ var AnzFzg = "0";
+
+ if (tbAnzahlFzg.Text != "")
+ AnzFzg = tbAnzahlFzg.Text;
+
+ if (tbAnzahlPersonen.Text != "")
+ AnzPers = tbAnzahlPersonen.Text;
+
+ if (einweis == "") einweis = "Fehlerhaft";
+ if (zutritt == "") zutritt = "Fehlerhaft";
+
+ arrivalClicked = true;
+
+ query = $"INSERT INTO zutritte (Kategorie,Name,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung,AnzahlPers,AnzahlFzg,Ansprechpartner,Kl_Unterweisung,Fzg_gemeldet,Kennzeichen,Bemerkung,signature_blob) VALUES ('{kat}','{cbName.SelectedValue.ToString().Replace(",",";")}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}','{zutritt}','{einweis}','{AnzPers.Replace(",",";")}','{AnzFzg.Replace(",", ";")}','{asp.Replace(",", ";")}','{klUnterweis}','{anzFzgGemeldet}','{tbKennzeichen.Text}','{tbBemerkung.Text}',@signature)";
+
+ btnSignature.IsEnabled = true;
+
+ if (klUnterweis == 0) btnKlEinweisung_durchgeführt.IsEnabled = true;
+ else if (klUnterweis == 1)
+ {
+ btnKlEinweisung_durchgeführt.ToolTip = "Kleine Unterweisung wurde bereits durchgeführt\nBestätigung nicht nötig";
+ btnSignature.ToolTip = "Kleine Unterweisung wurde bereits durchgeführt\nUnterschrift nicht nötig";
+ btnSignature.Content = "Unterschrift bereits vorhanden";
+ }
+
+ if (arrivalClicked) btnClose.IsEnabled = true;
+ }
+
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ try
+ {
+ if (arrivalClicked)
+ {
+ e.Cancel = true;
+ MessageBox.Show(this, "Ankunft wurde geklickt\n\nBitte Fenster über \"Schließen\"-Button schließen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ signoPad.CloseConnection();
+ mainWindow.Focus();
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+
+ MessageBox.Show("Fehler: " + ex.Message);
+ }
+ }
+
+
+
+ private async void Close_Click(object sender, RoutedEventArgs e)
+ {
+ if (arrivalClicked)
+ {
+ await SQL.WriteSQL(query, _signature);
+
+ arrivalClicked = false;
+
+ this.Close();
+ }
+
+ signoPad.CloseConnection();
+ }
+
+ private async void CbName_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (cbName.SelectedValue != null)
+ {
+ if(cbName.SelectedItem.ToString() == "------------" || cbName.SelectedItem.ToString() == "============" || cbName.SelectedItem.ToString() == "Besucher:" || cbName.SelectedItem.ToString() == "Firmen:" || (cbName.SelectedItem.ToString() == "" && cbName.SelectedIndex != -1))
+ {
+ cbName.SelectedIndex = -1;
+ MessageBox.Show(this, "Dieses Feld kann nicht gewählt werden", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ string a_Fzg = await SQL.ReadSingleValueAsync($"SELECT Anzahl_Fzg FROM zkup.firmen WHERE `Name`='{cbName.SelectedValue.ToString()}' AND `Arbeitsbeginn` <= current_date() AND `Arbeitsende` >= current_date()");
+ lblAngemeldeteFzg.Text = !string.IsNullOrWhiteSpace(a_Fzg) ? a_Fzg + " Fzg. angemeldet" : "keine Fzg. angemeldet";
+
+
+ btnCheck.IsEnabled = true;
+ btnKarte.IsEnabled = true;
+ }
+ }
+
+ private async void btnSignature_Click(object sender, RoutedEventArgs e)
+ {
+ string kat = "1";
+ string firmaBesucher = "";
+ string name = "";
+
+ if (cbName.SelectedIndex < firmenCount)
+ {
+ firmaBesucher = cbName.SelectedValue.ToString();
+ name = await SQL.ReadSingleValueAsync($"SELECT Verantwortlicher_MA_Firma FROM zkup.firmen WHERE Name = '{cbName.SelectedValue.ToString()}'");
+ }
+ else
+ {
+ firmaBesucher = cbName.SelectedValue.ToString();
+ name = await SQL.ReadSingleValueAsync($"SELECT Ansprechpartner_Intern FROM zkup.besucher WHERE Name = '{cbName.SelectedValue.ToString()}'");
+ }
+
+ var sig = new Signature(name, cbName.SelectedValue.ToString(), tbKennzeichen.Text);
+ if(sig.ShowDialog() == false)
+ {
+ _signature = sig.ResultByte;
+
+ btnCheck.IsEnabled = true;
+ }
+ }
+
+ private async void btnKlEinweisung_durchgeführt_Click(object sender, RoutedEventArgs e)
+ {
+ if (signoPad._stPad.DeviceGetCount() <= 0)
+ {
+ btnSignature.IsEnabled = false;
+ btnSignature.ToolTip = "Kein Unterschriftenpad gefunden";
+ }
+ else { btnSignature.IsEnabled = true; btnSignature.Content = "Unterschrift einholen!"; }
+
+ if (cbName.SelectedIndex < firmenCount)
+ await SQL.WriteSQL($"UPDATE zkup.firmen SET Kleine_Unterweisung_bis = '{(DateTime.Now.Date.AddYears(1)).ToString("yyyy-MM-dd")}' WHERE Name = '{cbName.SelectedValue.ToString()}'");
+ else
+ await SQL.WriteSQL($"UPDATE zkup.besucher SET Kleine_Unterweisung_bis = '{(DateTime.Now.Date.AddYears(1)).ToString("yyyy-MM-dd")}' WHERE Name = '{cbName.SelectedValue.ToString()}'");
+
+ var s = query.Split(',');
+ s[20] = "1";
+ query = string.Join(",", s);
+
+ btnKlEinweisung_durchgeführt.Background = new SolidColorBrush(Colors.GreenYellow);
+ }
+
+ private void btnKarte_Click(object sender, RoutedEventArgs e)
+ {
+ AddCardUser aI = new AddCardUser(cbName.SelectedItem.ToString());
+ aI.Owner = this;
+ aI.ShowDialog();
+ }
+
+ private void Window_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ this.Opacity = 1;
+ }
+
+ private void Window_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ this.Opacity = 0.5;
+ }
+
+ private void CloseWithX_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ this.DragMove();
+ }
+ }
+}
diff --git a/ZKuP/ArrivalsOverview.xaml b/ZKuP/ArrivalsOverview.xaml
new file mode 100644
index 0000000..9b922da
--- /dev/null
+++ b/ZKuP/ArrivalsOverview.xaml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ArrivalsOverview.xaml.cs b/ZKuP/ArrivalsOverview.xaml.cs
new file mode 100644
index 0000000..9d26f59
--- /dev/null
+++ b/ZKuP/ArrivalsOverview.xaml.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ArrivalsOverview.xaml
+ ///
+ public partial class ArrivalsOverview : Window
+ {
+ Roles LoggedInRole = Roles.None;
+
+ DataTable overv = new DataTable("Overview");
+ DataTable todayFirm = new DataTable("TodayFirm");
+ DataTable todayBesuch = new DataTable("TodayBesuch");
+
+
+
+ public ArrivalsOverview(Roles role)
+ {
+ InitializeComponent();
+
+ LoggedInRole = role;
+
+ dPOverviewVon.SelectedDate = DateTime.Now.Date;
+ dPOverviewBis.SelectedDate = DateTime.Now.Date.AddDays(14);
+ FillDataGrid(DateTime.Now.Date, DateTime.Now.Date.AddDays(14));
+ }
+
+
+ private async void FillDataGrid(DateTime von, DateTime bis)
+ {
+ if (LoggedInRole == Roles.Admin || LoggedInRole == Roles.Pförtner)
+ {
+ todayFirm = await SQL.ReadSQL($"Select * From zkup.firmen where (Arbeitsbeginn >= '{von.ToString("yyyy-MM-dd")}' AND Arbeitsende <= '{bis.ToString("yyyy-MM-dd")}') OR '{von.ToString("yyyy-MM-dd")}' BETWEEN Arbeitsbeginn AND Arbeitsende", todayFirm);
+ todayBesuch = await SQL.ReadSQL($"SELECT idbesucher, concat('Besucher: ', Name) AS Name, Verantwortlicher_MA AS Verantwortlicher_MA_Firma,Tel_Nr_Besucher AS Tel_Nr_Verantwortlicher_Firma,Besuchstag AS Arbeitsbeginn,Grund_des_Besuchs AS Beauftragte_Leistung,Ansprechpartner_Intern from zkup.besucher WHERE (Besuchstag >= '{von.ToString("yyyy-MM-dd")}' AND Besuchstag <= '{bis.ToString("yyyy-MM-dd")}')", todayBesuch);
+ }
+ else
+ {
+ todayFirm = await SQL.ReadSQL($"Select * From zkup.firmen where ((Arbeitsbeginn >= '{von.ToString("yyyy-MM-dd")}' AND Arbeitsende <= '{bis.ToString("yyyy-MM-dd")}') OR '{von.ToString("yyyy-MM-dd")}' BETWEEN Arbeitsbeginn AND Arbeitsende) AND (Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}')", todayFirm);
+ todayBesuch = await SQL.ReadSQL($"SELECT idbesucher, concat('Besucher: ', Name) AS Name, Verantwortlicher_MA AS Verantwortlicher_MA_Firma,Tel_Nr_Besucher AS Tel_Nr_Verantwortlicher_Firma,Besuchstag AS Arbeitsbeginn,Grund_des_Besuchs AS Beauftragte_Leistung,Ansprechpartner_Intern from zkup.besucher WHERE (Besuchstag >= '{von.ToString("yyyy-MM-dd")}' AND Besuchstag <= '{bis.ToString("yyyy-MM-dd")}') AND (Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}')", todayBesuch);
+ }
+
+ var firmview = todayFirm.DefaultView;
+ firmview.Sort = "Name";
+ todayFirm = firmview.ToTable();
+
+ var besuchview = todayBesuch.DefaultView;
+ besuchview.Sort = "Name";
+ todayBesuch = besuchview.ToTable();
+
+ todayFirm.Merge(todayBesuch);
+ dgArrivalsOverview.DataContext = todayFirm;
+ }
+
+
+ private void btnOK_Click(object sender, RoutedEventArgs e)
+ {
+ FillDataGrid(dPOverviewVon.SelectedDate.Value, dPOverviewBis.SelectedDate.Value);
+ }
+
+ private void dPOverviewVon_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dPOverviewVon.SelectedDate.HasValue && dPOverviewBis.SelectedDate.HasValue && dPOverviewBis.SelectedDate.Value >= dPOverviewVon.SelectedDate.Value)
+ {
+ //btnOK.IsEnabled = true;
+ FillDataGrid(dPOverviewVon.SelectedDate.Value, dPOverviewBis.SelectedDate.Value);
+ lblAnwesend.Text = $"Ihre anwesenden Firmen/Besucher zwischen dem {dPOverviewVon.SelectedDate.Value.ToString("dd.MM.yy")} und {dPOverviewBis.SelectedDate.Value.ToString("dd.MM.yy")}:";
+ dPOverviewVon.ClearValue(DatePicker.BackgroundProperty);
+ dPOverviewBis.ClearValue(DatePicker.BackgroundProperty);
+ }
+ else
+ dPOverviewVon.Background = new SolidColorBrush(Colors.Red);
+
+ }
+
+ private void dPOverviewBis_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dPOverviewVon.SelectedDate.HasValue && dPOverviewBis.SelectedDate.HasValue && dPOverviewBis.SelectedDate.Value >= dPOverviewVon.SelectedDate.Value)
+ {
+ //btnOK.IsEnabled = true;
+ FillDataGrid(dPOverviewVon.SelectedDate.Value, dPOverviewBis.SelectedDate.Value);
+ lblAnwesend.Text = $"Ihre anwesenden Firmen/Besucher zwischen dem {dPOverviewVon.SelectedDate.Value.ToString("dd.MM.yy")} und {dPOverviewBis.SelectedDate.Value.ToString("dd.MM.yy")}:";
+ dPOverviewBis.ClearValue(DatePicker.BackgroundProperty);
+ dPOverviewVon.ClearValue(DatePicker.BackgroundProperty);
+ }
+ else
+ dPOverviewBis.Background = new SolidColorBrush(Colors.Red);
+ }
+
+ }
+}
diff --git a/ZKuP/AspInfo.xaml b/ZKuP/AspInfo.xaml
new file mode 100644
index 0000000..dd58a29
--- /dev/null
+++ b/ZKuP/AspInfo.xaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/AspInfo.xaml.cs b/ZKuP/AspInfo.xaml.cs
new file mode 100644
index 0000000..dc2590a
--- /dev/null
+++ b/ZKuP/AspInfo.xaml.cs
@@ -0,0 +1,139 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für AspInfo.xaml
+ ///
+ public partial class AspInfo : Window
+ {
+ public int id { get; set; }
+
+ //info = Welcher InfoButton wurde gedrückt? 1 = Ankunft heute; 2 = bereits bestätigt
+ public AspInfo(string name, string kat, int info = 1, string idzutritte = "1")
+ {
+ InitializeComponent();
+
+ if (idzutritte != "1") id = Convert.ToInt32(idzutritte);
+
+ if (info == 1) { lblBemerkung.Visibility = Visibility.Collapsed; tbBemerkung.Visibility = Visibility.Collapsed; btnSignature.Visibility = Visibility.Collapsed; }
+ else if (info == 2) { lblBemerkung.Visibility = Visibility.Visible; tbBemerkung.Visibility = Visibility.Visible; }
+ else { lblBemerkung.Visibility = Visibility.Visible; tbBemerkung.Visibility = Visibility.Visible; }
+
+ if (kat == "1")
+ {
+ tbVorgesetzter.Visibility = Visibility.Visible;
+ tbTelVorgesetzter.Visibility = Visibility.Visible;
+ lblVorgesetzter.Visibility = Visibility.Visible;
+ lblTelVorgesetzter.Visibility = Visibility.Visible;
+
+ lblVertreter_Besucher.Text = "Vertreter";
+ lblTelVertreter_Besucher.Text = "Telefonnummer Vertreter";
+
+ System.Data.DataTable asp = SQL.ReadSQL($"SELECT * FROM zkup.ansprechpartner WHERE Name='{name}'").Result;
+
+ if (asp.Rows.Count > 0)
+ {
+ tbAsp.Text = asp.Rows[0].ItemArray[0].ToString();
+ tbVertreter.Text = asp.Rows[0].ItemArray[1].ToString();
+ tbTelAsp.Text = asp.Rows[0].ItemArray[2].ToString();
+ tbVorgesetzter.Text = asp.Rows[0].ItemArray[3].ToString();
+ tbTelVertreter.Text = asp.Rows[0].ItemArray[4].ToString();
+ tbTelVorgesetzter.Text = asp.Rows[0].ItemArray[5].ToString();
+
+
+ tbBemerkung.Text = SQL.ReadSingleValue($"SELECT Bemerkung FROM zkup.zutritte WHERE idzutritte='{idzutritte}'");
+ }
+ else MessageBox.Show(this, "Keine oder fehlerhafte Daten angegeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ else if (kat == "2")
+ {
+ tbVorgesetzter.Visibility = Visibility.Collapsed;
+ tbTelVorgesetzter.Visibility = Visibility.Collapsed;
+ lblVorgesetzter.Visibility = Visibility.Collapsed;
+ lblTelVorgesetzter.Visibility = Visibility.Collapsed;
+
+ lblVertreter_Besucher.Text = "Besucher";
+ lblTelVertreter_Besucher.Text = "Telefonnummer Besucher";
+
+ System.Data.DataTable asp = SQL.ReadSQL($"SELECT * FROM zkup.besucher WHERE Name='{name}'").Result;
+ if (asp.Rows.Count > 0)
+ {
+ tbAsp.Text = asp.Rows[0].ItemArray[7].ToString();
+ tbTelAsp.Text = asp.Rows[0].ItemArray[8].ToString();
+ tbVertreter.Text = asp.Rows[0].ItemArray[1].ToString();
+ tbTelVertreter.Text = asp.Rows[0].ItemArray[3].ToString();
+
+ tbBemerkung.Text = SQL.ReadSingleValue($"SELECT Bemerkung FROM zkup.zutritte WHERE idzutritte='{idzutritte}'");
+ }
+ else MessageBox.Show(this, "Keine oder fehlerhafte Daten angegeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ else if (kat == "")
+ {
+ tbVertreter.Visibility = Visibility.Collapsed;
+ tbTelVertreter.Visibility = Visibility.Collapsed;
+ tbVorgesetzter.Visibility = Visibility.Collapsed;
+ tbTelVorgesetzter.Visibility = Visibility.Collapsed;
+
+
+ lblVertreter_Besucher.Visibility = Visibility.Collapsed;
+ lblTelVertreter_Besucher.Visibility = Visibility.Collapsed;
+ lblVorgesetzter.Visibility = Visibility.Collapsed;
+ lblTelVorgesetzter.Visibility = Visibility.Collapsed;
+
+ btnSignature.Visibility = Visibility.Collapsed;
+
+ lblAsp.Text = "Fahrer:";
+ lblTelAsp.Text = "Telefonnummer Fahrer:";
+ lblBemerkung.Text = "Parkplatz / Bemerkung";
+
+ System.Data.DataTable asp = SQL.ReadSQL($"SELECT * FROM zkup.zutritte WHERE idzutritte='{idzutritte}'").Result;
+ if (asp.Rows.Count > 0)
+ {
+ tbAsp.Text = asp.Rows[0].ItemArray[2].ToString().Split(new[] { "Fahrer: " }, StringSplitOptions.None)[1];
+ tbTelAsp.Text = asp.Rows[0].ItemArray[8].ToString();
+
+ gridInfo.RowDefinitions[4].Height = new GridLength(0);
+ gridInfo.RowDefinitions[5].Height = new GridLength(0);
+ gridInfo.RowDefinitions[6].Height = new GridLength(4, GridUnitType.Star);
+
+ tbBemerkung.Text = asp.Rows[0].ItemArray[12].ToString();
+ }
+ }
+ }
+
+ private async void btnSignature_Click(object sender, RoutedEventArgs e)
+ {
+ var x = SQL.ReadSingleByteArr($"SELECT signature_blob FROM zkup.zutritte WHERE idzutritte = '{id}'");
+ //var i = DBImageManager.ImageFromByte(x);
+ ImageView iv;
+
+ if (x != null)
+ iv = new ImageView(Helper.ConvertBitmapToImage(x), false);
+ else
+ {
+ MessageBox.Show(this, "Keine Unterschrift vorhanden!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ //iv.BackgroundImage = Helper.ConvertBitmapToImage(x);
+ iv.ShowDialog();
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/ZKuP/Cards.xaml b/ZKuP/Cards.xaml
new file mode 100644
index 0000000..35c1712
--- /dev/null
+++ b/ZKuP/Cards.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/Cards.xaml.cs b/ZKuP/Cards.xaml.cs
new file mode 100644
index 0000000..eea7f36
--- /dev/null
+++ b/ZKuP/Cards.xaml.cs
@@ -0,0 +1,86 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für Cards.xaml
+ ///
+ public partial class Cards : Window
+ {
+ System.Data.DataTable karten = new System.Data.DataTable("karten");
+
+
+ public Cards()
+ {
+ InitializeComponent();
+
+ karten = SQL.ReadSQL("Select * from zkup.karten", karten).Result;
+ dgCards.DataContext = karten;
+ }
+
+ private async void dgCards_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as System.Data.DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ if (MessageBox.Show(this, $"Karte {arr[1]},\nausgegeben an {arr[3]} wirklich entfernen?", "Karte entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.karten WHERE `kartennr` = '{arr[1]}'");
+
+ karten = SQL.ReadSQL("Select * FROM zkup.karten", karten).Result;
+ dgCards.DataContext = karten;
+ }
+ }
+ }
+
+ private void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ AddCardUser addCardUser = new AddCardUser();
+ addCardUser.Owner = this;
+ addCardUser.ShowDialog();
+
+ karten = SQL.ReadSQL("Select * from zkup.karten", karten).Result;
+ dgCards.DataContext = karten;
+ }
+
+
+
+
+
+ private void dgCards_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dgCards.SelectedIndex != -1) btnDelete.IsEnabled = true;
+ else btnDelete.IsEnabled = false;
+ }
+ private async void btnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ var dg = dgCards;
+ var row = dg.SelectedItem as System.Data.DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if(MessageBox.Show(this, $"Karte {arr[1]},\nausgegeben an {arr[3]} wirklich entfernen?", "Karte entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+
+ await SQL.WriteSQL($"DELETE FROM zkup.karten WHERE `kartennr` = '{arr[1]}'");
+
+ karten = SQL.ReadSQL("Select * FROM zkup.karten", karten).Result;
+ dgCards.DataContext = karten;
+ }
+ }
+ }
+}
diff --git a/ZKuP/CheckParkausweis.xaml b/ZKuP/CheckParkausweis.xaml
new file mode 100644
index 0000000..228ca54
--- /dev/null
+++ b/ZKuP/CheckParkausweis.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/CheckParkausweis.xaml.cs b/ZKuP/CheckParkausweis.xaml.cs
new file mode 100644
index 0000000..b8343b4
--- /dev/null
+++ b/ZKuP/CheckParkausweis.xaml.cs
@@ -0,0 +1,57 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CheckParkausweis.xaml
+ ///
+ public partial class CheckParkausweis : Window
+ {
+ public CheckParkausweis()
+ {
+ InitializeComponent();
+
+ var list = SQL.ReadSQL($"SELECT Kennzeichen FROM zkup.parkausweise WHERE Genehmigt = '1'").Result;
+ dgCheck.DataContext = list;
+ }
+
+
+ private void btnSearch_Click(object sender, RoutedEventArgs e)
+ {
+ var list = SQL.ReadSQL($"SELECT Kennzeichen FROM zkup.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result;
+ dgCheck.DataContext = list;
+ }
+
+ private void tbSearch_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (tbSearch.Text == "")
+ lblSearch.Visibility = Visibility.Visible;
+ }
+
+ private void tbSearch_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ lblSearch.Visibility = Visibility.Hidden;
+ }
+
+ private void lblSearch_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if(e.Key == Key.Enter)
+ {
+ var list = SQL.ReadSQL($"SELECT Kennzeichen FROM zkup.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result;
+ dgCheck.DataContext = list;
+ }
+ }
+ }
+}
diff --git a/ZKuP/CreateFirma.xaml b/ZKuP/CreateFirma.xaml
new file mode 100644
index 0000000..e4976a8
--- /dev/null
+++ b/ZKuP/CreateFirma.xaml
@@ -0,0 +1,427 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/CreateFirma.xaml.cs b/ZKuP/CreateFirma.xaml.cs
new file mode 100644
index 0000000..46a4060
--- /dev/null
+++ b/ZKuP/CreateFirma.xaml.cs
@@ -0,0 +1,765 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CreateFirma.xaml
+ ///
+ public partial class CreateFirma : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private List myVar;
+ public List FirmaView
+ {
+ get { return myVar; }
+ set { myVar = value; }
+ }
+
+ DataTable firmen = new DataTable("Firmen");
+
+ private List aspVar;
+ public List asp
+ {
+ get { return aspVar; }
+ set { aspVar = value; OnPropertyChanged(); }
+ }
+
+ //public List Ansprechpartner { get; set; }
+
+
+ public CreateFirma()
+ {
+ this.DataContext = this;
+
+ InitializeComponent();
+
+ updateList();
+
+ dgFirmen.Items.SortDescriptions.Clear();
+ dgFirmen.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
+ dgFirmen.UpdateLayout();
+
+ asp = SQL.ReadListString("SELECT Name FROM zkup.ansprechpartner").Result;
+ asp = asp.OrderBy(p => p).ToList();
+ cbAnsprechpartner_Intern.ItemsSource = asp;
+
+ dpEinweisung_Bis.DisplayDateEnd = DateTime.Now + TimeSpan.FromDays(365);
+ }
+
+ private void updateList()
+ {
+ if (MainWindow.LoggedInRole == Roles.Admin || MainWindow.LoggedInRole == Roles.Pförtner)
+ {
+ requestListAdmin();
+ }
+ else
+ {
+ requestList();
+ }
+ }
+
+ private void requestList()
+ {
+ firmen = SQL.ReadSQL($"SELECT * FROM zkup.firmen WHERE Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'"
+ , firmen).Result;
+ FirmaView = Firma.DataTableToFirma(firmen);
+ dgFirmen.DataContext = firmen;
+ }
+
+ private void requestListAdmin()
+ {
+ firmen = SQL.ReadSQL("SELECT * FROM zkup.firmen", firmen).Result;
+ FirmaView = Firma.DataTableToFirma(firmen);
+ dgFirmen.DataContext = firmen;
+ }
+
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ dpArbeitsbeginn.IsDropDownOpen = false;
+ dpArbeitsende.IsDropDownOpen = false;
+ dpEinweisung_Bis.IsDropDownOpen = false;
+
+ this.Close();
+ }
+
+
+
+ private async void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(tbName.Text))
+ {
+ MessageBox.Show("Namen eintragen!", "Fehler");
+ return;
+ }
+ else if (string.IsNullOrWhiteSpace(tbVerantwortlicher_MA.Text))
+ {
+ MessageBox.Show("Verantwortlichen MA eintragen!", "Fehler");
+ return;
+ }
+ else if (string.IsNullOrWhiteSpace(tbTel_Firma.Text))
+ {
+ MessageBox.Show("Telefonnummer der Firma eintragen!", "Fehler");
+ return;
+ }
+ else if (!dpArbeitsbeginn.SelectedDate.HasValue)
+ {
+ MessageBox.Show("Arbeitsbeginn eintragen!", "Fehler");
+ return;
+ }
+ else if (!dpArbeitsende.SelectedDate.HasValue)
+ {
+ MessageBox.Show("Arbeitsende eintragen!", "Fehler");
+ return;
+ }
+ else if (string.IsNullOrWhiteSpace(tbAnzahl_Fzg.Text))
+ {
+ MessageBox.Show("Anzahl Fahrzeuge eintragen!", "Fehler");
+ return;
+ }
+ else if (string.IsNullOrWhiteSpace(tbBeauftragte_Leistung.Text))
+ {
+ MessageBox.Show("Beauftragte Leistung eintragen!", "Fehler");
+ return;
+ }
+ else if (!dpEinweisung_Bis.SelectedDate.HasValue && (GetDPText() != "...Einweisung folgt..." && GetDPText() != "...Nur in Begleitung..."))
+ {
+ MessageBox.Show("'Einweisung bis' eintragen", "Fehler");
+ return;
+ }
+ else if (cbAnsprechpartner_Intern.SelectedIndex == -1)
+ {
+ MessageBox.Show("'Ansprechpartner intern' auswählen!", "Fehler");
+ return;
+ }
+ else if (!dpEinweisung_Bis.SelectedDate.HasValue && GetDPText() == "...Einweisung folgt...")
+ {
+ if (dpArbeitsende.SelectedDate.Value < dpArbeitsbeginn.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsende darf nicht kleiner als Arbeitsbeginn sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else if (dpArbeitsbeginn.SelectedDate.Value > dpArbeitsende.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsbeginn darf nicht größer als Arbeitsende sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else
+ {
+ if (MessageBox.Show(this, "Einweisung muss durchgeführt und manuell nachgetragen werden!!\n\nMit dem Hinzufügen fortfahren?", "Achtung!", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Begleiter.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Fzg.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Fzg. darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else
+ {
+ await SQL.WriteSQL("INSERT INTO firmen (Name,Verantwortlicher_MA_Firma,Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleiter,Anzahl_Fzg,Beauftragte_Leistung,Arbeitsbeginn,Arbeitsende,Örtliche_Einweisung_bis,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Ersteller) VALUES " +
+ $"('{tbName.Text}','{tbVerantwortlicher_MA.Text}','{tbTel_Firma.Text}','{tbAnzahl_Begleiter.Text}','{tbAnzahl_Fzg.Text}','{tbBeauftragte_Leistung.Text}','{dpArbeitsbeginn.SelectedDate.Value.ToString("yyyy-MM-dd")}','{dpArbeitsende.SelectedDate.Value.ToString("yyyy-MM-dd")}','1902-01-01','{cbAnsprechpartner_Intern.Text}','{tbTel_Nr_Ansprechpartner_Intern.Text}','{Environment.UserName}')");
+
+
+ updateList();
+
+ dgFirmen.ScrollIntoView(dgFirmen.Items[dgFirmen.Items.Count - 1]); //scroll to last
+ dgFirmen.UpdateLayout();
+ ResetInput();
+ }
+ }
+ }
+ }
+ else if (!dpEinweisung_Bis.SelectedDate.HasValue && GetDPText() == "...Nur in Begleitung...")
+ {
+ if (dpArbeitsende.SelectedDate.Value < dpArbeitsbeginn.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsende darf nicht kleiner als Arbeitsbeginn sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else if (dpArbeitsbeginn.SelectedDate.Value > dpArbeitsende.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsbeginn darf nicht größer als Arbeitsende sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else
+ {
+ if (MessageBox.Show(this, "Firmen dürfen sich nur in Begleitung auf dem Gelände bewegen!!\n\nMit dem Hinzufügen fortfahren?", "Achtung!", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Begleiter.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Fzg.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Fzg. darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else
+ {
+ await SQL.WriteSQL("INSERT INTO firmen (Name,Verantwortlicher_MA_Firma,Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleiter,Anzahl_Fzg,Beauftragte_Leistung,Arbeitsbeginn,Arbeitsende,Örtliche_Einweisung_bis,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Ersteller) VALUES " +
+ $"('{tbName.Text}','{tbVerantwortlicher_MA.Text}','{tbTel_Firma.Text}','{tbAnzahl_Begleiter.Text}','{tbAnzahl_Fzg.Text}','{tbBeauftragte_Leistung.Text}','{dpArbeitsbeginn.SelectedDate.Value.ToString("yyyy-MM-dd")}','{dpArbeitsende.SelectedDate.Value.ToString("yyyy-MM-dd")}','1903-01-01','{cbAnsprechpartner_Intern.Text}','{tbTel_Nr_Ansprechpartner_Intern.Text}','{Environment.UserName}')");
+
+
+ updateList();
+
+ dgFirmen.ScrollIntoView(dgFirmen.Items[dgFirmen.Items.Count - 1]); //scroll to last
+ dgFirmen.UpdateLayout();
+ ResetInput();
+ }
+ }
+ }
+ }
+ else
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Begleiter.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Fzg.Text, "^[0-9]*$"))
+ {
+ MessageBox.Show(this, "Anzahl Fzg. darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else if (dpArbeitsende.SelectedDate.Value < dpArbeitsbeginn.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsende darf nicht kleiner als Arbeitsbeginn sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else if (dpArbeitsbeginn.SelectedDate.Value > dpArbeitsende.SelectedDate.Value)
+ {
+ MessageBox.Show(this, "Arbeitsbeginn darf nicht größer als Arbeitsende sein", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ else
+ {
+ await SQL.WriteSQL("INSERT INTO firmen (Name,Verantwortlicher_MA_Firma,Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleiter,Anzahl_Fzg,Beauftragte_Leistung,Arbeitsbeginn,Arbeitsende,Örtliche_Einweisung_bis,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Ersteller) VALUES " +
+ $"('{tbName.Text}','{tbVerantwortlicher_MA.Text}','{tbTel_Firma.Text}','{tbAnzahl_Begleiter.Text}','{tbAnzahl_Fzg.Text}','{tbBeauftragte_Leistung.Text}','{dpArbeitsbeginn.SelectedDate.Value.ToString("yyyy-MM-dd")}','{dpArbeitsende.SelectedDate.Value.ToString("yyyy-MM-dd")}','{dpEinweisung_Bis.SelectedDate.Value.ToString("yyyy-MM-dd")}','{cbAnsprechpartner_Intern.Text}','{tbTel_Nr_Ansprechpartner_Intern.Text}','{Environment.UserName}')");
+
+
+ updateList();
+
+ dgFirmen.ScrollIntoView(dgFirmen.Items[dgFirmen.Items.Count - 1]); //scroll to last
+ dgFirmen.UpdateLayout();
+ ResetInput();
+ }
+ }
+ }
+
+ private void ResetInput()
+ {
+ tbName.Text = "";
+ tbVerantwortlicher_MA.Text = "";
+ tbTel_Firma.Text = "";
+ tbAnzahl_Begleiter.Text = "";
+ tbAnzahl_Fzg.Text = "";
+ tbBeauftragte_Leistung.Text = "";
+ dpArbeitsbeginn.Text = "";
+ dpArbeitsende.Text = "";
+ dpEinweisung_Bis.Text = "";
+ cbAnsprechpartner_Intern.SelectedIndex = -1;
+ tbTel_Nr_Ansprechpartner_Intern.Text = "";
+ }
+
+ private void CbAnsprechpartner_Intern_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ string test = SQL.ReadSingleValueAsync($"SELECT Tel_Nr FROM zkup.ansprechpartner WHERE Name='{cbAnsprechpartner_Intern.SelectedValue}'").Result;
+ tbTel_Nr_Ansprechpartner_Intern.Text = test;
+ }
+
+
+
+ private void dgFirmen_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ dgFirmen.PreviewKeyDown -= DgFirmen_PreviewKeyDown;
+ }
+
+ private async void DgFirmen_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ deleteRow(arr);
+ }
+ }
+
+
+ private async void DgFirmen_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+
+ try
+ {
+
+ var header = e.Column.Header;
+ var newValue = (e.EditingElement as TextBox).Text;
+
+
+
+ var id = (e.Row.Item as DataRowView).Row.ItemArray[0];
+ DateTime date = DateTime.Now;
+
+ if (DateTime.TryParse(newValue, out date))
+ if (date <= DateTime.Now + TimeSpan.FromDays(365)) newValue = date.ToString("yyyy-MM-dd");
+ else
+ {
+ MessageBox.Show(this, "Daten dürfen maximal 365 Tage in der Zukunft liegen", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ newValue = (DateTime.Now + TimeSpan.FromDays(365)).ToString("yyyy-MM-dd");
+ }
+
+ var MessageValue = newValue;
+ var MessageDate = DateTime.Now;
+ if (DateTime.TryParse(newValue, out MessageDate))
+ MessageValue = MessageDate.ToString("dd.MM.yyyy");
+
+
+ if (string.IsNullOrWhiteSpace(newValue.ToString()))
+ {
+ MessageBox.Show(this, "Eintrag darf nicht leer sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ e.Cancel = true;
+ }
+ else
+ {
+ if (oldValue != MessageValue)
+ {
+ if (MessageBox.Show(this, $"Möchten Sie den Eintrag '{oldValue}' in der Spalte '{header}' sicher zu '{MessageValue}' ändern?", "Sicher ändern?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ switch (header)
+ {
+ case "Name":
+ await SQL.WriteSQL($"UPDATE firmen SET Name = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Verantw. MA":
+ await SQL.WriteSQL($"UPDATE firmen SET Verantwortlicher_MA_Firma = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Tel. Firma":
+ await SQL.WriteSQL($"UPDATE firmen SET Tel_Nr_Verantwortlicher_Firma = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Anz. Begleitp.":
+ if (!System.Text.RegularExpressions.Regex.IsMatch(newValue, "^[0-9]*$"))
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ await SQL.WriteSQL($"UPDATE firmen SET Anzahl_Begleiter = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Anz. Fzg.":
+ if (!System.Text.RegularExpressions.Regex.IsMatch(newValue, "^[0-9]*$"))
+ MessageBox.Show(this, "Anzahl Fzg. darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ await SQL.WriteSQL($"UPDATE firmen SET Anzahl_Fzg = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Beauftragte Leistung":
+ await SQL.WriteSQL($"UPDATE firmen SET Beauftragte_Leistung = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Arbeitsbeginn":
+ await SQL.WriteSQL($"UPDATE firmen SET Arbeitsbeginn = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ if (Convert.ToDateTime(SQL.ReadSingleValue($"SELECT Arbeitsende FROM zkup.firmen WHERE idFirmen = '{id}'")) < MessageDate)
+ {
+ MessageBox.Show(this, "Arbeitsende darf nicht kleiner als Arbeitsbeginn sein\nDatum wird automatisch angepasst", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ await SQL.WriteSQL($"UPDATE firmen SET Arbeitsende = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ }
+ break;
+ case "Arbeitsende":
+ await SQL.WriteSQL($"UPDATE firmen SET Arbeitsende = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ if (Convert.ToDateTime(SQL.ReadSingleValue($"SELECT Arbeitsbeginn FROM zkup.firmen WHERE idFirmen = '{id}'")) > MessageDate)
+ {
+ MessageBox.Show(this, "Arbeitbeginn darf nicht größer als Arbeitsende sein\nDatum wird automatisch angepasst", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ await SQL.WriteSQL($"UPDATE firmen SET Arbeitsbeginn = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ }
+ break;
+ case "Unterwiesen bis":
+ await SQL.WriteSQL($"UPDATE firmen SET Örtliche_Einweisung_bis = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Anspr. intern":
+ await SQL.WriteSQL($"UPDATE firmen SET Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ case "Tel. Ansprechp.":
+ await SQL.WriteSQL($"UPDATE firmen SET Tel_Nr_Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idFirmen = '{id}'");
+ break;
+ }
+ }
+ }
+ }
+
+ index = e.Row.GetIndex();
+
+ dgFirmen.PreviewKeyDown += DgFirmen_PreviewKeyDown;
+
+ dgFirmen.RowValidationErrorTemplate = new ControlTemplate();
+
+ updateList();
+
+ dgFirmen.SelectedIndex = (index);
+ dgFirmen.ScrollIntoView(dgFirmen.Items[index]);
+
+ }
+
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show($"Es ist ein Fehler aufgetreten\n\n{ex.Message}", "Schwerer Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ finally
+ {
+ timer.Interval = TimeSpan.FromMilliseconds(50);
+ timer.Tick += Timer_Tick;
+ timer.Start();
+ }
+ }
+ System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
+
+ private async void Timer_Tick(object sender, EventArgs e)
+ {
+ await ScrollTo();
+ timer.Stop();
+ }
+
+ int index = 0;
+ private async Task ScrollTo()
+ {
+ try
+ {
+ if (index > 0 && dgFirmen.Items.Count >= index)
+ {
+ dgFirmen.SelectedIndex = index;
+ dgFirmen.ScrollIntoView(dgFirmen.Items[index], dgFirmen.Columns[0]);
+
+
+ //DataGridRow row = (DataGridRow)dgFirmen.ItemContainerGenerator.ContainerFromIndex(index - 1);
+
+ //row.Focusable = true;
+ //row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Right));
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show($"Es ist ein Fehler aufgetreten\n\n{ex.Message}", "Schwerer Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+
+
+ private void BtnEinweisung_PreValues_Click(object sender, RoutedEventArgs e)
+ {
+ string Value = (sender as Button).Content.ToString();
+
+ if (Value.EndsWith("Jahr"))
+ dpEinweisung_Bis.SelectedDate = DateTime.Now.AddYears(1);
+ else if (Value.EndsWith("Monat"))
+ dpEinweisung_Bis.SelectedDate = DateTime.Now.AddMonths(1);
+ else if (Value.EndsWith("Woche"))
+ dpEinweisung_Bis.SelectedDate = DateTime.Now.AddDays(7);
+ else if (Value.EndsWith("folgt"))
+ {
+ SetDPText("...Einweisung folgt...");
+ }
+ else if (Value.EndsWith("Begleitung"))
+ {
+ SetDPText("...Nur in Begleitung...");
+ }
+ //Debug.WriteLine(x.ToString());
+ }
+
+ private void SetDPText(string Text)
+ {
+ dpEinweisung_Bis.Text = "";
+
+ System.Reflection.FieldInfo fiTextBox = typeof(DatePicker).GetField("_textBox", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+
+ if (fiTextBox != null)
+ {
+ DatePickerTextBox dateTextBox =
+ (DatePickerTextBox)fiTextBox.GetValue(dpEinweisung_Bis);
+
+ if (dateTextBox != null)
+ {
+ System.Reflection.PropertyInfo piWatermark = dateTextBox.GetType()
+ .GetProperty("Watermark", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+
+ if (piWatermark != null)
+ {
+ piWatermark.SetValue(dateTextBox, Text, null);
+ }
+ }
+ }
+ }
+
+ private string GetDPText()
+ {
+ System.Reflection.FieldInfo fiTextBox = typeof(DatePicker).GetField("_textBox", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+
+ if (fiTextBox != null)
+ {
+ DatePickerTextBox dateTextBox =
+ (DatePickerTextBox)fiTextBox.GetValue(dpEinweisung_Bis);
+
+ if (dateTextBox != null)
+ {
+ System.Reflection.PropertyInfo piWatermark = dateTextBox.GetType()
+ .GetProperty("Watermark", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
+
+ if (piWatermark != null)
+ {
+ return (string)piWatermark.GetValue(dateTextBox, null);
+ }
+ }
+ }
+
+ return "";
+ }
+
+ private void TbBeauftragte_Leistung_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpArbeitsbeginn.Focus();
+ dpArbeitsbeginn.IsDropDownOpen = true;
+ }
+
+
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ else
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+ private void DpArbeitsbeginn_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpArbeitsbeginn.IsDropDownOpen = false;
+ dpArbeitsende.Focus();
+ dpArbeitsende.IsDropDownOpen = true;
+ }
+ }
+
+ private void DpArbeitsende_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpArbeitsende.IsDropDownOpen = false;
+ dpEinweisung_Bis.Focus();
+ dpEinweisung_Bis.IsDropDownOpen = true;
+ }
+ }
+
+ private void DpEinweisung_Bis_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpEinweisung_Bis.IsDropDownOpen = false;
+ dpEinweisung_Bis.Focus();
+ }
+ }
+
+
+ private void dgFirmen_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dgFirmen.SelectedIndex != -1) btnDelete.IsEnabled = true;
+ else btnDelete.IsEnabled = false;
+
+ //ScrollTo();
+ }
+ private async void btnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ var dg = dgFirmen;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Markierte Firma wirklich entfernen?", "Firma entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ deleteRow(arr);
+ }
+ }
+
+ private async void deleteRow(object[] arr)
+ {
+ await SQL.WriteSQL("INSERT INTO firmenLog (idfirmen,Name,Verantwortlicher_MA_Firma,Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleiter,Anzahl_Fzg,Beauftragte_Leistung,Arbeitsbeginn,Arbeitsende,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Geloescht_Von) VALUES " +
+ $"('{arr[0]}','{arr[1].ToString()}','{arr[2].ToString()}','{arr[3].ToString()}','{arr[4].ToString()}','{arr[5].ToString()}','{arr[6].ToString()}','{Convert.ToDateTime(arr[7].ToString()).ToString("yyyy-MM-dd")}','{Convert.ToDateTime(arr[8].ToString()).ToString("yyyy-MM-dd")}','{arr[10].ToString()}','{arr[11].ToString()}','{Environment.UserName}')");
+
+ await SQL.WriteSQL($"DELETE FROM zkup.firmen WHERE `idFirmen` = '{arr[0]}'");
+
+ updateList();
+ }
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ else
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+
+ string oldValue = "";
+ private void dgFirmen_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
+ {
+ if (e.Column.Header.ToString() == "Anspr. intern")
+ oldValue = (e.EditingElement as ComboBox) != null ? (e.EditingElement as ComboBox).Text : "";
+ else
+ oldValue = (e.EditingElement as TextBox) != null ? (e.EditingElement as TextBox).Text : "";
+ }
+
+
+ private void dg_cbASP_DropDownOpened(object sender, EventArgs e)
+ {
+ oldValue = (sender as ComboBox) != null ? (sender as ComboBox).Text : "";
+ }
+
+ private async void dg_cbAsp_DropDownClosed(object sender, EventArgs e)
+ {
+ var box = sender as ComboBox;
+ DataGridRow dataGridRow = Helper.FindParent(box);
+ int index = dataGridRow.GetIndex();
+
+ var id = ((System.Data.DataRowView)dataGridRow.DataContext).Row.ItemArray[0];
+
+ if ((sender as ComboBox).SelectedIndex != -1 && (sender as ComboBox).SelectedItem.ToString() != "")
+ {
+ if (oldValue != box.Text)
+ {
+ if (MessageBox.Show(this, $"Möchten Sie den Eintrag '{oldValue}' in der Spalte 'Anspr. intern' sicher zu '{box.Text}' ändern?", "Sicher ändern?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"UPDATE firmen SET Ansprechpartner_Intern = '{box.Text}',Tel_Nr_Ansprechpartner_Intern = '{SQL.ReadSingleValue($"SELECT Tel_Nr FROM zkup.ansprechpartner WHERE Name = '{(sender as ComboBox).Text}'")}', Bearbeiter = '{Environment.UserName}' WHERE idfirmen = '{id}'");
+
+ updateList();
+
+
+ dgFirmen.RowValidationErrorTemplate = new ControlTemplate();
+
+ dgFirmen.SelectedIndex = (index);
+ dgFirmen.ScrollIntoView(dgFirmen.Items[index]);
+ }
+ }
+ }
+ else
+ {
+ //tbAnsprechp_Intern.Text = "";
+ //tbTel_Ansprechp.Text = "";
+ }
+ }
+
+
+ private void btnHelp_Click(object sender, RoutedEventArgs e)
+ {
+ canvasHelp.Visibility = Visibility.Visible;
+ }
+
+ private void btnCloseHelp_Click(object sender, RoutedEventArgs e)
+ {
+ canvasHelp.Visibility = Visibility.Collapsed;
+ }
+
+ private void tbAnzahl_Fzg_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 2) e.Handled = true;
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$")) e.Handled = true;
+ }
+
+ private void tbAnzahl_Begleiter_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 2) e.Handled = true;
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$")) e.Handled = true;
+ }
+
+ private void Textboxes_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Command == ApplicationCommands.Paste)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+
+
+ public class Firma
+ {
+ string Name;
+ string Verantwortlicher_MA_Firma;
+ string Tel_Nr_Verantwortlicher_Firma;
+ string Anzahl_Begleiter;
+ string Anzahl_Fzg;
+ string Beauftragte_Leistung;
+ string Arbeitsbeginn;
+ string Arbeitsende;
+ string Örtliche_Einweisung_bis;
+ string Ansprechpartner_Intern;
+ string Tel_Nr_Ansprechpartner_Intern;
+
+
+
+
+ public static List DataTableToFirma(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Firma()
+ {
+ Name = dr[1].ToString(),
+ Verantwortlicher_MA_Firma = dr[2].ToString(),
+ Tel_Nr_Verantwortlicher_Firma = dr[3].ToString(),
+ Anzahl_Begleiter = dr[4].ToString(),
+ Anzahl_Fzg = dr[5].ToString(),
+ Beauftragte_Leistung = dr[6].ToString(),
+ Arbeitsbeginn = dr[7].ToString(),
+ Arbeitsende = dr[8].ToString(),
+ Örtliche_Einweisung_bis = dr[9].ToString(),
+ Ansprechpartner_Intern = dr[10].ToString(),
+ Tel_Nr_Ansprechpartner_Intern = dr[11].ToString()
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/CreateParkausweis.xaml b/ZKuP/CreateParkausweis.xaml
new file mode 100644
index 0000000..18564ec
--- /dev/null
+++ b/ZKuP/CreateParkausweis.xaml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/CreateParkausweis.xaml.cs b/ZKuP/CreateParkausweis.xaml.cs
new file mode 100644
index 0000000..329c6ec
--- /dev/null
+++ b/ZKuP/CreateParkausweis.xaml.cs
@@ -0,0 +1,386 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CreateParkausweis.xaml
+ ///
+ public partial class CreateParkausweis : Window
+ {
+ List plz = new List();
+ public bool special { get; private set; }
+
+ public CreateParkausweis(bool Special = false)
+ {
+ InitializeComponent();
+ special = Special;
+
+ if(special)
+ {
+ CommentRow.Height = new GridLength(2, GridUnitType.Star);
+ MinWidth = 330;
+ MinHeight = 800;
+ Width = 330;
+ Height = 800;
+ }
+ else
+ {
+ CommentRow.Height = new GridLength(0, GridUnitType.Star);
+ MinWidth = 330;
+ MinHeight = 707;
+ Width = 330;
+ Height = 707;
+ }
+
+ //var uri = new Uri("pack://application:,,,/Resources/PLZ_MUC.txt");
+ //var resourceStream = Application.GetResourceStream(uri);
+
+ using (var reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ZKuP.Resources.PLZ_MUC.txt")))
+ {
+ plz = reader.ReadToEnd().Replace("\r", "").Split('\n').ToList();
+ }
+ }
+
+ private void Textboxes_Changed(object sender, TextChangedEventArgs e)
+ {
+ if (System.Text.RegularExpressions.Regex.IsMatch(tbAdresse.Text, @"^.+\s{1}\d+\s*\w*"))
+ {
+ tbAdresse.Foreground = new SolidColorBrush(Colors.Black);
+ }
+
+ if (System.Text.RegularExpressions.Regex.IsMatch(tbEmail.Text, @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"))
+ {
+ tbEmail.Foreground = new SolidColorBrush(Colors.Black);
+ }
+
+ checkButton();
+ }
+
+ private void checkButton()
+ {
+ if (special)
+ btnCreate.IsEnabled = true;
+ else
+ {
+ if (
+ tbVorname.Text != "" &&
+ tbNachname.Text != "" &&
+ tbEmail.Text != "" &&
+ tbAbteilung.Text != "" &&
+ tbAdresse.Text != "" &&
+ tbPLZ.Text != "" &&
+ tbVorgesetzter.Text != "" &&
+ cbFirma.SelectedIndex != -1 &&
+ cBCorrectness.IsChecked.Value == true &&
+ cBSchicht.IsChecked.Value == true &&
+ (rbDKennzeichen.IsChecked.Value && (!string.IsNullOrWhiteSpace(tbDTownKennzeichen.Text)
+ && !string.IsNullOrWhiteSpace(tbDCharsKennzeichen.Text)
+ && !string.IsNullOrWhiteSpace(tbDDigitsKennzeichen.Text))
+ ||
+ (rbOtherKennzeichen.IsChecked.Value &&
+ !string.IsNullOrWhiteSpace(tbOtherKennzeichen.Text)))
+ )
+ btnCreate.IsEnabled = true;
+ else btnCreate.IsEnabled = false;
+ //tbTelefon != "";
+ }
+ }
+
+ private void tbPLZ_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (tbPLZ.Text.Length == 5 && !special)
+ {
+ foreach (var s in plz)
+ {
+ if (tbPLZ.Text == s)
+ {
+ MessageBox.Show(this, "Mitarbeiter im Stadtgebiet München sind nicht berechtigt Parkkarten zu beantragen!\n\nDie Angabe falscher Daten stellt einen fristlosen Kündigungsgrund dar!!", "Keine Berechtigung!", MessageBoxButton.OK, MessageBoxImage.Information);
+ tbPLZ.Text = "";
+ btnCreate.IsEnabled = false;
+ return;
+ }
+ }
+
+ checkButton();
+ }
+ else btnCreate.IsEnabled = false;
+ }
+
+
+
+
+ private async void btnCreate_Click(object sender, RoutedEventArgs e)
+ {
+ if(!System.Text.RegularExpressions.Regex.IsMatch(tbPLZ.Text, @"^\d{5}$"))
+ {
+ MessageBox.Show(this, "Postleitzahl muss exakt 5 Stellen haben und darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if(rbDKennzeichen.IsChecked.Value &&
+ (string.IsNullOrWhiteSpace(tbDTownKennzeichen.Text) ||
+ (string.IsNullOrWhiteSpace(tbDCharsKennzeichen.Text) ||
+ string.IsNullOrWhiteSpace(tbDDigitsKennzeichen.Text))))
+ {
+ MessageBox.Show(this, "Kennzeichen muss vollständig ausgefüllt sein", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if(rbOtherKennzeichen.IsChecked.Value &&
+ string.IsNullOrWhiteSpace(tbOtherKennzeichen.Text))
+ {
+ MessageBox.Show(this, "Kennzeichen muss ausgefüllt sein", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbEmail.Text, @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"))
+ {
+ MessageBox.Show(this, "Email nicht vollständig oder falsches Format", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if(!System.Text.RegularExpressions.Regex.IsMatch(tbAdresse.Text, @"^.+\s{1}\d+\s*\w*"))
+ {
+ MessageBox.Show(this, "Adresse nicht vollständig oder falsches Format\n\nFormat: Straße Leerzeichen Hausnummer Zusatz(wenn vorhanden)", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!(string.IsNullOrWhiteSpace(tbVorname.Text) &&
+ string.IsNullOrWhiteSpace(tbNachname.Text) &&
+ string.IsNullOrWhiteSpace(tbEmail.Text) &&
+ string.IsNullOrWhiteSpace(tbAbteilung.Text) &&
+ string.IsNullOrWhiteSpace(tbAdresse.Text) &&
+ string.IsNullOrWhiteSpace(tbPLZ.Text) &&
+ string.IsNullOrWhiteSpace(tbVorgesetzter.Text) &&
+ !cBSchicht.IsChecked.Value &&
+ !cBCorrectness.IsChecked.Value)
+ || special)
+ {
+
+ int _schicht = 0, _correctness = 0;
+ string _bemerkung = "Erstellt durch ZKuP";
+
+ if (cBSchicht.IsChecked.Value) _schicht = 1;
+ if (cBCorrectness.IsChecked.Value) _correctness = 1;
+ if (!string.IsNullOrWhiteSpace(tbBemerkung.Text)) _bemerkung = tbBemerkung.Text;
+
+ if (rbOtherKennzeichen.IsChecked.Value)
+ {
+ await SQL.WriteSQL($"INSERT INTO parkausweise (MA_Vorname,MA_Name,Kennzeichen,Email,Telefon,Abteilung,Firma,Adresse,PLZ,Vorgesetzter,AcceptedCorrectness,Schicht,Bemerkung) VALUES ('{tbVorname.Text}','{tbNachname.Text}','{tbOtherKennzeichen.Text}','{tbEmail.Text}','{tbTelefon.Text}','{tbAbteilung.Text}','{cbFirma.Text}','{tbAdresse.Text}','{tbPLZ.Text}','{tbVorgesetzter.Text}','{_correctness}','{_schicht}','{_bemerkung}')");
+ var id = SQL.ReadSingleValue($"SELECT idparkausweise FROM zkup.parkausweise ORDER BY idparkausweise DESC LIMIT 1");
+ MessageBox.Show(this, $"Antrag erfolgreich abgeschickt\n\nIhre Karte hat die Nr. {id}", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information);
+ this.Close();
+ }
+ else if (rbDKennzeichen.IsChecked.Value)
+ {
+ await SQL.WriteSQL($"INSERT INTO parkausweise (MA_Vorname,MA_Name,Kennzeichen,Email,Telefon,Abteilung,Firma,Adresse,PLZ,Vorgesetzter,AcceptedCorrectness,Schicht,Bemerkung) VALUES ('{tbVorname.Text}','{tbNachname.Text}','{tbDTownKennzeichen.Text}-{tbDCharsKennzeichen.Text} {tbDDigitsKennzeichen.Text}','{tbEmail.Text}','{tbTelefon.Text}','{tbAbteilung.Text}','{cbFirma.Text}','{tbAdresse.Text}','{tbPLZ.Text}','{tbVorgesetzter.Text}','{_correctness}','{_schicht}','{_bemerkung}')");
+ var id = SQL.ReadSingleValue($"SELECT idparkausweise FROM zkup.parkausweise ORDER BY idparkausweise DESC LIMIT 1");
+ MessageBox.Show(this, $"Antrag erfolgreich abgeschickt\n\nIhre Karte hat die Nr. {id}", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information);
+ this.Close();
+ }
+ }
+ else MessageBox.Show(this, "Es müssen alle benötigten(*) Felder ausgefüllt werden", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+
+
+
+
+ private void cBCorrectness_Unchecked(object sender, RoutedEventArgs e)
+ {
+ btnCreate.IsEnabled = false;
+ }
+
+ private void cBCorrectness_Checked(object sender, RoutedEventArgs e)
+ {
+ checkButton();
+ }
+
+ private void cBSchicht_Checked(object sender, RoutedEventArgs e)
+ {
+ checkButton();
+ }
+
+ private void cBSchicht_Unchecked(object sender, RoutedEventArgs e)
+ {
+ if(!special) btnCreate.IsEnabled = false;
+ }
+
+ private void tbPLZ_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 5)
+ {
+ e.Handled = true;
+ return;
+ }
+
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$"))
+ {
+ e.Handled = true;
+ return;
+ }
+ }
+
+ private void tbPLZ_TextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 5)
+ {
+ e.Handled = true;
+ return;
+ }
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$"))
+ {
+ e.Handled = true;
+ return;
+ }
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ else
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+ private void tbPLZ_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Command == ApplicationCommands.Paste)
+ {
+ e.Handled = true;
+ }
+ }
+
+
+ private void rbDKennzeichen_Checked(object sender, RoutedEventArgs e)
+ {
+ tbOtherKennzeichen.Visibility = Visibility.Hidden;
+
+ tbDTownKennzeichen.Visibility = Visibility.Visible;
+ tbDCharsKennzeichen.Visibility = Visibility.Visible;
+ tbDDigitsKennzeichen.Visibility = Visibility.Visible;
+ }
+
+ private void rbOtherKennzeichen_Checked(object sender, RoutedEventArgs e)
+ {
+ if (MessageBox.Show(this, "Diese Funktion darf nicht für deutsche Kennzeichen genutzt werden\nDie Kennzeichen werden überprüft und bei deutschem Kennzeichen abgelehnt\n\nMöchten Sie sicher ein ausländisches Kennzeichen eingeben?", "Achtung!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ tbDTownKennzeichen.Visibility = Visibility.Collapsed;
+ tbDCharsKennzeichen.Visibility = Visibility.Collapsed;
+ tbDDigitsKennzeichen.Visibility = Visibility.Collapsed;
+
+ tbOtherKennzeichen.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ rbDKennzeichen.IsChecked = true;
+ }
+ }
+
+ private void tbDTownKennzeichen_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 3)
+ {
+ e.Handled = true;
+ return;
+ }
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[A-ZÄÖÜ]?[A-ZÄÖÜ]?[A-ZÄÖÜ]?"))
+ {
+ e.Handled = true;
+ return;
+ }
+ }
+
+ private void tbDCharsKennzeichen_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 2)
+ {
+ e.Handled = true;
+ return;
+ }
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[A-ZÄÖÜ]?[A-ZÄÖÜ]?"))
+ {
+ e.Handled = true;
+ return;
+ }
+ }
+
+ private void tbDDigitsKennzeichen_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 5)
+ {
+ e.Handled = true;
+ return;
+ }
+
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$"))
+ {
+ e.Handled = true;
+ return;
+ }
+ }
+
+ private void tbAdresse_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAdresse.Text, @"^.+\s{1}\d+\s*\w*"))
+ {
+ tbAdresse.Foreground = new SolidColorBrush(Colors.Red);
+ tbAdresse.ToolTip = "Adresse nicht vollständig oder falsches Format";
+ }
+ else
+ {
+ tbAdresse.Foreground = new SolidColorBrush(Colors.Black);
+ tbAdresse.ToolTip = "";
+ }
+ }
+
+ private void tbEmail_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbEmail.Text, @"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"))
+ {
+ tbEmail.Foreground = new SolidColorBrush(Colors.Red);
+ tbEmail.ToolTip = "Email nicht vollständig oder falsches Format";
+ }
+ else
+ {
+ tbEmail.Foreground = new SolidColorBrush(Colors.Black);
+ tbEmail.ToolTip = "";
+ }
+
+ }
+
+ private void tbBemerkung_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ lblBemerkung.Visibility = Visibility.Collapsed;
+ }
+
+ private void tbBemerkung_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(tbBemerkung.Text)) lblBemerkung.Visibility = Visibility.Visible;
+ else lblBemerkung.Visibility = Visibility.Collapsed;
+ }
+ }
+}
diff --git a/ZKuP/CreateVisitor.xaml b/ZKuP/CreateVisitor.xaml
new file mode 100644
index 0000000..6b00df2
--- /dev/null
+++ b/ZKuP/CreateVisitor.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/CreateVisitor.xaml.cs b/ZKuP/CreateVisitor.xaml.cs
new file mode 100644
index 0000000..4583e6d
--- /dev/null
+++ b/ZKuP/CreateVisitor.xaml.cs
@@ -0,0 +1,141 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CreateVisitor.xaml
+ ///
+ public partial class CreateVisitor : Window
+ {
+ public CreateVisitor()
+ {
+ InitializeComponent();
+ }
+
+ private async void BtnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ if (tbAnzahl_Begleiter.Text == "") tbAnzahl_Begleiter.Text = "0";
+
+ if (string.IsNullOrWhiteSpace(tbName.Text))
+ MessageBox.Show("Name eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbVerantwortlicher_MA.Text))
+ MessageBox.Show("Verantwortlichen MA eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbTel_Besucher.Text))
+ MessageBox.Show("Telefonnummer Besucher eintragen!", "Fehler");
+ else if (!dpBesuchstag.SelectedDate.HasValue)
+ MessageBox.Show("Besuchstag eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbGrundDesBesuchs.Text))
+ MessageBox.Show("'Grund des Besuchs' eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbOertlichkeit.Text))
+ MessageBox.Show("'Örtlichkeit' eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbAnsprechp_Intern.Text))
+ MessageBox.Show("'Ansprechpartner intern' eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbTel_Ansprechp.Text))
+ MessageBox.Show("'Telefonnr. Ansprechpartner intern' eintragen!", "Fehler");
+ else
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Begleiter.Text, "^[0-9]*$"))
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ await SQL.WriteSQL("REPLACE INTO besucher (Name,Verantwortlicher_MA,Tel_Nr_Besucher,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Oertlichkeit,Ersteller) VALUES " +
+ $"('{tbName.Text}','{tbVerantwortlicher_MA.Text}','{tbTel_Besucher.Text}','{tbAnzahl_Begleiter.Text}','{dpBesuchstag.SelectedDate.Value.ToString("yyyy-MM-dd")}','{tbGrundDesBesuchs.Text}','{tbAnsprechp_Intern.Text}','{tbTel_Ansprechp.Text}','{tbOertlichkeit.Text}','{Environment.UserName}')");
+ }
+
+ if (await SQL.RowExists("besucher", "Name", tbName.Text))
+ {
+ MessageBox.Show("Besucher erfolgreich erstellt", "Erfolg!", MessageBoxButton.OK, MessageBoxImage.Information);
+
+ tbName.Text = "";
+ tbVerantwortlicher_MA.Text = "";
+ tbTel_Besucher.Text = "";
+ tbAnzahl_Begleiter.Text = "";
+ tbAnsprechp_Intern.Text = "";
+ tbTel_Ansprechp.Text = "";
+ dpBesuchstag.SelectedDate = null;
+ tbGrundDesBesuchs.Text = "";
+ tbOertlichkeit.Text = "";
+ }
+ else MessageBox.Show("Fehler beim erstellen des Besuchers", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+
+
+
+
+ private void TbAnzahl_Begleiter_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpBesuchstag.IsDropDownOpen = true;
+ dpBesuchstag.Focus();
+ }
+
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ else
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+ private void DpBesuchstag_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpBesuchstag.IsDropDownOpen = false;
+ dpBesuchstag.Focus();
+ }
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+
+ private void tbAnzahl_Begleiter_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 2) e.Handled = true;
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$")) e.Handled = true;
+ }
+
+ private void Textboxes_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Command == ApplicationCommands.Paste)
+ {
+ e.Handled = true;
+ }
+ }
+
+ private void btnMyVisitors_Click(object sender, RoutedEventArgs e)
+ {
+ CreateVisitor_List cVL = new CreateVisitor_List();
+ cVL.Owner = this;
+ cVL.ShowDialog();
+ }
+ }
+}
diff --git a/ZKuP/CreateVisitor_List.xaml b/ZKuP/CreateVisitor_List.xaml
new file mode 100644
index 0000000..63f9b03
--- /dev/null
+++ b/ZKuP/CreateVisitor_List.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/CreateVisitor_List.xaml.cs b/ZKuP/CreateVisitor_List.xaml.cs
new file mode 100644
index 0000000..21607c8
--- /dev/null
+++ b/ZKuP/CreateVisitor_List.xaml.cs
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CreateVisitor_List.xaml
+ ///
+ public partial class CreateVisitor_List : Window
+ {
+ private List myVar;
+ public List VisitorView
+ {
+ get { return myVar; }
+ set { myVar = value; }
+ }
+
+ DataTable visitors = new DataTable("Visitors");
+
+
+ int index = 0;
+
+ public CreateVisitor_List()
+ {
+ this.DataContext = this;
+
+ InitializeComponent();
+
+ this.Title = "Besucherliste von: " + Helper.InsertSpaceBeforeUpperCase(Environment.UserName);
+
+ visitors = SQL.ReadSQL($"SELECT * FROM zkup.besucher WHERE Ersteller = '{Environment.UserName}'", visitors).Result;
+ VisitorView = Visitor.DataTableToVisitor(visitors);
+ dgVisitors.DataContext = visitors;
+
+ dgVisitors.Items.SortDescriptions.Clear();
+ dgVisitors.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
+ dgVisitors.UpdateLayout();
+
+
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private async void DgVisitors_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+ var header = e.Column.Header;
+ var newValue = (e.EditingElement as TextBox).Text;
+ var id = (e.Row.Item as DataRowView).Row.ItemArray[0];
+ DateTime date = DateTime.Now;
+
+ if (DateTime.TryParseExact(newValue, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out date))
+ newValue = date.ToString("yyyy-MM-dd");
+
+ var MessageValue = newValue;
+ var MessageDate = DateTime.Now;
+ if (DateTime.TryParse(newValue, out MessageDate))
+ MessageValue = MessageDate.ToString("dd.MM.yyyy");
+
+ if (oldValue != MessageValue)
+ {
+ if (MessageBox.Show(this, $"Möchten Sie den Eintrag '{oldValue}' in der Spalte '{header}' sicher zu '{MessageValue}' ändern?", "Sicher ändern?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ switch (header)
+ {
+ case "Name":
+ await SQL.WriteSQL($"UPDATE besucher SET Name = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Verantw. MA":
+ await SQL.WriteSQL($"UPDATE besucher SET Verantwortlicher_MA = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Tel. Besucher":
+ await SQL.WriteSQL($"UPDATE besucher SET Tel_Nr_Besucher = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Anz. Begleitp.":
+ await SQL.WriteSQL($"UPDATE besucher SET Anzahl_Begleitpersonen = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Besuchstag":
+ await SQL.WriteSQL($"UPDATE besucher SET Besuchstag = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Grund des Besuchs":
+ await SQL.WriteSQL($"UPDATE besucher SET Grund_des_Besuchs = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Örtlichkeit":
+ await SQL.WriteSQL($"UPDATE besucher SET Oertlichkeit = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Anspr. intern":
+ await SQL.WriteSQL($"UPDATE besucher SET Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Tel. Ansprechp.":
+ await SQL.WriteSQL($"UPDATE besucher SET Tel_Nr_Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ }
+ }
+ }
+
+ index = e.Row.GetIndex();
+ dgVisitors.PreviewKeyDown += DgVisitors_PreviewKeyDown;
+
+ visitors = SQL.ReadSQL($"Select * from zkup.besucher WHERE Ersteller = '{Environment.UserName}'", visitors).Result;
+ VisitorView = Visitor.DataTableToVisitor(visitors);
+
+
+ dgVisitors.RowValidationErrorTemplate = new ControlTemplate();
+
+ dgVisitors.SelectedIndex = (index);
+ dgVisitors.ScrollIntoView(dgVisitors.Items[index]);
+
+ //ScrollTo();
+ }
+
+ private async void DgVisitors_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ deleteRow(arr);
+ }
+ }
+
+ private void DgVisitors_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ dgVisitors.PreviewKeyDown -= DgVisitors_PreviewKeyDown;
+ }
+
+ string oldValue = "";
+ private void dgVisitors_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
+ {
+ oldValue = (e.EditingElement as TextBox) != null ? (e.EditingElement as TextBox).Text : "";
+ }
+
+ private void dgVisitors_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dgVisitors.SelectedIndex != -1) btnDelete.IsEnabled = true;
+ else btnDelete.IsEnabled = false;
+
+ }
+
+ private async void btnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ var dg = dgVisitors;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Markierten Besucher wirklich entfernen?", "Besucher entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ deleteRow(arr);
+ }
+ }
+
+ private async void deleteRow(object[] arr)
+ {
+ await SQL.WriteSQL("INSERT INTO besucherLog (idbesucher, Name,Verantwortlicher_MA,Tel_Nr_Besucher,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Oertlichkeit,Geloescht_Von) VALUES " +
+ $"('{arr[0]}','{arr[1].ToString()}','{arr[2].ToString()}','{arr[3].ToString()}','{arr[4].ToString()}','{Convert.ToDateTime(arr[5].ToString()).ToString("yyyy-MM-dd")}','{arr[6].ToString()}','{arr[7].ToString()}','{arr[8].ToString()}','{arr[10].ToString()}','{Environment.UserName}')");
+
+ await SQL.WriteSQL($"DELETE FROM zkup.besucher WHERE `idbesucher` = '{arr[0]}'");
+
+ visitors = SQL.ReadSQL($"Select * from zkup.besucher WHERE Ersteller = '{Environment.UserName}'", visitors).Result;
+ VisitorView = Visitor.DataTableToVisitor(visitors);
+ }
+ }
+}
diff --git a/ZKuP/DBImageManager.cs b/ZKuP/DBImageManager.cs
new file mode 100644
index 0000000..0323cfb
--- /dev/null
+++ b/ZKuP/DBImageManager.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace ZKuP
+{
+ public static class DBImageManager
+ {
+ public static BitmapImage ImageFromByte(byte[] array)
+ {
+ //Store binary data read from the database in a byte array
+ byte[] blob = array;
+ MemoryStream stream = new MemoryStream();
+ stream.Write(blob, 0, blob.Length);
+ stream.Position = 0;
+
+ System.Drawing.Image img = System.Drawing.Image.FromStream(stream,false,true);
+ BitmapImage bi = new BitmapImage();
+ bi.BeginInit();
+
+ MemoryStream ms = new MemoryStream();
+ img.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
+ ms.Seek(0, SeekOrigin.Begin);
+ bi.StreamSource = ms;
+ bi.EndInit();
+
+ return bi;
+ }
+
+ public static byte[] ByteFromImage(Image image)
+ {
+ try
+ {
+
+ //Initialize a file stream to read the image file
+ MemoryStream fs = new MemoryStream();
+ image.Save(fs, ImageFormat.Tiff);
+
+ //Initialize a byte array with size of stream
+ byte[] imgByteArr = new byte[fs.Length];
+
+ //Read data from the file stream and put into the byte array
+ fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
+
+ //Close a file stream
+ fs.Close();
+
+ return imgByteArr;
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show(ex.Message);
+ return null;
+ }
+ }
+
+
+ public static byte[] ImageFromFileToByte(string fileName)
+ {
+ FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
+
+ //Initialize a byte array with size of stream
+ byte[] imgByteArr = new byte[fs.Length];
+
+ //Read data from the file stream and put into the byte array
+ fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
+
+ //Close a file stream
+ fs.Close();
+
+ return imgByteArr;
+ }
+
+ public static string StringFromImage(Image image)
+ {
+ MemoryStream ms = new MemoryStream();
+ image.Save(ms, ImageFormat.Tiff);
+ return Convert.ToBase64String(ms.ToArray());
+ }
+ }
+}
+
+
diff --git a/ZKuP/Delivery.xaml b/ZKuP/Delivery.xaml
new file mode 100644
index 0000000..8a84974
--- /dev/null
+++ b/ZKuP/Delivery.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/Delivery.xaml.cs b/ZKuP/Delivery.xaml.cs
new file mode 100644
index 0000000..ab80c19
--- /dev/null
+++ b/ZKuP/Delivery.xaml.cs
@@ -0,0 +1,122 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für Delivery.xaml
+ ///
+ public partial class Delivery : Window
+ {
+ string query = "";
+
+ byte[] _signature = null;
+
+ public Delivery()
+ {
+ InitializeComponent();
+ var list = SQL.ReadListStringTwoColumns($"SELECT Firma, Fahrer FROM zkup.lieferanten", " Fahrer: ").Result;
+ list = list.OrderBy(p => p).ToList();
+ cBLieferfirma.ItemsSource = list;
+ }
+
+
+ private void btnFiltern_Click(object sender, RoutedEventArgs e)
+ {
+ var list = SQL.ReadListStringTwoColumns($"SELECT Firma, Fahrer FROM zkup.lieferanten WHERE Firma LIKE '%{tbFilter.Text}%' OR Fahrer LIKE '%{tbFilter.Text}%'", " Fahrer: ").Result;
+ list = list.OrderBy(p => p).ToList();
+ cBLieferfirma.ItemsSource = list;
+
+ cBLieferfirma.IsDropDownOpen = true;
+ }
+
+
+
+ private async void btnSignature_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(tbFahrer.Text) && !string.IsNullOrWhiteSpace(tbFirma.Text))
+ {
+ var sig = new Signature(tbFahrer.Text, tbFirma.Text, tbKennzeichen.Text, false);
+ if (sig.ShowDialog() == false)
+ {
+ _signature = sig.ResultByte;
+ }
+ }
+ else MessageBox.Show(this, "Firma und Fahrer müssen ausgefüllt werden", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show($"Es ist ein Fehler aufgetreten\n\nInterne Meldung: {ex.Message}");
+ }
+
+ }
+
+
+ private async void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (tbParkplatz.Text != "")
+ query = ($"INSERT INTO zutritte (Kategorie,Name,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung,AnzahlPers,AnzahlFzg,Ansprechpartner,Kl_Unterweisung,Fzg_gemeldet,Kennzeichen,Bemerkung, signature_blob) VALUES ('3','Firma: {tbFirma.Text}, Fahrer: {tbFahrer.Text}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}','--','--','1','1','{tbHandy.Text}','1','1','{tbKennzeichen.Text}','Parkplatz: {tbParkplatz.Text}\n\nBemerkung:\n{tbBemerkung.Text}', @signature)");
+ else
+ query = ($"INSERT INTO zutritte (Kategorie,Name,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung,AnzahlPers,AnzahlFzg,Ansprechpartner,Kl_Unterweisung,Fzg_gemeldet,Kennzeichen,Bemerkung, signature_blob) VALUES ('3','Firma: {tbFirma.Text}, Fahrer: {tbFahrer.Text}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}','--','--','1','1','{tbHandy.Text}','1','1','{tbKennzeichen.Text}','{tbBemerkung.Text}', @signature)");
+
+ await SQL.WriteSQL(query, _signature);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show(this, "Fehler beim Eintragen des Lieferanten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ this.Close();
+ }
+
+ private async void cBLieferfirma_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ System.Data.DataTable result = new System.Data.DataTable();
+ string firma = (sender as ComboBox).SelectedItem.ToString().Split(new string[] { " Fahrer: " }, StringSplitOptions.None)[0];
+ string fahrer = (sender as ComboBox).SelectedItem.ToString().Split(new string[] { " Fahrer: " }, StringSplitOptions.None)[1];
+
+ if (fahrer != "")
+ result = await SQL.ReadSQL($"SELECT * FROM zkup.lieferanten WHERE Firma = '{firma}' AND Fahrer = '{fahrer}' LIMIT 1");
+ else
+ result = await SQL.ReadSQL($"SELECT * FROM zkup.lieferanten WHERE Firma = '{firma}' LIMIT 1");
+
+
+ tbFirma.Text = result.Rows[0].ItemArray[0] != null ? result.Rows[0].ItemArray[0].ToString() : "";
+ tbFahrer.Text = result.Rows[0].ItemArray[1] != null ? result.Rows[0].ItemArray[1].ToString() : "";
+ tbHandy.Text = result.Rows[0].ItemArray[2] != null ? result.Rows[0].ItemArray[2].ToString() : "";
+ tbKennzeichen.Text = result.Rows[0].ItemArray[3] != null ? result.Rows[0].ItemArray[3].ToString() : "";
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+ }
+}
diff --git a/ZKuP/FodyWeavers.xml b/ZKuP/FodyWeavers.xml
new file mode 100644
index 0000000..8aaedeb
--- /dev/null
+++ b/ZKuP/FodyWeavers.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/ZKuP/FodyWeavers.xsd b/ZKuP/FodyWeavers.xsd
new file mode 100644
index 0000000..44a5374
--- /dev/null
+++ b/ZKuP/FodyWeavers.xsd
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
+
+
+
+
+ A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
+
+
+
+
+ A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
+
+
+
+
+ The order of preloaded assemblies, delimited with line breaks.
+
+
+
+
+
+ This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
+
+
+
+
+ Controls if .pdbs for reference assemblies are also embedded.
+
+
+
+
+ Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
+
+
+
+
+ As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
+
+
+
+
+ Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
+
+
+
+
+ Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
+
+
+
+
+ A list of unmanaged 32 bit assembly names to include, delimited with |.
+
+
+
+
+ A list of unmanaged 64 bit assembly names to include, delimited with |.
+
+
+
+
+ The order of preloaded assemblies, delimited with |.
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/ZKuP/GrantParkausweis.xaml b/ZKuP/GrantParkausweis.xaml
new file mode 100644
index 0000000..e4241ef
--- /dev/null
+++ b/ZKuP/GrantParkausweis.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/GrantParkausweis.xaml.cs b/ZKuP/GrantParkausweis.xaml.cs
new file mode 100644
index 0000000..11c8a86
--- /dev/null
+++ b/ZKuP/GrantParkausweis.xaml.cs
@@ -0,0 +1,135 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für GrantParkausweis.xaml
+ ///
+ public partial class GrantParkausweis : Window
+ {
+ public GrantParkausweis()
+ {
+ InitializeComponent();
+
+ var list = SQL.ReadSQL($"SELECT * FROM zkup.parkausweise WHERE Genehmigt = '0'").Result;
+ dgGrant.DataContext = list;
+ }
+
+ private async void btnGrant_Click(object sender, RoutedEventArgs e)
+ {
+ var arr = ((sender as Button).DataContext as System.Data.DataRowView).Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Möchten Sie den Parkausweis für {arr[1].ToString()} {arr[2].ToString()} sicher genehmigen?", "Sicher?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"UPDATE parkausweise SET Genehmigt = '1', Genehmiger = '{Environment.UserName}' WHERE idparkausweise = '{(int)arr[0]}'");
+
+ SendMail((int)arr[0], $"{arr[1].ToString()} {arr[2].ToString()}", arr[3].ToString(), arr[4].ToString(), arr[7].ToString(), true);
+
+ var list = SQL.ReadSQL($"SELECT * FROM zkup.parkausweise WHERE Genehmigt = '0'").Result;
+ dgGrant.DataContext = list;
+ }
+ }
+
+ private async void btnDecline_Click(object sender, RoutedEventArgs e)
+ {
+ var arr = ((sender as Button).DataContext as System.Data.DataRowView).Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Möchten Sie den Parkausweis für {arr[1].ToString()} {arr[2].ToString()} sicher ablehnen?\n\nDer Antrag wird dadurch gelöscht!", "Sicher?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.parkausweise WHERE idparkausweise = '{(int)arr[0]}'");
+
+ SendMail((int)arr[0], $"{arr[1].ToString()} {arr[2].ToString()}", "", arr[4].ToString(), "", false);
+
+ var list = SQL.ReadSQL($"SELECT * FROM zkup.parkausweise WHERE Genehmigt = '0'").Result;
+ dgGrant.DataContext = list;
+ }
+ }
+
+
+
+ public void SendMail(int id, string Name, string Kennzeichen, string Email, string Firma, bool Genehmigt)
+ {
+ var user = System.Text.RegularExpressions.Regex.Split(Environment.UserName, @"(? DataTableToGrant(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (System.Data.DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Grant()
+ {
+ idparkausweise = (int)dr[0],
+ MA_Vorname = dr[1].ToString(),
+ MA_Name = dr[2].ToString(),
+ Kennzeichen = dr[3].ToString(),
+ Email = dr[4].ToString(),
+ Telefon = dr[5].ToString(),
+ Abteilung = dr[6].ToString(),
+ Firma = dr[7].ToString(),
+ Adresse = dr[8].ToString(),
+ PLZ = dr[9].ToString(),
+ Vorgesetzter = dr[10].ToString(),
+ Schicht = (int)dr[11]
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/Helper.cs b/ZKuP/Helper.cs
new file mode 100644
index 0000000..2c8972d
--- /dev/null
+++ b/ZKuP/Helper.cs
@@ -0,0 +1,446 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using Word = Microsoft.Office.Interop.Word;
+
+namespace ZKuP
+{
+ class Helper
+ {
+
+ public static List> DataTableToTuple(System.Data.DataTable dataTable)
+ {
+ List> x = new List>();
+
+ foreach (System.Data.DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Tuple(dr[0].ToString(), dr[1].ToString()));
+ }
+
+ return x;
+ }
+
+
+ public static List DataTableToListString(System.Data.DataTable dataTable, int Columns = 1, int startColumn = 0)
+ {
+ switch (Columns)
+ {
+ case 1:
+ return (from System.Data.DataRow dr in dataTable.Rows select dr[startColumn + 0].ToString()).ToList();
+ break;
+ case 2:
+ return (from System.Data.DataRow dr in dataTable.Rows select dr[startColumn + 0].ToString() + " " + dr[startColumn + 1].ToString()).ToList();
+ break;
+
+
+ default:
+ return (from System.Data.DataRow dr in dataTable.Rows select dr[0].ToString()).ToList();
+ }
+ }
+
+ public static IEnumerable FindVisualChildren(DependencyObject depObj,
+ string name) where T : DependencyObject
+ {
+ if (depObj != null)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
+ if (child != null && child is T &&
+ (child as FrameworkElement).Name.Equals(name))
+ {
+ yield return (T)child;
+ }
+
+ foreach (T childOfChild in FindVisualChildren(child, name))
+ {
+ yield return childOfChild;
+ }
+ }
+ }
+ }
+
+ public static Parent FindParent(DependencyObject child)
+ where Parent : DependencyObject
+ {
+ DependencyObject parentObject = child;
+
+ //We are not dealing with Visual, so either we need to fnd parent or
+ //get Visual to get parent from Parent Heirarchy.
+ while (!((parentObject is System.Windows.Media.Visual)
+ || (parentObject is System.Windows.Media.Media3D.Visual3D)))
+ {
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ parentObject = (parentObject as FrameworkContentElement).Parent;
+ }
+ }
+
+ //We have not found parent yet , and we have now visual to work with.
+ parentObject = VisualTreeHelper.GetParent(parentObject);
+
+ //check if the parent matches the type we're looking for
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ //use recursion to proceed with next level
+ return FindParent(parentObject);
+ }
+ }
+
+
+ public static DependencyObject GetScrollViewer(DependencyObject o)
+ {
+ // Return the DependencyObject if it is a ScrollViewer
+ if (o is System.Windows.Controls.ScrollViewer)
+ { return o; }
+
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(o); i++)
+ {
+ var child = VisualTreeHelper.GetChild(o, i);
+
+ var result = GetScrollViewer(child);
+ if (result == null)
+ {
+ continue;
+ }
+ else
+ {
+ return result;
+ }
+ }
+ return null;
+ }
+
+
+
+ public static void SendMail(string body = "")
+ {
+ if (body != "") body = "Exception:%0D%0A%0D%0A" + body;
+
+ System.Diagnostics.Process.Start($"mailto:marcus.bachler@deutschebahn.com?subject=Fehlermeldung_ZKuP&body=" + body);
+ }
+
+ public static string InsertSpaceBeforeUpperCase(string str)
+ {
+ var sb = new StringBuilder();
+
+ char previousChar = char.MinValue; // Unicode '\0'
+
+ foreach (char c in str)
+ {
+ if (char.IsUpper(c))
+ {
+ // If not the first character and previous character is not a space, insert a space before uppercase
+
+ if (sb.Length != 0 && previousChar != ' ')
+ {
+ sb.Append(' ');
+ }
+ }
+
+ sb.Append(c);
+
+ previousChar = c;
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// Load a resource WPF-BitmapImage (png, bmp, ...) from embedded resource defined as 'Resource' not as 'Embedded resource'.
+ ///
+ /// Path without starting slash
+ /// Usually 'Assembly.GetExecutingAssembly()'. If not mentionned, I will use the calling assembly
+ ///
+ public static System.Drawing.Bitmap LoadBitmapFromResource(string pathInApplication, System.Reflection.Assembly assembly = null)
+ {
+ if (assembly == null)
+ {
+ assembly = System.Reflection.Assembly.GetCallingAssembly();
+ }
+
+ if (pathInApplication[0] == '/')
+ {
+ pathInApplication = pathInApplication.Substring(1);
+ }
+ return BitmapImage2Bitmap(new System.Windows.Media.Imaging.BitmapImage(new Uri(@"pack://application:,,,/" + assembly.GetName().Name + ";component/" + pathInApplication, UriKind.Absolute)));
+ }
+
+ private static System.Drawing.Bitmap BitmapImage2Bitmap(System.Windows.Media.Imaging.BitmapImage bitmapImage)
+ {
+ // BitmapImage bitmapImage = new BitmapImage(new Uri("../Images/test.png", UriKind.Relative));
+
+ using (System.IO.MemoryStream outStream = new System.IO.MemoryStream())
+ {
+ System.Windows.Media.Imaging.BitmapEncoder enc = new System.Windows.Media.Imaging.TiffBitmapEncoder();
+ enc.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bitmapImage));
+ enc.Save(outStream);
+ System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(outStream);
+
+ return new System.Drawing.Bitmap(bitmap);
+ }
+ }
+
+
+ ///
+ /// Takes a bitmap and converts it to an image that can be handled by WPF ImageBrush
+ ///
+ /// A bitmap image
+ /// The image as a BitmapImage for WPF
+ public static BitmapImage ConvertBitmapToImage(System.Drawing.Bitmap src)
+ {
+ System.IO.MemoryStream ms = new System.IO.MemoryStream();
+ src.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
+ BitmapImage image = new BitmapImage();
+ image.BeginInit();
+ ms.Seek(0, System.IO.SeekOrigin.Begin);
+ image.StreamSource = ms;
+ image.EndInit();
+ return image;
+ }
+
+
+ public static BitmapImage ConvertByteArrayToBitmapImage(Byte[] bytes)
+ {
+ var stream = new System.IO.MemoryStream(bytes);
+ stream.Seek(0, System.IO.SeekOrigin.Begin);
+ var image = new System.Windows.Media.Imaging.BitmapImage();
+ image.BeginInit();
+ image.StreamSource = stream;
+ image.EndInit();
+ return image;
+ }
+
+
+ public static bool OpenAndEditWord(string Name, string Kennzeichen, string Firma, string Nr)
+ {
+ try
+ {
+ using (var regWord = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("Word.Application"))
+ {
+ if (regWord == null)
+ {
+ MessageBox.Show("Microsoft Word wird benötigt, ist aber nicht installiert\nFunktion kann nicht ausgeführt werden", "Word nicht installiert", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ else
+ {
+ //Console.WriteLine("Microsoft Word is installed");
+
+ Word.Application wordApp = new Word.Application();
+
+ wordApp.Visible = true;
+
+ Word.Document document = wordApp.Documents.OpenNoRepairDialog("https://dbsw.sharepoint.com/:w:/r/sites/PfoertnerWerkMuenche/Freigegebene%20Dokumente/DBSecurity/Parkkarte_Template_ab_2020.dotx");
+
+ //Word.Document document = wordApp.Documents.OpenNoRepairDialog(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\Parkkarte_Template_ab_2020.dotx");
+ document.Activate();
+
+ Word.Table table = document.Tables[1];
+ table.Cell(1, 2).Range.Text = Nr;
+ table.Cell(3, 2).Range.Text = Kennzeichen;
+ table.Cell(4, 2).Range.Text = Firma;
+
+ Word.Table table2 = document.Tables[2];
+ table2.Cell(1, 1).Range.Text = Name;
+
+ Word.Dialog dialog = null;
+ dialog = wordApp.Dialogs[Word.WdWordDialog.wdDialogFilePrint];
+ var dialogResult = dialog.Show();
+ if (dialogResult == 1)
+ {
+ document.PrintOut(false);
+ }
+ else if (dialogResult == -1)
+ {
+ document.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
+ wordApp.Quit();
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show($"Fehlermeldung:\n\n{ex.Message}", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error);
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+
+
+
+ public class ConvertToBackground : System.Windows.Data.IValueConverter
+ {
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string input = value.ToString().Substring(0, 2);
+ switch (input)
+ {
+ case "Pr"://üfen!
+ return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightYellow);
+ case "OK":
+ return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGreen);
+ case "Fe"://hler!
+ return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightSalmon);
+ case "Nu":
+ return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Orange);
+ default:
+ return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray);
+ }
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class ConvertToBackground2 : System.Windows.Data.IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string input = value.ToString().Split(' ')[0];
+ if (input == "Besucher:")
+ return 1;
+ else
+ return 0;
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ //public class ConvertDateToBackground : System.Windows.Data.IValueConverter
+ //{
+
+ // public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ // {
+ // string input = System.Convert.ToDateTime(value).ToShortDateString();
+ // switch (input)
+ // {
+ // case "01.01.1902"://üfen!
+ // return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
+ // default:
+ // return new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);
+ // }
+
+ // }
+
+ // public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ // {
+ // throw new NotImplementedException();
+ // }
+ //}
+
+ public class IntToCategory : System.Windows.Data.IValueConverter
+ {
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string input = value as string;
+ switch (input)
+ {
+ case "1":
+ return "Fremdfirma";
+ case "2":
+ return "Besucher";
+ case "3":
+ return "Lieferant";
+ default:
+ return "Fehler!";
+ }
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class BoolToCheckBox : System.Windows.Data.IValueConverter
+ {
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+
+ int input = value != null ? System.Convert.ToInt16(value) : 0;
+
+ switch (input)
+ {
+ case 1:
+ return true;
+ case 0:
+ return false;
+ default:
+ return false;
+ }
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ bool input = System.Convert.ToBoolean(value);
+ switch (input)
+ {
+ case true:
+ return 1;
+ case false:
+ return 0;
+ default:
+ return 0;
+ }
+ }
+ }
+
+ public class MultiToBackground : System.Windows.Data.IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ try
+ {
+ if (System.Convert.ToInt16(values[0]) <= System.Convert.ToInt16(values[1]))
+ return new SolidColorBrush(Colors.LightGreen);
+ else return new SolidColorBrush(Colors.LightYellow);
+
+ }
+ catch (Exception)
+ {
+ return new SolidColorBrush(Colors.LightYellow);
+ }
+ }
+
+ public object[] ConvertBack(object values, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+
+
+
+
+
+
+}
diff --git a/ZKuP/ImageView.xaml b/ZKuP/ImageView.xaml
new file mode 100644
index 0000000..1c45192
--- /dev/null
+++ b/ZKuP/ImageView.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ImageView.xaml.cs b/ZKuP/ImageView.xaml.cs
new file mode 100644
index 0000000..7dd3b60
--- /dev/null
+++ b/ZKuP/ImageView.xaml.cs
@@ -0,0 +1,152 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ImageView.xaml
+ ///
+ public partial class ImageView : Window
+ {
+
+ public ImageView(BitmapImage image, bool showComboBox = false)
+ {
+ InitializeComponent();
+
+ if (!showComboBox) { cBSignature.Visibility = Visibility.Collapsed; dPDate.Visibility = Visibility.Collapsed; }
+ else { cBSignature.Visibility = Visibility.Visible; dPDate.Visibility = Visibility.Visible; }
+
+ if (image != null)
+ imageSignature.Source = image;
+ else
+ {
+ var list = SQL.ReadDateTimeAndStringList($"SELECT Zutritt,Name FROM zkup.zutritteLog").Result;
+
+ cBSignature.ItemsSource = list.OrderByDescending(p => p);
+ }
+ }
+
+ private void cBSignature_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (cBSignature.SelectedItem != null && cBSignature.SelectedIndex != -1)
+ {
+ var i = SQL.ReadSingleByteArr($"SELECT signature_blob FROM zkup.zutritteLog WHERE Name = '{cBSignature.SelectedItem.ToString().Split(';')[1]}' AND Zutritt = '{cBSignature.SelectedItem.ToString().Split(';')[0]}'");
+
+
+ if (i != null)
+ imageSignature.Source = Helper.ConvertBitmapToImage(i);
+ else
+ imageSignature.Source = new BitmapImage(new Uri(@"/Resources/NoSignature.png", UriKind.Relative));
+ //MessageBox.Show(this, "Keine Unterschrift vorhanden!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dPDate.SelectedDate.HasValue)
+ {
+ if (dPDate.SelectedDate.Value >= DateTime.Now.Date) btnUp.IsEnabled = false;
+ else if (dPDate.SelectedDate.Value < DateTime.Now.Date) btnUp.IsEnabled = true;
+ }
+
+ Filtern();
+ }
+
+ private void btnToday_Click(object sender, RoutedEventArgs e)
+ {
+ dPDate.SelectedDate = DateTime.Now;
+ }
+
+ private void btnDown_Click(object sender, RoutedEventArgs e)
+ {
+ if (dPDate.SelectedDate.HasValue) dPDate.SelectedDate = dPDate.SelectedDate.Value - TimeSpan.FromDays(1);
+ else dPDate.SelectedDate = DateTime.Now;
+ }
+
+ private void btnUp_Click(object sender, RoutedEventArgs e)
+ {
+ if (dPDate.SelectedDate.HasValue && dPDate.SelectedDate.Value < DateTime.Now.Date) dPDate.SelectedDate = dPDate.SelectedDate.Value + TimeSpan.FromDays(1);
+ else dPDate.SelectedDate = DateTime.Now;
+ }
+
+ private void btnFiltern_Click(object sender, RoutedEventArgs e)
+ {
+ Filtern();
+ }
+
+ private void tbFilter_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ lblFilter.Visibility = Visibility.Hidden;
+ }
+
+ private void tbFilter_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(tbFilter.Text)) lblFilter.Visibility = Visibility.Visible;
+ }
+
+ private void tbFilter_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if(e.Key == Key.Enter)
+ Filtern();
+ }
+
+ private void Filtern()
+ {
+ string withSign = "";
+ if (cbOnlyWithSignature.IsChecked.Value) withSign = " AND signature_blob IS NOT NULL";
+
+ if (dPDate.SelectedDate.HasValue && !string.IsNullOrWhiteSpace(tbFilter.Text))
+ {
+ var list = SQL.ReadDateTimeAndStringList($"SELECT Zutritt,Name FROM zkup.zutritteLog WHERE Zutritt LIKE '%{(dPDate).SelectedDate.Value.ToString("yyyy-MM-dd")}%' AND Name LIKE '%{tbFilter.Text}%'{withSign}").Result;
+
+ cBSignature.ItemsSource = list.OrderByDescending(p => p);
+ }
+ else if (!dPDate.SelectedDate.HasValue && !string.IsNullOrWhiteSpace(tbFilter.Text))
+ {
+ var list = SQL.ReadDateTimeAndStringList($"SELECT Zutritt,Name FROM zkup.zutritteLog WHERE Name LIKE '%{tbFilter.Text}%'{withSign}").Result;
+
+ cBSignature.ItemsSource = list.OrderByDescending(p => p);
+ }
+ else if (dPDate.SelectedDate.HasValue && string.IsNullOrWhiteSpace(tbFilter.Text))
+ {
+ var list = SQL.ReadDateTimeAndStringList($"SELECT Zutritt,Name FROM zkup.zutritteLog WHERE Zutritt LIKE '%{(dPDate).SelectedDate.Value.ToString("yyyy-MM-dd")}%'{withSign}").Result;
+
+ cBSignature.ItemsSource = list.OrderByDescending(p => p);
+ }
+ else if (!dPDate.SelectedDate.HasValue && string.IsNullOrWhiteSpace(tbFilter.Text))
+ {
+ if (cbOnlyWithSignature.IsChecked.Value) withSign = " WHERE signature_blob IS NOT NULL";
+ cbOnlyWithSignature.IsChecked = false;
+ var list = SQL.ReadDateTimeAndStringList($"SELECT Zutritt,Name FROM zkup.zutritteLog{withSign}").Result;
+
+ cBSignature.ItemsSource = list.OrderByDescending(p => p);
+ }
+
+ if (cBSignature.Items.Count == 0) cBSignature.ItemsSource = new List() { "Keine Einträge gefunden..." };
+
+ cBSignature.IsDropDownOpen = false;
+ cBSignature.IsDropDownOpen = true;
+ }
+
+ private void cbOnlyWithSignature_Unchecked(object sender, RoutedEventArgs e)
+ {
+ Filtern();
+ }
+
+ private void cbOnlyWithSignature_Checked(object sender, RoutedEventArgs e)
+ {
+ Filtern();
+ }
+ }
+}
diff --git a/ZKuP/Log.cs b/ZKuP/Log.cs
new file mode 100644
index 0000000..64369ed
--- /dev/null
+++ b/ZKuP/Log.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZKuP
+{
+ class Log
+ {
+ static string path = @"\\muenas001.wb4fv.db.de\GLW99\ZKuP\Log\log.log";
+
+ public static void WriteLog(string Message)
+ {
+ File.AppendAllText(path, $"\n--------------------------------\n{DateTime.Now.ToString("dd.MM.yy HH:mm:ss")} | {Environment.UserName} | {Environment.MachineName}: Message:\n{Message}\n\n");
+ }
+ }
+}
diff --git a/ZKuP/MainWindow - Kopieren.xaml b/ZKuP/MainWindow - Kopieren.xaml
new file mode 100644
index 0000000..802deeb
--- /dev/null
+++ b/ZKuP/MainWindow - Kopieren.xaml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/MainWindow - Kopieren.xaml.cs b/ZKuP/MainWindow - Kopieren.xaml.cs
new file mode 100644
index 0000000..5b205cf
--- /dev/null
+++ b/ZKuP/MainWindow - Kopieren.xaml.cs
@@ -0,0 +1,625 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.DirectoryServices.AccountManagement;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Security.Permissions;
+using System.Security.Principal;
+using System.Text;
+using System.Threading;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace ZKuP
+{
+ ///
+ /// Interaktionslogik für MainWindow.xaml
+ ///
+ public partial class MainWindow : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+
+ private List firmenList;
+ public List FirmenList
+ {
+ get { return firmenList; }
+ set { firmenList = value; OnPropertyChanged(); }
+ }
+
+ DataTable firmen = new DataTable("firmen");
+
+ private List besucherList;
+ public List BesucherList
+ {
+ get { return besucherList; }
+ set { besucherList = value; OnPropertyChanged(); }
+ }
+
+ DataTable besucher = new DataTable("besucher");
+
+
+ private List overview = new List();
+ public List Overviews
+ {
+ get { return overview; }
+ set { overview = value; OnPropertyChanged(); }
+ }
+
+ DataTable overv = new DataTable("Overview");
+
+ public List Kategorien { get; set; } = new List();
+
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
+
+ AuthenticateUser();
+ }
+
+ private async void AuthenticateUser()
+ {
+ if (AuthenticateDomain())
+ {
+ if (!Thread.CurrentPrincipal.Identity.IsAuthenticated)
+ {
+ MessageBox.Show($"Ihr User {Thread.CurrentPrincipal.Identity.Name} ist nicht zum Zugriff berechtigt", "Zugriff verweigert");
+ Application.Current.Shutdown();
+ return;
+ }
+ else
+ {
+ string auth = "";
+ string role = "";
+
+ auth = await SQL.ReadSingleValue($"SELECT EXISTS(SELECT * FROM users WHERE `Username` = '{Environment.UserName}')");
+
+ if (auth == "1")
+ role = await SQL.ReadSingleValue($"SELECT Role FROM users WHERE `Username` = '{Environment.UserName}'");
+ else
+ {
+ MessageBox.Show($"Ihr User {Thread.CurrentPrincipal.Identity.Name} ist nicht zum Zugriff berechtigt", "Zugriff verweigert");
+ Application.Current.Shutdown();
+ return;
+ }
+
+ switch (role)
+ {
+ case "0":
+ PfoertnerStart();
+ break;
+ case "1":
+ EditorStart();
+ break;
+ case "2":
+ AdminStart();
+ break;
+ default:
+ PfoertnerStart();
+ break;
+ }
+
+ Kategorien.Add("Fremdfirma");
+ Kategorien.Add("Besucher");
+
+ firmen = await SQL.ReadSQL($"SELECT Name FROM firmen", firmen);
+ besucher = await SQL.ReadSQL($"SELECT Name From besucher", besucher);
+
+ FirmenList = DataTableToFirmenList(firmen);
+ BesucherList = DataTableToFirmenList(besucher);
+
+ overv = await SQL.ReadSQL("SELECT * FROM zutritte", overv);
+
+ //Overviews = DataTableToOverview(overv);
+ dgOverview.DataContext = overv;
+ }
+ }
+ else
+ {
+ MessageBox.Show("User nicht in der Domäne aktiviert");
+ Application.Current.Shutdown();
+ return;
+ }
+ }
+
+ private bool AuthenticateDomain()
+ {
+ using (var domainContext = new PrincipalContext(ContextType.Domain, Environment.UserDomainName))
+ {
+ using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, Environment.UserName))
+ {
+ if (foundUser.Enabled.HasValue)
+ {
+ return (bool)foundUser.Enabled;
+ }
+ else
+ {
+ return false; //or false depending what result you want in the case of Enabled being NULL
+ }
+ }
+ }
+ }
+
+ private void AdminStart()
+ {
+ btnManageUsers.Visibility = Visibility.Visible;
+ btnCreateVisitor.Visibility = Visibility.Visible;
+ btnCreateFirma.Visibility = Visibility.Visible;
+
+ //MessageBox.Show("Sie sind Admin");
+ // something that only an admin user should be able to do
+ }
+
+ private void EditorStart()
+ {
+ btnCreateVisitor.Visibility = Visibility.Visible;
+ btnCreateFirma.Visibility = Visibility.Visible;
+ btnManageUsers.Visibility = Visibility.Collapsed;
+
+
+ //MessageBox.Show("Sie sind Editor");
+ // something that only an admin user should be able to do
+ }
+
+ private void PfoertnerStart()
+ {
+ btnCreateVisitor.Visibility = Visibility.Collapsed;
+ btnManageUsers.Visibility = Visibility.Collapsed;
+ btnCreateFirma.Visibility = Visibility.Collapsed;
+ //MessageBox.Show("Sie sind Pförtner");
+ // something that only an admin user should be able to do
+ }
+
+
+
+ private async void ComboBox_DropDownOpened(object sender, EventArgs e)
+ {
+ var box = sender as ComboBox;
+ DataGridRow dataGridRow = FindParent(box);
+ int index = dataGridRow.GetIndex();
+
+ //TextBlock persnummer = null;
+ var KatFramework = dgOverview.Columns[1].GetCellContent(dgOverview.Items[index]);
+ var Kat = FindVisualChild(KatFramework);
+
+
+ if (Kat.Text == "Fremdfirma")
+ firmen = await SQL.ReadSQL($"SELECT Name FROM firmen", firmen);
+
+ //firmen = await SQL.ReadSQL($"SELECT Name FROM firmen", firmen);
+ //FirmenList = DataTableToFirmenList(firmen);
+ if (Kat.SelectedIndex == -1)
+ FirmenList.Add("Zuerst Kategorie wählen");
+ //if (t.Count >= 1)
+ if (Kat.Text == "Fremdfirma")
+ {
+ FirmenList = DataTableToFirmenList(firmen);
+ if (Kat.SelectedIndex == -1)
+ FirmenList.Add("Zuerst Kategorie wählen");
+
+ box.ItemsSource = FirmenList;
+ }
+ }
+
+
+ private async void ComboBox_Besucher_DropDownOpened_1(object sender, EventArgs e)
+ {
+ var box = sender as ComboBox;
+ DataGridRow dataGridRow = FindParent(box);
+ int index = dataGridRow.GetIndex();
+
+ //TextBlock persnummer = null;
+ var KatFramework = dgOverview.Columns[1].GetCellContent(dgOverview.Items[index]);
+ var Kat = FindVisualChild(KatFramework);
+
+
+ if (Kat.Text == "Besucher")
+ besucher = await SQL.ReadSQL($"SELECT Name From besucher", besucher);
+
+ if (Kat.Text == "Besucher")
+ {
+ BesucherList = DataTableToFirmenList(besucher);
+ if (Kat.SelectedIndex == -1)
+ BesucherList.Add("Zuerst Kategorie wählen");
+
+ box.ItemsSource = BesucherList;
+ }
+ }
+
+
+
+ string selectedKategorie = "";
+ private void ComboBox_DropDownClosed_1(object sender, EventArgs e)
+ {
+ selectedKategorie = (sender as ComboBox).Text;
+ }
+ string selectedFirma = "";
+ private void ComboBox_DropDownClosed(object sender, EventArgs e)
+ {
+ selectedFirma = (sender as ComboBox).Text;
+ }
+ string selectedBesucher = "";
+ private void ComboBox_Besucher_DropDownClosed_2(object sender, EventArgs e)
+ {
+ selectedBesucher = (sender as ComboBox).Text;
+ }
+
+ private async void CheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ //var box = sender as CheckBox;
+ //DataGridRow dataGridRow = FindParent(box);
+ //int index = dataGridRow.GetIndex();
+
+ //var stamp = dgOverview.Columns[4].GetCellContent(dgOverview.Items[index]) as TextBlock;
+ //var time = DateTime.Now.ToString("dd.MM.yyyy HH:mm");
+ //stamp.Text = time;
+
+
+ //var checkEinweisung = await SQL.ReadSingleValue($"SELECT Örtliche_Einweisung_bis FROM firmen WHERE Name = '{selectedFirma}'");
+
+
+ //var einweis = dgOverview.Columns[6].GetCellContent(dgOverview.Items[index]) as TextBlock;
+ //var zutritt = dgOverview.Columns[5].GetCellContent(dgOverview.Items[index]) as TextBlock;
+
+ //if (Convert.ToDateTime(time) > Convert.ToDateTime(checkEinweisung))
+ //{
+ // einweis.Text = "Prüfen!";
+ // einweis.Background = new SolidColorBrush(Colors.Red);
+ //}
+ //else
+ //{
+ // einweis.Text = "OK!";
+ // einweis.Background = new SolidColorBrush(Colors.Green);
+ //}
+
+ //var checkZutritt = await SQL.ReadSingleValue($"SELECT Arbeitsende FROM firmen WHERE Name = '{selectedFirma}'");
+
+
+ //if (Convert.ToDateTime(time) > Convert.ToDateTime(checkZutritt))
+ //{
+ // zutritt.Text = "Prüfen!";
+ // zutritt.Background = new SolidColorBrush(Colors.Red);
+ //}
+ //else
+ //{
+ // zutritt.Text = "OK!";
+ // zutritt.Background = new SolidColorBrush(Colors.Green);
+ //}
+
+
+ //await SQL.WriteSQL($"INSERT INTO zutritte (Kategorie,Firma_Name,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung) VALUES ('{selectedKategorie}','{selectedFirma}','{Convert.ToDateTime(time).ToString("yyyy-MM-dd HH:mm:ss")}','{zutritt.Text}','{einweis.Text}')");
+ //overv = await SQL.ReadSQL("SELECT * FROM zutritte", overv);
+ //dgOverview.DataContext = overv;
+ ////overv.NewRow();
+ ////Overviews = DataTableToOverview(overv);
+
+ //dgOverview.CommitEdit(DataGridEditingUnit.Row,true);
+ }
+
+ private void DgOverview_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ e.Cancel = true;
+ }
+
+
+
+
+
+ private void BtnManageUsers_Click(object sender, RoutedEventArgs e)
+ {
+ ManageUsers mU = new ManageUsers();
+ mU.ShowDialog();
+ }
+
+ private void BtnCreateVisitor_Click(object sender, RoutedEventArgs e)
+ {
+ CreateVisitor cV = new CreateVisitor();
+ cV.ShowDialog();
+ }
+
+ private void BtnCreateFirma_Click(object sender, RoutedEventArgs e)
+ {
+ CreateFirma cF = new CreateFirma();
+ cF.ShowDialog();
+ }
+
+
+
+
+
+
+ public static List DataTableToFirmenList(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(dr[0].ToString());
+ }
+
+ return x;
+ }
+
+ public static List DataTableToOverview(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Overview()
+ {
+ Kategorie = dr[1].ToString(),
+ NameFirma = dr[2].ToString(),
+ NameBesucher = dr[3].ToString(),
+ Zutritt = dr[4].ToString(),
+ Pruefung_Zutritt = dr[5].ToString(),
+ Pruefung_Einweisung = dr[6].ToString()
+ });
+ }
+
+ return x;
+ }
+
+
+ public static Parent FindParent(DependencyObject child)
+ where Parent : DependencyObject
+ {
+ DependencyObject parentObject = child;
+
+ //We are not dealing with Visual, so either we need to fnd parent or
+ //get Visual to get parent from Parent Heirarchy.
+ while (!((parentObject is System.Windows.Media.Visual)
+ || (parentObject is System.Windows.Media.Media3D.Visual3D)))
+ {
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ parentObject = (parentObject as FrameworkContentElement).Parent;
+ }
+ }
+
+ //We have not found parent yet , and we have now visual to work with.
+ parentObject = VisualTreeHelper.GetParent(parentObject);
+
+ //check if the parent matches the type we're looking for
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ //use recursion to proceed with next level
+ return FindParent(parentObject);
+ }
+ }
+
+ public static IEnumerable FindVisualChildren(DependencyObject depObj)
+ where T : DependencyObject
+ {
+ if (depObj != null)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
+ if (child != null && child is T)
+ {
+ yield return (T)child;
+ }
+
+ foreach (T childOfChild in FindVisualChildren(child))
+ {
+ yield return childOfChild;
+ }
+ }
+ }
+ }
+
+ public static childItem FindVisualChild(DependencyObject obj)
+ where childItem : DependencyObject
+ {
+ foreach (childItem child in FindVisualChildren(obj))
+ {
+ return child;
+ }
+
+ return null;
+ }
+
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ private void DgOverview_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //foreach (var cell in dgOverview.Items)
+ //{
+ // if (cell is DataRowView)
+ // {
+ // //DataRowView view = cell as DataRowView;
+ // //if (view.Row.ItemArray[5].ToString() == "Prüfen!")
+ // // (view.Row.ItemArray[5] as DataGridCell).Background = new SolidColorBrush(Colors.Red);
+ // //else if (view.Row.ItemArray[5].ToString() == "OK!")
+ // // (view.Row..ItemArray[5] as DataGridCell).Background = new SolidColorBrush(Colors.Red);
+
+ // //if (cell.Content.ToString() == "OK!") cell.Background = new SolidColorBrush(Colors.Green);
+ // }
+ //}
+ }
+
+ private void DgOverview_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
+ {
+ foreach (DataGridCell cell in dgOverview.Items)
+ {
+ if (cell.Content.ToString() == "Prüfen!") cell.Background = new SolidColorBrush(Colors.Red);
+
+ if (cell.Content.ToString() == "OK!") cell.Background = new SolidColorBrush(Colors.Green);
+ }
+ }
+
+ private async void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var box = sender as Button;
+ DataGridRow dataGridRow = FindParent(box);
+
+
+ int index = dataGridRow.GetIndex();
+
+ if (dgOverview.Items.Count - 1 == index)
+ {
+ var KatFramework = dgOverview.Columns[1].GetCellContent(dgOverview.Items[index]);
+ var FirmFramework = dgOverview.Columns[2].GetCellContent(dgOverview.Items[index]);
+ var BesuchFramework = dgOverview.Columns[3].GetCellContent(dgOverview.Items[index]);
+
+ var Kat = FindVisualChild(KatFramework);
+ var Firm = FindVisualChild(FirmFramework);
+ var Besuch = FindVisualChild(BesuchFramework);
+
+
+
+ if (Kat.SelectedIndex == -1)
+ MessageBox.Show("Bitte Kategorie wählen", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ else if (Firm.SelectedIndex == -1 && Besuch.SelectedIndex == -1)
+ MessageBox.Show("Bitte Firma/Besucher wählen", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ else
+ {
+ var stamp = dgOverview.Columns[5].GetCellContent(dgOverview.Items[index]) as TextBlock;
+ var time = DateTime.Now.ToString("dd.MM.yyyy HH:mm");
+ stamp.Text = time;
+
+ var checkEinweisung = "";
+ var checkZutritt = "";
+
+ if (Kat.Text == "Fremdfirma")
+ checkEinweisung = await SQL.ReadSingleValue($"SELECT Örtliche_Einweisung_bis FROM firmen WHERE Name = '{selectedFirma}'");
+ else if (Kat.Text == "Besucher")
+ checkEinweisung = await SQL.ReadSingleValue($"SELECT Unterwiesen_Bis FROM besucher WHERE Name = '{selectedBesucher}'");
+
+ var einweis = dgOverview.Columns[6].GetCellContent(dgOverview.Items[index]) as TextBlock;
+ var zutritt = dgOverview.Columns[5].GetCellContent(dgOverview.Items[index]) as TextBlock;
+
+ if (Convert.ToDateTime(time) > Convert.ToDateTime(checkEinweisung))
+ {
+ einweis.Text = "Prüfen!";
+ einweis.Background = new SolidColorBrush(Colors.Red);
+ }
+ else
+ {
+ einweis.Text = "OK!";
+ einweis.Background = new SolidColorBrush(Colors.Green);
+ }
+
+ if (Kat.Text == "Fremdfirma")
+ {
+ checkZutritt = await SQL.ReadSingleValue($"SELECT Arbeitsende FROM firmen WHERE Name = '{selectedFirma}'");
+
+ if (Convert.ToDateTime(time) > Convert.ToDateTime(checkZutritt))
+ {
+ zutritt.Text = "Prüfen!";
+ zutritt.Background = new SolidColorBrush(Colors.Red);
+ }
+ else
+ {
+ zutritt.Text = "OK!";
+ zutritt.Background = new SolidColorBrush(Colors.Green);
+ }
+
+ if (Convert.ToDateTime(time) > Convert.ToDateTime(checkZutritt))
+ {
+ zutritt.Text = "Prüfen!";
+ zutritt.Background = new SolidColorBrush(Colors.Red);
+ }
+ else
+ {
+ zutritt.Text = "OK!";
+ zutritt.Background = new SolidColorBrush(Colors.Green);
+ }
+
+ await SQL.WriteSQL($"INSERT INTO zutritte (Kategorie,NameFirma,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung) VALUES ('{selectedKategorie}','{selectedFirma}','{Convert.ToDateTime(time).ToString("yyyy-MM-dd HH:mm:ss")}','{zutritt.Text}','{einweis.Text}')");
+ }
+ else if (Kat.Text == "Besucher")
+ {
+ checkZutritt = await SQL.ReadSingleValue($"SELECT Besuchstag FROM besucher WHERE Name = '{selectedBesucher}'");
+
+ if (Convert.ToDateTime(time).Date != Convert.ToDateTime(checkZutritt).Date)
+ {
+ zutritt.Text = "Prüfen!";
+ zutritt.Background = new SolidColorBrush(Colors.Red);
+ }
+ else
+ {
+ zutritt.Text = "OK!";
+ zutritt.Background = new SolidColorBrush(Colors.Green);
+ }
+
+ if (Convert.ToDateTime(time).Date != Convert.ToDateTime(checkZutritt).Date)
+ {
+ zutritt.Text = "Prüfen!";
+ zutritt.Background = new SolidColorBrush(Colors.Red);
+ }
+ else
+ {
+ zutritt.Text = "OK!";
+ zutritt.Background = new SolidColorBrush(Colors.Green);
+ }
+
+ await SQL.WriteSQL($"INSERT INTO zutritte (Kategorie,NameBesucher,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung) VALUES ('{selectedKategorie}','{selectedBesucher}','{Convert.ToDateTime(time).ToString("yyyy-MM-dd HH:mm:ss")}','{zutritt.Text}','{einweis.Text}')");
+ }
+
+
+
+
+
+ //await SQL.WriteSQL($"INSERT INTO zutritte (Kategorie,Name,Zutritt,Pruefung_Zutritt,Pruefung_Einweisung) VALUES ('{selectedKategorie}','{selectedFirma}','{Convert.ToDateTime(time).ToString("yyyy-MM-dd HH:mm:ss")}','{zutritt.Text}','{einweis.Text}')");
+ overv = await SQL.ReadSQL("SELECT * FROM zutritte", overv);
+ dgOverview.DataContext = overv;
+ //overv.NewRow();
+ //Overviews = DataTableToOverview(overv);
+
+ dgOverview.CommitEdit(DataGridEditingUnit.Row, true);
+ dgOverview.IsHitTestVisible = false;
+ dgOverview.CanUserAddRows = false;
+ }
+ }
+ else
+ MessageBox.Show("Editieren ist nicht möglich", "Achtung");
+ }
+
+ private void BtnNew_Click(object sender, RoutedEventArgs e)
+ {
+ dgOverview.IsHitTestVisible = true;
+ dgOverview.CanUserAddRows = true;
+ }
+
+ }
+
+
+ public class Overview
+ {
+ public string Kategorie;
+ public string NameFirma;
+ public string NameBesucher;
+ public string Zutritt;
+ public string Pruefung_Zutritt;
+ public string Pruefung_Einweisung;
+ }
+}
diff --git a/ZKuP/MainWindow.xaml b/ZKuP/MainWindow.xaml
new file mode 100644
index 0000000..2660ded
--- /dev/null
+++ b/ZKuP/MainWindow.xaml
@@ -0,0 +1,385 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/MainWindow.xaml.cs b/ZKuP/MainWindow.xaml.cs
new file mode 100644
index 0000000..712c671
--- /dev/null
+++ b/ZKuP/MainWindow.xaml.cs
@@ -0,0 +1,944 @@
+using Renci.SshNet.Messages;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.DirectoryServices.AccountManagement;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Security.Permissions;
+using System.Security.Principal;
+using System.Text;
+using System.Threading;
+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.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+
+namespace ZKuP
+{
+ ///
+ /// Interaktionslogik für MainWindow.xaml
+ ///
+ public partial class MainWindow : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+
+ public static Roles LoggedInRole { get; private set; }
+ public string NoToolTip { get; } = "Doppelklick um Ankunft zu Bestätigen";
+
+ private List overview = new List();
+ public List Overviews
+ {
+ get { return overview; }
+ set { overview = value; OnPropertyChanged(); }
+ }
+
+ DataTable overv = new DataTable("Overview");
+ DataTable todayFirm = new DataTable("TodayFirm");
+ DataTable todayBesuch = new DataTable("TodayBesuch");
+
+
+ DispatcherTimer reloadTimer = new DispatcherTimer();
+
+
+
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
+
+ //this.WindowState = WindowState.Normal;
+
+ cbShowParkcardToAccept.IsChecked = Properties.Settings.Default.ShowParkcardAccept;
+
+ if ((Properties.Settings.Default.Width + Properties.Settings.Default.Left) >= System.Windows.SystemParameters.PrimaryScreenWidth) CenterWindowOnScreen(this);
+ if ((Properties.Settings.Default.Height + Properties.Settings.Default.Top) >= System.Windows.SystemParameters.PrimaryScreenHeight) CenterWindowOnScreen(this);
+
+ if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat") || File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat") != File.GetLastWriteTime(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\UpdateZKuP.bat"))
+ {
+ File.Copy(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\UpdateZKuP.bat", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat", true);
+ }
+
+ CheckVersion();
+
+ AuthenticateUser();
+ }
+
+ private async void AuthenticateUser()
+ {
+ if (!SQL.CheckDeviceConnection("10.20.98.34"))
+ {
+ Application.Current.Shutdown();
+ return;
+ }
+
+ if (AuthenticateDomain())
+ {
+ if (!Thread.CurrentPrincipal.Identity.IsAuthenticated)
+ {
+ MessageBox.Show($"Ihr User {Environment.UserName} ist nicht zum Zugriff berechtigt", "Zugriff verweigert");
+ Application.Current.Shutdown();
+ return;
+ }
+ else
+ {
+ string auth = "";
+ string role = "";
+
+ if (!SQL.TestConnection())
+ {
+ return;
+ }
+
+ auth = await SQL.ReadSingleValueAsync($"SELECT EXISTS(SELECT * FROM zkup.users WHERE `Username` = '{Environment.UserName}')");
+
+ if (auth == "1")
+ role = await SQL.ReadSingleValueAsync($"SELECT Role FROM zkup.users WHERE `Username` = '{Environment.UserName}'");
+ else
+ {
+ //CheckVersion();
+
+ var res = MessageBox.Show($"Ihr User {Environment.UserName} ist nicht zum Zugriff berechtigt\n\nMöchten Sie einen Besucher erstellen oder eine Parkkarte beantragen?", "Zugriff verweigert", MessageBoxButton.YesNo, MessageBoxImage.Warning);
+
+ if (res == MessageBoxResult.Yes)
+ {
+ BesucherCreateStart();
+ return;
+ }
+ else if (res == MessageBoxResult.No)
+ {
+ Application.Current.Shutdown();
+ return;
+ }
+
+ Application.Current.Shutdown();
+ return;
+ }
+
+ switch (role)
+ {
+ case "0":
+ PfoertnerStart();
+ break;
+ case "1":
+ EditorStart();
+ break;
+ case "2":
+ AdminStart();
+ break;
+ default:
+ PfoertnerStart();
+ break;
+ }
+
+
+ getToday();
+
+
+ await SQL.WriteSQL("DELETE FROM zkup.zutritte WHERE Zutritt < current_date() - INTERVAL 30 DAY");
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+ //Overviews = DataTableToOverview(overv);
+
+ dgOverview.DataContext = overv;
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+
+
+
+ reloadTimer.Interval = TimeSpan.FromMinutes(1);
+ reloadTimer.Tick += ReloadTimer_Tick;
+ reloadTimer.Start();
+ }
+ }
+ else
+ {
+ MessageBox.Show("User nicht in der Domäne aktiviert");
+ Application.Current.Shutdown();
+ return;
+ }
+ }
+
+ private bool AuthenticateDomain()
+ {
+ using (var domainContext = new PrincipalContext(ContextType.Domain, Environment.UserDomainName))
+ {
+ using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, Environment.UserName))
+ {
+ if (foundUser.Enabled.HasValue)
+ {
+ return (bool)foundUser.Enabled;
+ }
+ else
+ {
+ return false; //or false depending what result you want in the case of Enabled being NULL
+ }
+ }
+ }
+ }
+
+ private async void AdminStart()
+ {
+ LoggedInRole = Roles.Admin;
+
+ //CheckVersion();
+
+
+ Main.Visibility = Visibility.Visible;
+ gridToday.Visibility = Visibility.Visible;
+ gridArrived.Visibility = Visibility.Visible;
+
+ lblSearch.Visibility = Visibility.Visible;
+ tbSearch.Visibility = Visibility.Visible;
+
+ btnManageUsers.Visibility = Visibility.Visible;
+ btnCreateVisitor.Visibility = Visibility.Visible;
+ btnCreateFirma.Visibility = Visibility.Visible;
+ btnManageAsp.Visibility = Visibility.Visible;
+ btnKarten.Visibility = Visibility.Visible;
+ btnSignatures.Visibility = Visibility.Visible;
+ btnDelivery.Visibility = Visibility.Visible;
+ btnNew.Visibility = Visibility.Visible;
+ btnCreateDeliveries.Visibility = Visibility.Visible;
+
+ btnCheckParkausweis.Visibility = Visibility.Visible;
+ btnCreateParkausweis.Visibility = Visibility.Visible;
+ btnCreateSpecialParkausweis.Visibility = Visibility.Visible;
+ btnGrantParkausweis.Visibility = Visibility.Visible;
+ btnListParkausweis.Visibility = Visibility.Visible;
+ btnPrintParkausweis.Visibility = Visibility.Visible;
+
+ btnSettings.Visibility = Visibility.Visible;
+ btnArrivalsOverview.Visibility = Visibility.Visible;
+
+ gridSplitter.Visibility = Visibility.Visible;
+ gridSplitterArrows.Visibility = Visibility.Visible;
+ gridSplitterLine.Visibility = Visibility.Visible;
+ //MessageBox.Show("Sie sind Admin");
+ // something that only an admin user should be able to do
+ }
+
+ private void EditorStart()
+ {
+ LoggedInRole = Roles.Editor;
+
+ //CheckVersion();
+
+
+ Main.Visibility = Visibility.Visible;
+ gridToday.Visibility = Visibility.Visible;
+ gridArrived.Visibility = Visibility.Visible;
+
+ lblSearch.Visibility = Visibility.Visible;
+ tbSearch.Visibility = Visibility.Visible;
+
+ btnCreateVisitor.Visibility = Visibility.Visible;
+ btnCreateFirma.Visibility = Visibility.Visible;
+ btnManageAsp.Visibility = Visibility.Visible;
+ btnManageUsers.Visibility = Visibility.Collapsed;
+
+ btnCreateParkausweis.Visibility = Visibility.Visible;
+
+ btnSettings.Visibility = Visibility.Collapsed;
+ btnArrivalsOverview.Visibility = Visibility.Visible;
+
+ gridSplitter.Visibility = Visibility.Visible;
+ gridSplitterArrows.Visibility = Visibility.Visible;
+ gridSplitterLine.Visibility = Visibility.Visible;
+ //MessageBox.Show("Sie sind Editor");
+ // something that only an editor user should be able to do
+ }
+
+ private void PfoertnerStart()
+ {
+ LoggedInRole = Roles.Pförtner;
+
+ //CheckVersion();
+
+
+ Main.Visibility = Visibility.Visible;
+ gridToday.Visibility = Visibility.Visible;
+ gridArrived.Visibility = Visibility.Visible;
+
+ lblSearch.Visibility = Visibility.Visible;
+ tbSearch.Visibility = Visibility.Visible;
+
+ btnCreateVisitor.Visibility = Visibility.Visible;
+ btnManageUsers.Visibility = Visibility.Collapsed;
+ btnCreateFirma.Visibility = Visibility.Collapsed;
+ btnManageAsp.Visibility = Visibility.Collapsed;
+ btnKarten.Visibility = Visibility.Visible;
+ btnNew.Visibility = Visibility.Visible;
+ btnDelivery.Visibility = Visibility.Visible;
+ btnCreateDeliveries.Visibility = Visibility.Visible;
+
+ btnCheckParkausweis.Visibility = Visibility.Visible;
+ btnPrintParkausweis.Visibility = Visibility.Visible;
+
+ btnSettings.Visibility = Visibility.Collapsed;
+ btnArrivalsOverview.Visibility = Visibility.Visible;
+
+ gridSplitter.Visibility = Visibility.Visible;
+ gridSplitterArrows.Visibility = Visibility.Visible;
+ gridSplitterLine.Visibility = Visibility.Visible;
+ //MessageBox.Show("Sie sind Pförtner");
+ // something that only an pförtner user should be able to do
+ }
+
+ private void BesucherCreateStart()
+ {
+ LoggedInRole = Roles.None;
+
+ Main.Visibility = Visibility.Collapsed;
+
+ this.Width = 700;
+ this.Height = 700;
+ this.ResizeMode = ResizeMode.NoResize;
+
+ Main.Visibility = Visibility.Collapsed;
+ gridToday.Visibility = Visibility.Collapsed;
+ gridArrived.Visibility = Visibility.Collapsed;
+
+ UserCreate.Visibility = Visibility.Visible;
+ btnResetLists.Visibility = Visibility.Collapsed;
+ gridSplitter.Visibility = Visibility.Collapsed;
+ gridSplitterArrows.Visibility = Visibility.Collapsed;
+ gridSplitterLine.Visibility = Visibility.Collapsed;
+ lblResetLists.Visibility = Visibility.Collapsed;
+ btnResetLists.Visibility = Visibility.Collapsed;
+
+ btnSettings.Visibility = Visibility.Collapsed;
+ btnArrivalsOverview.Visibility = Visibility.Collapsed;
+
+ gridSplitter.Visibility = Visibility.Collapsed;
+ gridSplitterArrows.Visibility = Visibility.Collapsed;
+ gridSplitterLine.Visibility = Visibility.Collapsed;
+ //btnResetListsMain.Visibility = Visibility.Collapsed;
+ }
+
+
+
+
+
+ private async void ReloadTimer_Tick(object sender, EventArgs e)
+ {
+ getToday();
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+
+
+ private async void getToday()
+ {
+ if (LoggedInRole == Roles.Admin || LoggedInRole == Roles.Pförtner)
+ {
+ todayFirm = await SQL.ReadSQL("Select * FROM zkup.firmen where Arbeitsbeginn <= current_date() AND Arbeitsende >= current_date()", todayFirm);
+ todayBesuch = await SQL.ReadSQL("SELECT idbesucher, concat('Besucher: ', Name) AS Name, Verantwortlicher_MA AS Verantwortlicher_MA_Firma,Tel_Nr_Besucher AS Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Kleine_Unterweisung_bis,Oertlichkeit FROM zkup.besucher WHERE Besuchstag = current_date()", todayBesuch);
+ }
+ else
+ {
+ todayFirm = await SQL.ReadSQL($"Select * FROM zkup.firmen where (Arbeitsbeginn <= current_date() AND Arbeitsende >= current_date()) AND (Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}')", todayFirm);
+ todayBesuch = await SQL.ReadSQL($"SELECT idbesucher, concat('Besucher: ', Name) AS Name, Verantwortlicher_MA AS Verantwortlicher_MA_Firma,Tel_Nr_Besucher AS Tel_Nr_Verantwortlicher_Firma,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Kleine_Unterweisung_bis,Oertlichkeit FROM zkup.besucher WHERE Besuchstag = current_date() AND (Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}')", todayBesuch);
+ }
+
+ var firmview = todayFirm.DefaultView;
+ firmview.Sort = "Name";
+ todayFirm = firmview.ToTable();
+
+ var besuchview = todayBesuch.DefaultView;
+ besuchview.Sort = "Name";
+ todayBesuch = besuchview.ToTable();
+
+ todayFirm.Merge(todayBesuch);
+ dgToday.DataContext = todayFirm;
+ }
+
+
+ private void BtnManageUsers_Click(object sender, RoutedEventArgs e)
+ {
+ ManageUsers mU = new ManageUsers();
+ mU.Owner = this;
+ mU.ShowDialog();
+ }
+
+ private async void BtnCreateVisitor_Click(object sender, RoutedEventArgs e)
+ {
+ ManageVisitor mV = new ManageVisitor();
+ mV.Owner = this;
+ mV.ShowDialog();
+
+ getToday();
+ }
+
+ private async void BtnCreateFirma_Click(object sender, RoutedEventArgs e)
+ {
+ CreateFirma cF = new CreateFirma();
+ cF.Owner = this;
+ cF.ShowDialog();
+
+ getToday();
+ }
+
+ private void BtnManageAsp_Click(object sender, RoutedEventArgs e)
+ {
+ ManageAsp mA = new ManageAsp();
+ mA.Owner = this;
+ mA.ShowDialog();
+ }
+
+
+ private async void btnUserCreate_Click(object sender, RoutedEventArgs e)
+ {
+ CreateVisitor cV = new CreateVisitor();
+ cV.Owner = this;
+ cV.ShowDialog();
+
+ getToday();
+ }
+
+
+ private void btnKarten_Click(object sender, RoutedEventArgs e)
+ {
+ Cards cards = new Cards();
+ cards.Owner = this;
+ cards.ShowDialog();
+ }
+
+
+
+ private async void BtnNew_Click(object sender, RoutedEventArgs e)
+ {
+ if (LoggedInRole == Roles.Admin || LoggedInRole == Roles.Pförtner)
+ {
+ if (dgToday.SelectedValue == null)
+ {
+ if (MessageBox.Show(this, "Möchten Sie wirklich eine Ankunft ohne vorherige Auswahl bestätigen?\n\nWenn die Firma/der Besucher in der Liste 'Ankunft heute' steht, bitte per Doppelklick auf die Zeile bestätigen", "Sicher?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ Arrivals arrivals = new Arrivals(this);
+ arrivals.Owner = this;
+ arrivals.Show();
+ }
+ }
+ else
+ {
+ Arrivals arrivals = new Arrivals(this, (dgToday.SelectedValue as DataRowView).Row.ItemArray[1].ToString().Replace("Besucher: ", ""));
+ arrivals.Owner = this;
+ arrivals.Show();
+ }
+
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+ }
+
+ private async void btnDelivery_Click(object sender, RoutedEventArgs e)
+ {
+ Delivery delivery = new Delivery();
+ delivery.Owner = this;
+ delivery.ShowDialog();
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+
+
+
+
+
+
+
+ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (dgOverview != null) todayFirm.DefaultView.RowFilter = $"Name like '%{(sender as TextBox).Text}%' OR Ansprechpartner_Intern like '%{(sender as TextBox).Text}%' OR Verantwortlicher_MA_Firma like '%{(sender as TextBox).Text}%'";
+ }
+
+ private void TbSearch_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ lblSearch.Visibility = Visibility.Collapsed;
+ }
+
+
+
+ private async void CBKleine_Unterweis_Click(object sender, RoutedEventArgs e)
+ {
+ CheckBox box = (sender as CheckBox);
+ string id = ((box.DataContext) as DataRowView).Row.ItemArray[0].ToString();
+
+ if (box.IsChecked == true)
+ {
+ if (((box.DataContext) as DataRowView).Row.ItemArray[1].ToString() == "1")
+ {
+ await SQL.WriteSQL($"UPDATE zkup.firmen SET Kleine_Unterweisung_bis = '{(DateTime.Now.Date.AddYears(1)).ToString("yyyy-MM-dd")}' WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ await SQL.WriteSQL($"UPDATE zkup.zutritte SET Kl_Unterweisung = 1 WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ }
+ else if (((box.DataContext) as DataRowView).Row.ItemArray[1].ToString() == "2")
+ {
+ await SQL.WriteSQL($"UPDATE zkup.besucher SET Kleine_Unterweisung_bis = '{(DateTime.Now.Date.AddYears(1)).ToString("yyyy-MM-dd")}' WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ await SQL.WriteSQL($"UPDATE zkup.zutritte SET Kl_Unterweisung = 1 WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ }
+ }
+ else
+ {
+ if (((box.DataContext) as DataRowView).Row.ItemArray[1].ToString() == "1")
+ {
+ await SQL.WriteSQL($"UPDATE zkup.firmen SET Kleine_Unterweisung_bis = '1901-01-01' WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ await SQL.WriteSQL($"UPDATE zkup.zutritte SET Kl_Unterweisung = 0 WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ }
+ else if (((box.DataContext) as DataRowView).Row.ItemArray[1].ToString() == "2")
+ {
+ await SQL.WriteSQL($"UPDATE zkup.besucher SET Kleine_Unterweisung_bis = '{(DateTime.Now.Date.AddYears(1)).ToString("yyyy-MM-dd")}' WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ await SQL.WriteSQL($"UPDATE zkup.zutritte SET Kl_Unterweisung = 0 WHERE Name = '{((box.DataContext) as DataRowView).Row.ItemArray[2]}'");
+ }
+ }
+ }
+
+
+
+ private void TbSearch_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ lblSearch.Visibility = Visibility.Visible;
+ }
+
+ private async void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ if (LoggedInRole == Roles.Admin || LoggedInRole == Roles.Pförtner)
+ {
+ if (dgToday.SelectedValue == null)
+ {
+ Arrivals arrivals = new Arrivals(this);
+ arrivals.Owner = this;
+ arrivals.Show();
+ }
+ else
+ {
+ Arrivals arrivals = new Arrivals(this, (dgToday.SelectedValue as DataRowView).Row.ItemArray[1].ToString().Replace("Besucher: ", ""));
+ arrivals.Owner = this;
+ arrivals.Show();
+ }
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+ }
+
+ private void BtnInfo_Click(object sender, RoutedEventArgs e)
+ {
+ var dc = ((sender as Button).DataContext) as DataRowView;
+ string id = "";
+ string kat = "";
+
+ if ((dc).Row.ItemArray[7].ToString() != "")
+ {
+ id = (dc).Row.ItemArray[10].ToString();
+ kat = "1";
+ }
+ else
+ {
+ id = (dc).Row.ItemArray[1].ToString().Replace("Besucher: ", "");
+ kat = "2";
+ }
+
+ AspInfo aI = new AspInfo(id, kat, 1);
+ aI.Owner = this;
+ aI.ShowDialog();
+ }
+
+ private void btnCard_Click(object sender, RoutedEventArgs e)
+ {
+ var dc = ((sender as Button).DataContext) as DataRowView;
+
+ AddCardUser aI = new AddCardUser((dc).Row.ItemArray[2].ToString());
+ aI.Owner = this;
+ aI.ShowDialog();
+ }
+
+ private void btnArrivalsOverview_Click(object sender, RoutedEventArgs e)
+ {
+ ArrivalsOverview aOv = new ArrivalsOverview(LoggedInRole);
+ aOv.Owner = this;
+ aOv.ShowDialog();
+ }
+
+
+
+
+
+
+
+
+
+
+
+ private void BtnInfoArrived_Click(object sender, RoutedEventArgs e)
+ {
+ var dc = ((sender as Button).DataContext) as DataRowView;
+ string name = "";
+ string kat = "";
+
+ if ((dc).Row.ItemArray[1].ToString() == "1")
+ {
+ name = (dc).Row.ItemArray[8].ToString();
+ kat = "1";
+ }
+ else if ((dc).Row.ItemArray[1].ToString() == "2")
+ {
+ name = (dc).Row.ItemArray[2].ToString();
+ kat = "2";
+ }
+
+ AspInfo aI = new AspInfo(name, kat, 2, (dc).Row.ItemArray[0].ToString());
+ aI.Owner = this;
+ aI.ShowDialog();
+ }
+
+ private void Window_Closing(object sender, CancelEventArgs e)
+ {
+ if (Main.Visibility == Visibility.Visible)
+ {
+ Properties.Settings.Default.Save();
+ }
+ }
+
+ private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+#if DEBUG
+ if (e.Key == Key.LeftCtrl)
+ BesucherCreateStart();
+
+ if(e.Key == Key.RightCtrl)
+ Helper.SendMail("testTesttest");
+#endif
+ }
+
+ private void TextBlock_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ Helper.SendMail();
+ }
+
+
+ private void BtnHelp_Click(object sender, RoutedEventArgs e)
+ {
+ canvasHelp.Visibility = Visibility.Visible;
+ }
+
+ private void BtnCloseHelp_Click(object sender, RoutedEventArgs e)
+ {
+ canvasHelp.Visibility = Visibility.Collapsed;
+ }
+
+
+ private async void dgOverview_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+ var header = e.Column.Header;
+ var newValue = (e.EditingElement as TextBox).Text;
+ var id = (e.Row.Item as DataRowView).Row.ItemArray[0];
+
+
+ switch (header)
+ {
+ case "Kennzeichen":
+ await SQL.WriteSQL($"UPDATE zutritte SET Kennzeichen = '{newValue}' WHERE idzutritte = '{id}'");
+ break;
+ }
+
+ dgOverview.RowValidationErrorTemplate = new ControlTemplate();
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+
+
+
+ private async void CheckVersion()
+ {
+ try
+ {
+ if (Convert.ToDouble(File.ReadAllText(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\Version.txt")) > Convert.ToDouble(lblVersion.Text.Split(' ')[1]))
+ {
+ if (MessageBox.Show(this, "Neue Version verfügbar!\n\n\n" +
+ "Die Anwendung kann nur mit der neuen Version wieder gestartet werden\n" +
+ "Die Anwendung wird auf dem Desktop abgelegt, bitte nur diese Datei starten\n" +
+ "ZKuP wird nach dem Update automatisch neu gestartet\n\n" +
+ "Neue Version herunterladen?", "Neue Version verfügbar!", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
+ {
+ if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat") || File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat") != File.GetLastWriteTime(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\UpdateZKuP.bat"))
+ {
+ File.Copy(@"\\muenas001.wb4fv.db.de\GLW99\ZKuP\UpdateZKuP.bat", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat", true);
+
+ System.Diagnostics.Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat");
+ Application.Current.Shutdown();
+ return;
+ }
+ else
+ {
+ System.Diagnostics.Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdateZKuP.bat");
+ Application.Current.Shutdown();
+ return;
+ }
+ }
+ else { Application.Current.Shutdown(); return; }
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+
+ if (MessageBox.Show(this, "Fehler beim Abfragen der Version\n\nDie Anwendung kann genutzt werden\nBitte in einigen Minuten die Anwendung beenden und erneut starten\n\nMöchten Sie sich die detaillierte Fehlermeldung anzeigen lassen?", "Fehler!", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
+ MessageBox.Show(this, "Fehlermeldung:\n\n" + ex.Message, "Fehlermeldung", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ private void btnDebug_Click(object sender, RoutedEventArgs e)
+ {
+ CheckVersion();
+ }
+
+ private void btnSignatures_Click(object sender, RoutedEventArgs e)
+ {
+ var iv = new ImageView(null, true);
+ iv.Owner = this;
+ iv.ShowDialog();
+ }
+
+ private async void btnCreateDeliveries_Click(object sender, RoutedEventArgs e)
+ {
+ var deliver = new ManageDeliveries();
+ deliver.Owner = this;
+ deliver.ShowDialog();
+
+ overv = await SQL.ReadSQL("SELECT * FROM zkup.zutritte where Zutritt >= now() + INTERVAL -10 DAY", overv);
+
+ dgOverview.Items.SortDescriptions.Clear();
+ dgOverview.Items.SortDescriptions.Add(new SortDescription("Zutritt", ListSortDirection.Descending));
+ dgOverview.Items.Refresh();
+ }
+
+
+ private void btnResetLists_Click(object sender, RoutedEventArgs e)
+ {
+ gridBackground.RowDefinitions[1].Height = new GridLength(this.Height / 2);
+ gridBackground.RowDefinitions[3].Height = new GridLength(1, GridUnitType.Star);
+ }
+
+
+
+
+ private void btnCreateParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ ParkausweisDisclaimer Pd = new ParkausweisDisclaimer();
+ Pd.Owner = this;
+ Pd.ShowDialog();
+ }
+
+ private void btnCreateSpecialParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ CreateParkausweis cPa = new CreateParkausweis(true);
+ cPa.Owner = this;
+ cPa.ShowDialog();
+ }
+
+ private void btnGrantParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ GrantParkausweis gPa = new GrantParkausweis();
+ gPa.Owner = this;
+ gPa.ShowDialog();
+ }
+
+ private void btnListParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ ManageParkausweis mPa = new ManageParkausweis();
+ mPa.Owner = this;
+ mPa.ShowDialog();
+ }
+
+ private void btnCheckParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ CheckParkausweis checkPa = new CheckParkausweis();
+ checkPa.Owner = this;
+ checkPa.ShowDialog();
+ }
+
+ private void btnPrintParkausweis_Click(object sender, RoutedEventArgs e)
+ {
+ PrintParkausweis pPa = new PrintParkausweis();
+ pPa.Owner = this;
+ pPa.Show();
+ }
+
+
+ private async void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ double maxheight = this.ActualHeight - 120 - 191;
+ double actualheight = this.ActualHeight - 120 - gridBackground.RowDefinitions[1].Height.Value;
+ if (actualheight <= 191) gridBackground.RowDefinitions[1].Height = new GridLength(maxheight);
+ }
+
+ public void CenterWindowOnScreen(Window window)
+ {
+ double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
+ double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
+ double windowWidth = window.Width;
+ double windowHeight = window.Height;
+ window.Left = (screenWidth / 2) - (windowWidth / 2);
+ window.Top = (screenHeight / 2) - (windowHeight / 2);
+ }
+
+ private async void Window_ContentRendered(object sender, EventArgs e)
+ {
+ if (LoggedInRole == Roles.Admin && Properties.Settings.Default.ShowParkcardAccept)
+ {
+ if (await SQL.RowExists("parkausweise", "Genehmigt", "0") == true)
+ {
+ if (MessageBox.Show(this, "Es liegen zu genehmigende Parkkartenanträge vor!\n\nMöchten Sie diese jetzt überprüfen?", "Neue Anträge", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ GrantParkausweis gPa = new GrantParkausweis();
+ gPa.Owner = this;
+ gPa.Show();
+ }
+ }
+ }
+ else if (LoggedInRole == Roles.Pförtner)
+ {
+ if (await SQL.RowExists("parkausweise", "Genehmigt = '1' AND Gedruckt", "0") == true)
+ {
+ if (MessageBox.Show(this, "Es liegen zu druckende Parkkarten vor!\n\nMöchten Sie diese jetzt überprüfen?", "Neue Parkkarten", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ PrintParkausweis pPa = new PrintParkausweis();
+ pPa.Owner = this;
+ pPa.Show();
+ }
+ }
+ }
+ }
+
+ private void btnSettings_Click(object sender, RoutedEventArgs e)
+ {
+ canvasSettings.Visibility = Visibility.Visible;
+ }
+
+ private void cbShowParkcardToAccept_Checked(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.ShowParkcardAccept = true;
+ }
+
+ private void cbShowParkcardToAccept_Unchecked(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.ShowParkcardAccept = false;
+ }
+
+ private void btnCloseSettings_Click(object sender, RoutedEventArgs e)
+ {
+ canvasSettings.Visibility = Visibility.Collapsed;
+ }
+
+ private void gridSplitter_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
+ {
+ double maxheight = this.ActualHeight - 120 - 191;
+ double actualheight = this.ActualHeight - 120 - gridBackground.RowDefinitions[1].Height.Value;
+ if (actualheight <= 191) gridBackground.RowDefinitions[1].Height = new GridLength(maxheight);
+ }
+
+ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ double maxheight = this.ActualHeight - 120 - 195;
+ double actualheight = this.ActualHeight - 120 - gridBackground.RowDefinitions[1].Height.Value;
+ if (actualheight <= 195)
+ {
+ gridBackground.RowDefinitions[1].Height = new GridLength(maxheight);
+ return;
+ }
+
+ //if(e.NewSize.Height > e.PreviousSize.Height)
+ gridBackground.RowDefinitions[1].Height = new GridLength(gridBackground.RowDefinitions[1].Height.Value + (e.NewSize.Height - e.PreviousSize.Height));
+ //else
+ // gridBackground.RowDefinitions[1].Height = new GridLength(gridBackground.RowDefinitions[1].Height.Value + (e.PreviousSize.Height - e.NewSize.Height));
+
+ System.Diagnostics.Debug.WriteLine("WindowSize: " + this.Width );
+ }
+
+ }
+
+
+ public class ReturnToolTip : System.Windows.Data.IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if(MainWindow.LoggedInRole == Roles.Admin || MainWindow.LoggedInRole == Roles.Pförtner)
+ {
+ return "Doppelklick um Ankunft zu Bestätigen";
+ }
+ else
+ {
+ return "Von Ihnen eingegebene Firmen/Besucher, die für heute angemeldet sind";
+ }
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+
+ public class Overview
+ {
+ public string Kategorie;
+ public string Name;
+ public string Zutritt;
+ public string Pruefung_Zutritt;
+ public string Pruefung_Einweisung;
+ public int Kl_Unterweisung;
+ public string Kennzeichen;
+ public string Bemerkung;
+ }
+
+ public enum Roles
+ {
+ Pförtner,
+ Editor,
+ Admin,
+ None
+ }
+}
diff --git a/ZKuP/ManageAsp.xaml b/ZKuP/ManageAsp.xaml
new file mode 100644
index 0000000..32733ed
--- /dev/null
+++ b/ZKuP/ManageAsp.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ManageAsp.xaml.cs b/ZKuP/ManageAsp.xaml.cs
new file mode 100644
index 0000000..dff754c
--- /dev/null
+++ b/ZKuP/ManageAsp.xaml.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ManageAsp.xaml
+ ///
+ public partial class ManageAsp : Window
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private List myVar;
+ public List aspView
+ {
+ get { return myVar; }
+ set { myVar = value; }
+ }
+
+ DataTable asp = new DataTable("Asp");
+
+ public ManageAsp()
+ {
+ this.DataContext = this;
+
+ InitializeComponent();
+
+
+ asp = SQL.ReadSQL("SELECT * FROM zkup.ansprechpartner", asp).Result;
+ aspView = Asp.DataTableToAsp(asp);
+ dgAsp.DataContext = asp;
+ }
+
+ private async void BtnCreateAsp_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(tbAsp.Text))
+ MessageBox.Show(this, "Ansprechpartner muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (string.IsNullOrWhiteSpace(tbAspVertreter.Text))
+ MessageBox.Show(this, "Vertreter muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (string.IsNullOrWhiteSpace(tbAspVorgesetzter.Text))
+ MessageBox.Show(this, "Vorgesetzter muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (string.IsNullOrWhiteSpace(tbAspTel.Text))
+ MessageBox.Show(this, "Ansprechpartner-Telefonnummer muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (string.IsNullOrWhiteSpace(tbVertreterTel.Text))
+ MessageBox.Show(this, "Vertreter-Telefonnummer muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else if (string.IsNullOrWhiteSpace(tbVorgesetzterTel.Text))
+ MessageBox.Show(this, "Vorgesetzter-Telefonnummer muss ausgefüllt sein!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ {
+ await SQL.WriteSQL("INSERT INTO ansprechpartner (Name,Vertreter,Tel_Nr,Vorgesetzter,Tel_Vertreter,Tel_Vorgesetzter) VALUES " +
+ $"('{tbAsp.Text}','{tbAspVertreter.Text}','{tbAspTel.Text}','{tbAspVorgesetzter.Text}','{tbVertreterTel.Text}','{tbVorgesetzterTel.Text}')");
+
+ tbAsp.Text = "";
+ tbAspTel.Text = "";
+ tbAspVertreter.Text = "";
+ tbAspVorgesetzter.Text = "";
+ tbVertreterTel.Text = "";
+ tbVorgesetzterTel.Text = "";
+
+ asp = SQL.ReadSQL("SELECT * FROM zkup.ansprechpartner", asp).Result;
+ aspView = Asp.DataTableToAsp(asp);
+ }
+ }
+ private async void DgAsp_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.ansprechpartner WHERE `Name` = '{arr[0]}'");
+
+ asp = SQL.ReadSQL("Select * from zkup.ansprechpartner", asp).Result;
+ aspView = Asp.DataTableToAsp(asp);
+ }
+ }
+
+
+ private void DgAsp_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ dgAsp.PreviewKeyDown -= DgAsp_PreviewKeyDown;
+ }
+ private async void DgAsp_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+ var header = e.Column.Header;
+ var newValue = (e.EditingElement as TextBox).Text;
+ var name = (e.Row.Item as DataRowView).Row.ItemArray[0];
+
+
+ switch (header)
+ {
+ case "Ansprechpartner":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Name = '{newValue}' WHERE Name = '{name}'");
+ break;
+ case "Asp-Vertreter":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Vertreter = '{newValue}' WHERE Name = '{name}'");
+ break;
+ case "Asp-Tel":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Tel_Nr = '{newValue}' WHERE Name = '{name}'");
+ break;
+ case "Asp-Vorgesetzter":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Vorgesetzter = '{newValue}' WHERE Name = '{name}'");
+ break;
+ case "Vertreter-Tel":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Tel_Vertreter = '{newValue}' WHERE Name = '{name}'");
+ break;
+ case "Vorgesetzter-Tel":
+ await SQL.WriteSQL($"UPDATE ansprechpartner SET Tel_Vorgesetzter = '{newValue}' WHERE Name = '{name}'");
+ break;
+
+ }
+
+ dgAsp.RowValidationErrorTemplate = new ControlTemplate();
+ dgAsp.PreviewKeyDown += DgAsp_PreviewKeyDown;
+
+ asp = SQL.ReadSQL("Select * from zkup.ansprechpartner", asp).Result;
+ aspView = Asp.DataTableToAsp(asp);
+ }
+
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+
+ public class Asp
+ {
+ string Name;
+ string Vertreter;
+ string Tel_Nr;
+ string Vorgesetzter;
+ string Tel_Vertreter;
+ string Tel_Vorgesetzter;
+
+
+ public static List DataTableToAsp(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Asp()
+ {
+ Name = dr[0].ToString(),
+ Vertreter = dr[1].ToString(),
+ Tel_Nr = dr[2].ToString(),
+ Vorgesetzter = dr[3].ToString(),
+ Tel_Vertreter = dr[4].ToString(),
+ Tel_Vorgesetzter = dr[5].ToString()
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/ManageDeliveries.xaml b/ZKuP/ManageDeliveries.xaml
new file mode 100644
index 0000000..c30f3bc
--- /dev/null
+++ b/ZKuP/ManageDeliveries.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ManageDeliveries.xaml.cs b/ZKuP/ManageDeliveries.xaml.cs
new file mode 100644
index 0000000..1c9b8d5
--- /dev/null
+++ b/ZKuP/ManageDeliveries.xaml.cs
@@ -0,0 +1,211 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ManageDeliveries.xaml
+ ///
+ public partial class ManageDeliveries : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private List myVar;
+ public List DeliveriesView
+ {
+ get { return myVar; }
+ set { myVar = value; OnPropertyChanged(); }
+ }
+ System.Data.DataTable lieferanten = new System.Data.DataTable("lieferanten");
+
+ public ManageDeliveries()
+ {
+ InitializeComponent();
+
+ lieferanten = SQL.ReadSQL("Select * from zkup.lieferanten", lieferanten).Result;
+ DeliveriesView = Deliver.DataTableToDeliver(lieferanten);
+ dgLieferanten.DataContext = lieferanten;
+
+ dgLieferanten.Items.SortDescriptions.Clear();
+ dgLieferanten.Items.SortDescriptions.Add(new SortDescription("Firma", ListSortDirection.Ascending));
+ dgLieferanten.Items.Refresh();
+ }
+
+ private async void btnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ if (tbFirma.Text == "")
+ {
+ MessageBox.Show(this, "Lieferfirma muss eingetragen werden!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ else
+ {
+ await SQL.WriteSQL($"INSERT INTO lieferanten (Firma, Fahrer, Handynr, Kennzeichen) VALUES ('{tbFirma.Text}','{tbFahrer.Text}','{tbHandynr.Text}','{tbKennzeichen.Text}')");
+
+ lieferanten = SQL.ReadSQL("Select * from zkup.lieferanten", lieferanten).Result;
+ DeliveriesView = Deliver.DataTableToDeliver(lieferanten);
+ dgLieferanten.ScrollIntoView(dgLieferanten.Items[dgLieferanten.Items.Count - 1]); //scroll to last
+ dgLieferanten.UpdateLayout();
+ ResetInput();
+ }
+ }
+
+
+ private void ResetInput()
+ {
+ tbFirma.Text = "";
+ tbFahrer.Text = "";
+ tbHandynr.Text = "";
+ tbKennzeichen.Text = "";
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+
+ private async void dgLieferanten_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+ var header = e.Column.Header;
+ var newValue = (e.EditingElement as TextBox).Text;
+ var id = (e.Row.Item as System.Data.DataRowView).Row.ItemArray[0];
+
+ string searchFahrer = "";
+
+ if ((e.Row.Item as System.Data.DataRowView).Row.ItemArray[1].ToString() != "")
+ searchFahrer = $" AND Fahrer = '{(e.Row.Item as System.Data.DataRowView).Row.ItemArray[1].ToString()}'";
+
+ switch (header)
+ {
+ case "Firma":
+ await SQL.WriteSQL($"UPDATE lieferanten SET Firma = '{newValue}' WHERE Fahrer = '{id}'" + searchFahrer);
+ break;
+ case "Fahrer":
+ await SQL.WriteSQL($"UPDATE lieferanten SET Fahrer = '{newValue}' WHERE Firma = '{id}'" + searchFahrer);
+ break;
+ case "Handynr":
+ await SQL.WriteSQL($"UPDATE lieferanten SET Handynr = '{newValue}' WHERE Firma = '{id}'" + searchFahrer);
+ break;
+ case "Kennzeichen":
+ await SQL.WriteSQL($"UPDATE lieferanten SET Kennzeichen = '{newValue}' WHERE Firma = '{id}'" + searchFahrer);
+ break;
+ }
+
+ dgLieferanten.PreviewKeyDown += DgLieferanten_PreviewKeyDown;
+
+ lieferanten = await SQL.ReadSQL("Select * from zkup.lieferanten", lieferanten);
+ DeliveriesView = Deliver.DataTableToDeliver(lieferanten);
+ }
+
+
+ private async void DgLieferanten_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as System.Data.DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.lieferanten WHERE `Firma` = '{arr[0]}' AND `Fahrer` = '{arr[1]}'");
+
+ lieferanten = SQL.ReadSQL("Select * from zkup.lieferanten", lieferanten).Result;
+ DeliveriesView = Deliver.DataTableToDeliver(lieferanten);
+ }
+ }
+
+ private void dgLieferanten_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ dgLieferanten.PreviewKeyDown -= DgLieferanten_PreviewKeyDown;
+ }
+
+
+ private async void btnDeleteDeliver_Click(object sender, RoutedEventArgs e)
+ {
+ var dg = dgLieferanten;
+ var row = dg.SelectedItem as System.Data.DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Markierten Lieferanten wirklich entfernen?", "Lieferanten entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.lieferanten WHERE `Firma` = '{arr[0]}' AND `Fahrer` = '{arr[1]}'");
+
+ lieferanten = SQL.ReadSQL("Select * from zkup.lieferanten", lieferanten).Result;
+ DeliveriesView = Deliver.DataTableToDeliver(lieferanten);
+ }
+ }
+
+ private void dgLieferanten_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dgLieferanten.SelectedIndex != -1) btnDeleteDeliver.IsEnabled = true;
+ else btnDeleteDeliver.IsEnabled = false;
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+
+
+
+ public class Deliver
+ {
+ public string Firma;
+ string Fahrer;
+ string Handynr;
+ string Kennzeichen;
+
+
+
+
+ public static List DataTableToDeliver(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (System.Data.DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Deliver()
+ {
+ Firma = dr[0].ToString(),
+ Fahrer = dr[1].ToString(),
+ Handynr = dr[2].ToString(),
+ Kennzeichen = dr[3].ToString()
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/ManageParkausweis.xaml b/ZKuP/ManageParkausweis.xaml
new file mode 100644
index 0000000..7dab894
--- /dev/null
+++ b/ZKuP/ManageParkausweis.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ManageParkausweis.xaml.cs b/ZKuP/ManageParkausweis.xaml.cs
new file mode 100644
index 0000000..7c36ed0
--- /dev/null
+++ b/ZKuP/ManageParkausweis.xaml.cs
@@ -0,0 +1,46 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ManageParkausweis.xaml
+ ///
+ public partial class ManageParkausweis : Window
+ {
+ public ManageParkausweis()
+ {
+ InitializeComponent();
+
+ var list = SQL.ReadSQL($"SELECT * FROM zkup.parkausweise").Result;
+ dgManage.DataContext = list;
+ }
+
+
+ private async void DgManage_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as System.Data.DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.parkausweise WHERE `idparkausweise` = '{arr[0]}'");
+
+ var list = SQL.ReadSQL($"SELECT * FROM zkup.parkausweise").Result;
+ dgManage.DataContext = list;
+ }
+ }
+ }
+}
diff --git a/ZKuP/ManageUsers.xaml b/ZKuP/ManageUsers.xaml
new file mode 100644
index 0000000..6e899c7
--- /dev/null
+++ b/ZKuP/ManageUsers.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ManageUsers.xaml.cs b/ZKuP/ManageUsers.xaml.cs
new file mode 100644
index 0000000..49cc774
--- /dev/null
+++ b/ZKuP/ManageUsers.xaml.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ManageUsers.xaml
+ ///
+ public partial class ManageUsers : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+
+ private List myVar;
+ public List UserView
+ {
+ get { return myVar; }
+ set { myVar = value; OnPropertyChanged(); }
+ }
+
+ DataTable userList = new DataTable("userList");
+
+ public ManageUsers()
+ {
+ InitializeComponent();
+
+ userList = SQL.ReadSQL("Select * from zkup.users", userList).Result;
+ userList.DefaultView.Sort = "Username";
+ userList = userList.DefaultView.ToTable();
+ UserView = Users.DataTableToUserList(userList);
+ dgUsers.DataContext = userList;
+ }
+
+ private void BtnAddUser_Click(object sender, RoutedEventArgs e)
+ {
+ if(tbUsername.Text == "")
+ {
+ MessageBox.Show("Username eintragen!", "Fehler");
+ return;
+ }
+
+ if(cbRole.SelectedIndex == -1)
+ {
+ MessageBox.Show("Role auswählen!", "Fehler");
+ return;
+ }
+
+
+ SQL.WriteSQL($"Insert into zkup.users (Username,Role) VALUES ('{tbUsername.Text}','{cbRole.SelectedIndex}')");
+
+ userList = SQL.ReadSQL("Select * from zkup.users", userList).Result;
+ userList.DefaultView.Sort = "Username";
+ userList = userList.DefaultView.ToTable();
+ UserView = Users.DataTableToUserList(userList);
+ dgUsers.DataContext = userList;
+
+ dgUsers.ScrollIntoView(UserView.Last());
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+
+
+ private async void DgUsers_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ await SQL.WriteSQL($"DELETE FROM zkup.users WHERE `Username` = '{arr[1]}'");
+
+ userList = SQL.ReadSQL("Select * from zkup.users", userList).Result;
+ userList.DefaultView.Sort = "Username asc";
+ userList = userList.DefaultView.ToTable();
+ UserView = Users.DataTableToUserList(userList);
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+
+ public class Users
+ {
+ string Username;
+ string Role;
+
+
+ public static List DataTableToUserList(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Users()
+ {
+ Username = dr[1].ToString(),
+ Role = dr[2].ToString()
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/ManageVisitor.xaml b/ZKuP/ManageVisitor.xaml
new file mode 100644
index 0000000..7d53965
--- /dev/null
+++ b/ZKuP/ManageVisitor.xaml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ManageVisitor.xaml.cs b/ZKuP/ManageVisitor.xaml.cs
new file mode 100644
index 0000000..fb9107d
--- /dev/null
+++ b/ZKuP/ManageVisitor.xaml.cs
@@ -0,0 +1,436 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für CreateVisitor.xaml
+ ///
+ public partial class ManageVisitor : Window, INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private List myVar;
+ public List VisitorView
+ {
+ get { return myVar; }
+ set { myVar = value; OnPropertyChanged(); }
+ }
+
+ DataTable visitors = new DataTable("Visitors");
+
+ private List aspVar;
+ public List asp
+ {
+ get { return aspVar; }
+ set { aspVar = value; OnPropertyChanged(); }
+ }
+
+
+ int index = 0;
+
+
+ public ManageVisitor()
+ {
+ this.DataContext = this;
+
+ InitializeComponent();
+
+
+ asp = SQL.ReadListString("SELECT Name FROM zkup.ansprechpartner").Result;
+ asp = asp.OrderBy(p => p).ToList();
+ asp.Insert(0, "");
+ cBAsp.ItemsSource = asp;
+ //dg_cbASP.ItemsSource = asp;
+
+ updateList();
+
+
+ dgVisitors.Items.SortDescriptions.Clear();
+ dgVisitors.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
+ dgVisitors.UpdateLayout();
+ }
+
+ private void updateList()
+ {
+ if (MainWindow.LoggedInRole == Roles.Admin || MainWindow.LoggedInRole == Roles.Pförtner)
+ {
+ requestListAdmin();
+ }
+ else
+ {
+ requestList();
+ }
+ }
+
+ private void requestList()
+ {
+ visitors = SQL.ReadSQL($"SELECT * FROM zkup.besucher WHERE Ersteller = '{Environment.UserName}' " +
+ $"OR Ersteller = '{Environment.UserDomainName}{Environment.UserName}' " +
+ $"OR Ersteller = '{SQL.ReadSingleValue($"SELECT Vertreter FROM zkup.ansprechpartner WHERE Name = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'")}' " +
+ $"OR Ansprechpartner_Intern = '{Helper.InsertSpaceBeforeUpperCase(Environment.UserName)}'"
+ , visitors).Result;
+
+ VisitorView = Visitor.DataTableToVisitor(visitors);
+ dgVisitors.DataContext = visitors;
+ }
+
+ private void requestListAdmin()
+ {
+ visitors = SQL.ReadSQL("SELECT * FROM zkup.besucher", visitors).Result;
+ VisitorView = Visitor.DataTableToVisitor(visitors);
+ dgVisitors.DataContext = visitors;
+ }
+
+ private void BtnClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private async void BtnAdd_Click(object sender, RoutedEventArgs e)
+ {
+ if (tbAnzahl_Begleiter.Text == "") tbAnzahl_Begleiter.Text = "0";
+
+ if (string.IsNullOrWhiteSpace(tbName.Text))
+ MessageBox.Show("Name eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbVerantwortlicher_MA.Text))
+ MessageBox.Show("Verantwortlichen MA eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbTel_Besucher.Text))
+ MessageBox.Show("Telefonnummer Besucher eintragen!", "Fehler");
+ else if (!dpBesuchstag.SelectedDate.HasValue)
+ MessageBox.Show("Besuchstag eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbGrundDesBesuchs.Text))
+ MessageBox.Show("'Grund des Besuchs' eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbOertlichkeit.Text))
+ MessageBox.Show("'Örtlichkeit' eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbAnsprechp_Intern.Text))
+ MessageBox.Show("'Ansprechpartner intern' auswählen oder eintragen!", "Fehler");
+ else if (string.IsNullOrWhiteSpace(tbTel_Ansprechp.Text))
+ MessageBox.Show("'Telefonnr. Ansprechpartner intern' eintragen!", "Fehler");
+ else
+ {
+ if (VisitorView.Exists(p => p.Name.Contains(tbName.Text)))
+ {
+ MessageBox.Show("Besucher existiert bereits", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ return;
+ }
+ else
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(tbAnzahl_Begleiter.Text, "^[0-9]*$"))
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ await SQL.WriteSQL("INSERT INTO besucher (Name,Verantwortlicher_MA,Tel_Nr_Besucher,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Oertlichkeit,Ersteller) VALUES " +
+ $"('{tbName.Text}','{tbVerantwortlicher_MA.Text}','{tbTel_Besucher.Text}','{tbAnzahl_Begleiter.Text}','{dpBesuchstag.SelectedDate.Value.ToString("yyyy-MM-dd")}','{tbGrundDesBesuchs.Text}','{tbAnsprechp_Intern.Text}','{tbTel_Ansprechp.Text}','{tbOertlichkeit.Text}','{Environment.UserName}')");
+
+
+ updateList();
+
+ dgVisitors.ScrollIntoView(dgVisitors.Items[dgVisitors.Items.Count - 1]); //scroll to last
+ dgVisitors.UpdateLayout();
+ ResetInput();
+ }
+ }
+ }
+
+ private void ResetInput()
+ {
+ tbName.Text = "";
+ tbVerantwortlicher_MA.Text = "";
+ tbTel_Besucher.Text = "";
+ tbAnzahl_Begleiter.Text = "";
+ dpBesuchstag.Text = "";
+ tbGrundDesBesuchs.Text = "";
+ tbOertlichkeit.Text = "";
+ cBAsp.SelectedIndex = -1;
+ tbAnsprechp_Intern.Text = "";
+ tbTel_Ansprechp.Text = "";
+ }
+
+ private async void DgVisitors_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ var dg = sender as DataGrid;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (e.Key == Key.Delete)
+ {
+ deleteRow(arr);
+ }
+ }
+
+
+
+ private void DgVisitors_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
+ {
+ dgVisitors.PreviewKeyDown -= DgVisitors_PreviewKeyDown;
+ }
+
+
+ private async void DgVisitors_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
+ {
+ var newValue = "";
+ var header = e.Column.Header;
+ if (header.ToString() == "Anspr. intern")
+ newValue = (e.EditingElement as ComboBox).Text;
+ else
+ newValue = (e.EditingElement as TextBox).Text;
+
+ var id = (e.Row.Item as DataRowView).Row.ItemArray[0];
+ DateTime date = DateTime.Now;
+
+ if (DateTime.TryParseExact(newValue, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out date))
+ newValue = date.ToString("yyyy-MM-dd");
+
+ var MessageValue = newValue;
+ var MessageDate = DateTime.Now;
+ if (DateTime.TryParse(newValue, out MessageDate))
+ MessageValue = MessageDate.ToString("dd.MM.yyyy");
+
+ if (oldValue != MessageValue)
+ {
+ if (MessageBox.Show(this, $"Möchten Sie den Eintrag '{oldValue}' in der Spalte '{header}' sicher zu '{MessageValue}' ändern?", "Sicher ändern?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ switch (header)
+ {
+ case "Name":
+ await SQL.WriteSQL($"UPDATE besucher SET Name = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Verantw. MA":
+ await SQL.WriteSQL($"UPDATE besucher SET Verantwortlicher_MA = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Tel. Besucher":
+ await SQL.WriteSQL($"UPDATE besucher SET Tel_Nr_Besucher = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Anz. Begleitp.":
+ if (!System.Text.RegularExpressions.Regex.IsMatch(newValue, "^[0-9]*$"))
+ MessageBox.Show(this, "Anzahl Begleiter darf nur Zahlen enthalten", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
+ else
+ await SQL.WriteSQL($"UPDATE besucher SET Anzahl_Begleitpersonen = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Besuchstag":
+ await SQL.WriteSQL($"UPDATE besucher SET Besuchstag = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Grund des Besuchs":
+ await SQL.WriteSQL($"UPDATE besucher SET Grund_des_Besuchs = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Örtlichkeit":
+ await SQL.WriteSQL($"UPDATE besucher SET Oertlichkeit = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Anspr. intern":
+ await SQL.WriteSQL($"UPDATE besucher SET Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ case "Tel. Ansprechp.":
+ await SQL.WriteSQL($"UPDATE besucher SET Tel_Nr_Ansprechpartner_Intern = '{newValue}', Bearbeiter = '{Environment.UserName}' WHERE idBesucher = '{id}'");
+ break;
+ }
+ }
+ }
+
+ index = e.Row.GetIndex();
+ dgVisitors.PreviewKeyDown += DgVisitors_PreviewKeyDown;
+
+ updateList();
+
+ dgVisitors.RowValidationErrorTemplate = new ControlTemplate();
+
+ dgVisitors.SelectedIndex = (index);
+ dgVisitors.ScrollIntoView(dgVisitors.Items[index]);
+
+ //ScrollTo();
+ }
+
+ private async Task ScrollTo()
+ {
+ if (index != 0 && index != -1)
+ {
+ dgVisitors.SelectedIndex = index;
+ dgVisitors.ScrollIntoView(dgVisitors.Items[index]);
+
+ DataGridRow row = (DataGridRow)dgVisitors.ItemContainerGenerator.ContainerFromIndex(index - 1);
+
+ if (row != null)
+ {
+ row.Focusable = true;
+ row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Right));
+ }
+ }
+ }
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ System.Diagnostics.Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ private void TbAnzahl_Begleiter_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpBesuchstag.Focus();
+ dpBesuchstag.IsDropDownOpen = true;
+ }
+
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ else
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+ private void DpBesuchstag_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Tab)
+ {
+ dpBesuchstag.IsDropDownOpen = false;
+ dpBesuchstag.Focus();
+ }
+ }
+
+
+
+ private void dgVisitors_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (dgVisitors.SelectedIndex != -1) btnDelete.IsEnabled = true;
+ else btnDelete.IsEnabled = false;
+
+ ScrollTo();
+ }
+ private async void btnDelete_Click(object sender, RoutedEventArgs e)
+ {
+ var dg = dgVisitors;
+ var row = dg.SelectedItem as DataRowView;
+ var arr = row.Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Markierten Besucher wirklich entfernen?", "Besucher entfernen?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ deleteRow(arr);
+ }
+ }
+
+ private async void deleteRow(object[] arr)
+ {
+ await SQL.WriteSQL("INSERT INTO besucherLog (idbesucher, Name,Verantwortlicher_MA,Tel_Nr_Besucher,Anzahl_Begleitpersonen,Besuchstag,Grund_des_Besuchs,Ansprechpartner_Intern,Tel_Nr_Ansprechpartner_Intern,Oertlichkeit,Geloescht_Von) VALUES " +
+ $"('{arr[0]}','{arr[1].ToString()}','{arr[2].ToString()}','{arr[3].ToString()}','{arr[4].ToString()}','{Convert.ToDateTime(arr[5].ToString()).ToString("yyyy-MM-dd")}','{arr[6].ToString()}','{arr[7].ToString()}','{arr[8].ToString()}','{arr[10].ToString()}','{Environment.UserName}')");
+
+
+ await SQL.WriteSQL($"DELETE FROM zkup.besucher WHERE `idBesucher` = '{arr[0]}'");
+
+ updateList();
+ }
+
+ private async void cBAsp_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (cBAsp.SelectedIndex != -1 && cBAsp.SelectedItem.ToString() != "")
+ {
+ var list = await SQL.ReadListStringTwoColumns($"SELECT Name, Tel_Nr FROM zkup.ansprechpartner WHERE Name = '{cBAsp.SelectedItem.ToString()}'");
+ tbAnsprechp_Intern.Text = list[0].Split(';')[0].ToString();
+ tbTel_Ansprechp.Text = list[0].Split(';')[1].ToString();
+ }
+ else
+ {
+ tbAnsprechp_Intern.Text = "";
+ tbTel_Ansprechp.Text = "";
+ }
+ }
+
+ private void TextBoxes_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.OemComma)
+ {
+ e.Handled = false;
+ return;
+ }
+ {
+ MessageBox.Show(this, "Komma (',') ist ein nicht erlaubtes Zeichen", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
+ e.Handled = true;
+ }
+ return;
+ }
+
+ string oldValue = "";
+ private void dgVisitors_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
+ {
+
+ oldValue = (e.EditingElement as TextBox) != null ? (e.EditingElement as TextBox).Text : "";
+ }
+
+ private void tbAnzahl_Begleiter_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ if ((sender as TextBox).Text.Length >= 2) e.Handled = true;
+ if (!System.Text.RegularExpressions.Regex.IsMatch(e.Text, "^[0-9]*$")) e.Handled = true;
+ }
+
+ private void ComboBox_DropDownOpened(object sender, EventArgs e)
+ {
+
+ }
+
+ private void Textboxes_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Command == ApplicationCommands.Paste)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+
+
+ public class Visitor
+ {
+ public string Name;
+ string Verantwortlicher_MA;
+ string Tel_Nr_Besucher;
+ string Anzahl_Begleitpersonen;
+ string Besuchstag;
+ string Grund_des_Besuchs;
+ string Oertlichkeit;
+ string Ansprechpartner_Intern;
+ string Tel_Nr_Ansprechpartner_Intern;
+
+
+
+
+ public static List DataTableToVisitor(System.Data.DataTable dataTable)
+ {
+ List x = new List();
+
+ foreach (DataRow dr in dataTable.Rows)
+ {
+ x.Add(new Visitor()
+ {
+ Name = dr[1].ToString(),
+ Verantwortlicher_MA = dr[2].ToString(),
+ Tel_Nr_Besucher = dr[3].ToString(),
+ Anzahl_Begleitpersonen = dr[4].ToString(),
+ Besuchstag = dr[5].ToString(),
+ Grund_des_Besuchs = dr[6].ToString(),
+ Ansprechpartner_Intern = dr[7].ToString(),
+ Tel_Nr_Ansprechpartner_Intern = dr[8].ToString(),
+ Oertlichkeit = dr[9].ToString()
+ });
+ }
+
+ return x;
+ }
+ }
+}
diff --git a/ZKuP/ParkausweisDisclaimer.xaml b/ZKuP/ParkausweisDisclaimer.xaml
new file mode 100644
index 0000000..72fb614
--- /dev/null
+++ b/ZKuP/ParkausweisDisclaimer.xaml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/ParkausweisDisclaimer.xaml.cs b/ZKuP/ParkausweisDisclaimer.xaml.cs
new file mode 100644
index 0000000..3504e31
--- /dev/null
+++ b/ZKuP/ParkausweisDisclaimer.xaml.cs
@@ -0,0 +1,46 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für ParkausweisDisclaimer.xaml
+ ///
+ public partial class ParkausweisDisclaimer : Window
+ {
+ public ParkausweisDisclaimer()
+ {
+ InitializeComponent();
+ }
+
+ private void btnDecline_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void btnAccept_Click(object sender, RoutedEventArgs e)
+ {
+ if (cBAccept.IsChecked.Value == true)
+ {
+ this.Close();
+
+ CreateParkausweis cPa = new CreateParkausweis();
+ //cPa.Owner = this;
+ cPa.ShowDialog();
+ }
+ else
+ cBAccept.Foreground = new SolidColorBrush(Colors.Red);
+ }
+ }
+}
diff --git a/ZKuP/PrintParkausweis.xaml b/ZKuP/PrintParkausweis.xaml
new file mode 100644
index 0000000..821c27f
--- /dev/null
+++ b/ZKuP/PrintParkausweis.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/PrintParkausweis.xaml.cs b/ZKuP/PrintParkausweis.xaml.cs
new file mode 100644
index 0000000..05d5acd
--- /dev/null
+++ b/ZKuP/PrintParkausweis.xaml.cs
@@ -0,0 +1,56 @@
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für PrintParkausweis.xaml
+ ///
+ public partial class PrintParkausweis : Window
+ {
+ public PrintParkausweis()
+ {
+ InitializeComponent();
+
+ var list = SQL.ReadSQL($"SELECT * FROM parkausweise WHERE Genehmigt = '1' AND Gedruckt = '0'").Result;
+ dgPrint.DataContext = list;
+ }
+
+ private async void btnPrint_Click(object sender, RoutedEventArgs e)
+ {
+ var arr = ((sender as Button).DataContext as System.Data.DataRowView).Row.ItemArray;
+
+ if (MessageBox.Show(this, $"Möchten Sie den Parkausweis für {arr[1].ToString()} {arr[2].ToString()} sicher drucken?", "Sicher?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
+ {
+ if (Helper.OpenAndEditWord($"{arr[1].ToString()} {arr[2].ToString()}", arr[3].ToString(), arr[7].ToString(), arr[0].ToString()))
+ {
+ if (MessageBox.Show(this, "Wurde der Parkausweis erfolgreich gedruckt?", "Erfolgreich gedruckt?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"UPDATE parkausweise SET Gedruckt = '1' WHERE idparkausweise = '{(int)arr[0]}'");
+ }
+ }
+ else
+ {
+ if (MessageBox.Show(this, "Es wurde ein Fehler beim Vorgang festgestellt\nWurde der Parkausweis dennoch erfolgreich gedruckt?", "Fehler", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ await SQL.WriteSQL($"UPDATE parkausweise SET Gedruckt = '1' WHERE idparkausweise = '{(int)arr[0]}'");
+ }
+ }
+
+ var list = SQL.ReadSQL($"SELECT * FROM parkausweise WHERE Genehmigt = '1' AND Gedruckt = '0'").Result;
+ dgPrint.DataContext = list;
+ }
+ }
+ }
+}
diff --git a/ZKuP/Properties/AssemblyInfo.cs b/ZKuP/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..22d2233
--- /dev/null
+++ b/ZKuP/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("ZKuP")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Deutsche Bahn AG")]
+[assembly: AssemblyProduct("ZKuP")]
+[assembly: AssemblyCopyright("Copyright © Marcus Bachler 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
+//ImCodeVerwendeteKultur in der .csproj-Datei
+//in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch
+//(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung
+//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile,
+//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
+ //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
+ // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
+ ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
+ //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
+ // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
+)]
+
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ZKuP/Properties/Resources.Designer.cs b/ZKuP/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..dd3fc68
--- /dev/null
+++ b/ZKuP/Properties/Resources.Designer.cs
@@ -0,0 +1,306 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace ZKuP.Properties {
+ using System;
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
+ // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ZKuP.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Capture_Sigma
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Capture_Sigma", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Green
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Green", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Green_Delta
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Green_Delta", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Green_Gamma
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Green_Gamma", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Yellow
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Yellow", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Yellow_Delta
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Yellow_Delta", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap LED_Yellow_Gamma
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("LED_Yellow_Gamma", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap OK_BW
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("OK_BW", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap OK_RGB
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("OK_RGB", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Alpha
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Alpha", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Delta
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Delta", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Gamma
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Gamma", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Omega
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Omega", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Sigma
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Sigma", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Pad_Zeta
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Pad_Zeta", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Scroll_RGB
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Scroll_RGB", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
+ ///
+ internal static System.Drawing.Icon STPadLibNet_Demo_App
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("STPadLibNet_Demo_App", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Welcome
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Welcome", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Cancel_BW
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Cancel_BW", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap Cancel_RGB
+ {
+ get
+ {
+ object obj = ResourceManager.GetObject("Cancel_RGB", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ZKuP/Properties/Resources.resx b/ZKuP/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/ZKuP/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ZKuP/Properties/Settings.Designer.cs b/ZKuP/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..7990073
--- /dev/null
+++ b/ZKuP/Properties/Settings.Designer.cs
@@ -0,0 +1,122 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace ZKuP.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("747")]
+ public double Height {
+ get {
+ return ((double)(this["Height"]));
+ }
+ set {
+ this["Height"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1624")]
+ public double Width {
+ get {
+ return ((double)(this["Width"]));
+ }
+ set {
+ this["Width"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("100")]
+ public double Top {
+ get {
+ return ((double)(this["Top"]));
+ }
+ set {
+ this["Top"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("100")]
+ public double Left {
+ get {
+ return ((double)(this["Left"]));
+ }
+ set {
+ this["Left"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("300")]
+ public global::System.Windows.GridLength gridOverviewHeight {
+ get {
+ return ((global::System.Windows.GridLength)(this["gridOverviewHeight"]));
+ }
+ set {
+ this["gridOverviewHeight"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Normal")]
+ public global::System.Windows.WindowState State {
+ get {
+ return ((global::System.Windows.WindowState)(this["State"]));
+ }
+ set {
+ this["State"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool ShowParkcardAccept {
+ get {
+ return ((bool)(this["ShowParkcardAccept"]));
+ }
+ set {
+ this["ShowParkcardAccept"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("100")]
+ public global::System.Windows.GridLength gridTodayHeight {
+ get {
+ return ((global::System.Windows.GridLength)(this["gridTodayHeight"]));
+ }
+ set {
+ this["gridTodayHeight"] = value;
+ }
+ }
+ }
+}
diff --git a/ZKuP/Properties/Settings.settings b/ZKuP/Properties/Settings.settings
new file mode 100644
index 0000000..cb01013
--- /dev/null
+++ b/ZKuP/Properties/Settings.settings
@@ -0,0 +1,30 @@
+
+
+
+
+
+ 747
+
+
+ 1624
+
+
+ 100
+
+
+ 100
+
+
+ 300
+
+
+ Normal
+
+
+ False
+
+
+ 100
+
+
+
\ No newline at end of file
diff --git a/ZKuP/Properties/app.manifest b/ZKuP/Properties/app.manifest
new file mode 100644
index 0000000..f3b6739
--- /dev/null
+++ b/ZKuP/Properties/app.manifest
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZKuP/Resources/Cancel BW.png b/ZKuP/Resources/Cancel BW.png
new file mode 100644
index 0000000..8b78edd
Binary files /dev/null and b/ZKuP/Resources/Cancel BW.png differ
diff --git a/ZKuP/Resources/Capture Sigma.png b/ZKuP/Resources/Capture Sigma.png
new file mode 100644
index 0000000..b61409e
Binary files /dev/null and b/ZKuP/Resources/Capture Sigma.png differ
diff --git a/ZKuP/Resources/NoSignature.png b/ZKuP/Resources/NoSignature.png
new file mode 100644
index 0000000..a0fbe67
Binary files /dev/null and b/ZKuP/Resources/NoSignature.png differ
diff --git a/ZKuP/Resources/OK BW.png b/ZKuP/Resources/OK BW.png
new file mode 100644
index 0000000..191d0b2
Binary files /dev/null and b/ZKuP/Resources/OK BW.png differ
diff --git a/ZKuP/Resources/PLZ_MUC.txt b/ZKuP/Resources/PLZ_MUC.txt
new file mode 100644
index 0000000..581c487
--- /dev/null
+++ b/ZKuP/Resources/PLZ_MUC.txt
@@ -0,0 +1,152 @@
+80995
+80997
+80999
+81247
+81249
+80331
+80333
+80335
+80336
+80469
+80538
+80539
+81541
+81543
+81667
+81669
+81671
+81675
+81677
+81241
+81243
+81245
+81249
+81671
+81673
+81677
+81735
+81825
+81829
+81675
+81677
+81679
+81925
+81927
+81929
+80933
+80935
+80995
+80689
+81375
+81377
+80639
+80686
+80687
+80689
+80331
+80335
+80336
+80337
+80339
+80469
+80538
+80333
+80335
+80539
+80636
+80797
+80798
+80799
+80802
+80797
+80807
+80809
+80933
+80935
+80937
+80939
+80637
+80638
+80992
+80993
+80995
+80997
+80335
+80634
+80636
+80637
+80638
+80639
+80797
+80809
+80992
+81539
+81541
+81547
+81549
+80687
+80689
+80992
+80997
+81241
+81243
+81245
+81247
+81249
+81539
+81541
+81549
+81669
+81671
+81735
+81737
+81739
+81827
+80538
+80539
+80799
+80801
+80802
+80803
+80804
+80805
+80807
+80939
+80796
+80797
+80798
+80799
+80801
+80803
+80804
+80809
+80335
+80339
+80336
+80337
+81369
+81371
+81373
+81379
+80686
+81369
+81373
+81377
+81379
+81369
+81371
+81379
+81475
+81476
+81477
+81479
+81735
+81825
+81827
+81829
+85540
+81539
+81543
+81545
+81547
+81549
\ No newline at end of file
diff --git a/ZKuP/Resources/Pad Sigma.png b/ZKuP/Resources/Pad Sigma.png
new file mode 100644
index 0000000..5e80b0b
Binary files /dev/null and b/ZKuP/Resources/Pad Sigma.png differ
diff --git a/ZKuP/Resources/db-logo.png b/ZKuP/Resources/db-logo.png
new file mode 100644
index 0000000..b393ae4
Binary files /dev/null and b/ZKuP/Resources/db-logo.png differ
diff --git a/ZKuP/SQL.cs b/ZKuP/SQL.cs
new file mode 100644
index 0000000..8903da8
--- /dev/null
+++ b/ZKuP/SQL.cs
@@ -0,0 +1,447 @@
+using MySql.Data.MySqlClient;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZKuP
+{
+ public static class SQL
+ {
+ static string connstr = "Server=10.20.98.34;Uid=ZK;Pwd=ZKUser#2001;database=zkup";
+ static MySqlConnection conn = new MySqlConnection(connstr);
+ static MySqlDataAdapter adp = new MySqlDataAdapter();
+
+
+ public static bool CheckDeviceConnection(string ip)
+ {
+ System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
+ //change the following ip variable into the ip adress you are looking for
+
+ System.Net.IPAddress address = System.Net.IPAddress.Parse(ip);
+ System.Net.NetworkInformation.PingReply pong = ping.Send(address);
+ if (pong.Status == System.Net.NetworkInformation.IPStatus.Success)
+ {
+ return true;
+ }
+ else
+ {
+ pong = ping.Send(address);
+
+ if (pong.Status == System.Net.NetworkInformation.IPStatus.Success)
+ {
+ return true;
+ }
+ else
+ {
+ System.Windows.MessageBox.Show($"Server ist nicht erreichbar\nNetzwerkverbindung überprüfen", "Fehler", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
+ System.Windows.Application.Current.Shutdown();
+ return false;
+ }
+ return false;
+ }
+ }
+
+
+ public static MySqlDataAdapter GetAdapter()
+ {
+ return adp;
+ }
+
+ public static MySqlConnection GetConnection()
+ {
+ return conn;
+ }
+
+ public static bool TestConnection()
+ {
+ if (!CheckDeviceConnection("10.20.98.34")) return false;
+
+ using (conn)
+ {
+ try
+ {
+ conn.Open();
+ conn.Close();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+
+ System.Windows.MessageBox.Show($"Verbindung zum Server konnte nicht hergestellt werden\n\nInterne Meldung: {ex.Message}", "Fehler", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
+ return false;
+ }
+ }
+ }
+
+ public static async Task WriteSQL(string SQLQuery, DataTable list)
+ {
+ var filter = list.DefaultView.RowFilter;
+
+ try
+ {
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ adp.UpdateCommand = new MySqlCommand(SQLQuery, conn);
+
+ adp.Update(list);
+
+ list.AcceptChanges();
+ conn.Close();
+ }
+
+ list.DefaultView.RowFilter = filter;
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ return list;
+ }
+
+ return list;
+ }
+
+ public static async Task WriteSQL(string SQLQuery)
+ {
+ try
+ {
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ MySqlCommand cmd = new MySqlCommand(SQLQuery, conn);
+ cmd.ExecuteNonQuery();
+ conn.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ }
+ }
+
+ public static async Task WriteSQL(string SQLQuery, byte[] data)
+ {
+ try
+ {
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ MySqlCommand cmd = new MySqlCommand(SQLQuery, conn);
+ cmd.Parameters.Add("@signature", MySqlDbType.LongBlob).Value = data;
+ cmd.ExecuteNonQuery();
+ conn.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ }
+ }
+
+
+
+ public static async Task ReadSQL(string SQLCommand, DataTable list)
+ {
+ var filter = list.DefaultView.RowFilter;
+ try
+ {
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ adp.SelectCommand = new MySqlCommand(SQLCommand, conn);
+
+ list.Clear();
+ adp.Fill(list);
+ conn.Close();
+ }
+
+ list.DefaultView.RowFilter = filter;
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ return list;
+ }
+
+ return list;
+ }
+
+ public static async Task ReadSQL(string SQLCommand)
+ {
+ DataTable list = new DataTable();
+
+ try
+ {
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ adp.SelectCommand = new MySqlCommand(SQLCommand, conn);
+
+ list.Clear();
+ adp.Fill(list);
+ conn.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ return list;
+ }
+
+ return list;
+ }
+
+
+ public static async Task ReadSingleValueAsync(string SQLCommand)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ object queryResult;
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ queryResult = cmd.ExecuteScalar();//Return an object so first check for null
+ }
+
+
+ if (queryResult != null)
+ return queryResult.ToString();
+ else
+ return "";
+ }
+
+ public static string ReadSingleValue(string SQLCommand)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ object queryResult;
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ queryResult = cmd.ExecuteScalar();//Return an object so first check for null
+ }
+
+
+ if (queryResult != null)
+ return queryResult.ToString();
+ else
+ return "";
+ }
+
+ public static System.Drawing.Bitmap ReadSingleByteArr(string SQLCommand)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ UInt32 FileSize;
+ byte[] rawData;
+ System.Drawing.Bitmap image = null;
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ MySql.Data.MySqlClient.MySqlDataReader myData = cmd.ExecuteReader();
+ while (myData.Read())
+ {
+ if (myData[0] == DBNull.Value)
+ return null;
+
+ byte[] data = (byte[])myData[0]; // 0 is okay if you only selecting one column
+ //And use:
+ //using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data))
+ //{
+ System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
+ image = new System.Drawing.Bitmap(ms);
+ //}
+ }
+ }
+
+ //if (rawData != null)
+ // return (byte[])rawData;
+ //else
+ return image;
+ }
+
+ public static async Task> ReadListString(string SQLCommand, int ColumnID = 0)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ List queryResult = new List();
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ while (reader.Read())
+ {
+ queryResult.Add(reader.GetString(ColumnID));
+ }
+ }
+
+ conn.Close();
+ }
+
+ return queryResult;
+ }
+
+ ///
+ /// Read two Columns, separated by ';'
+ ///
+ ///
+ ///
+ ///
+ public static async Task> ReadDateTimeAndStringList(string SQLCommand, int ColumnID = 0)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ List queryResult = new List();
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ while (reader.Read())
+ {
+ queryResult.Add(reader.GetDateTime(ColumnID).ToString("yyyy-MM-dd HH:mm:ss") + ";" + reader.GetString(ColumnID + 1));
+ }
+ }
+
+ conn.Close();
+ }
+
+ return queryResult;
+ }
+
+ ///
+ /// Read two Columns, separated by ';' or choose Seperator
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task> ReadListStringTwoColumns(string SQLCommand, string Seperator = ";", int ColumnID = 0)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(SQLCommand, conn);
+ List queryResult = new List();
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+
+ using (MySqlDataReader reader = cmd.ExecuteReader())
+ {
+ while (reader.Read())
+ {
+ queryResult.Add(reader.GetString(ColumnID) + $"{Seperator}" + reader.GetString(ColumnID + 1));
+ }
+ }
+
+ conn.Close();
+ }
+
+ return queryResult;
+ }
+
+
+ public static async Task RowExists(string Table, string Column, string Value)
+ {
+ MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand($"SELECT EXISTS(SELECT * FROM {Table} WHERE {Column} = '{Value}')", conn);
+ object queryResult;
+ var res = 0;
+
+ using (conn)
+ {
+ if (conn.State == ConnectionState.Open) conn.Close();
+
+ conn.Open();
+ queryResult = cmd.ExecuteScalar();//Return an object so first check for null
+ }
+
+ if (queryResult != null)
+ res = Convert.ToInt16(queryResult);
+
+ if (res == 1)
+ return true;
+ else if (res == 0)
+ return false;
+ else return false;
+ }
+
+ //public static async Task ReadAllData(DataTable list)
+ //{
+ // var filter = list.DefaultView.RowFilter;
+
+ // using (conn)
+ // {
+ // if (conn.State == ConnectionState.Open) conn.Close();
+
+ // conn.Open();
+ // adp.SelectCommand = new MySqlCommand("select PersNr,Name,Vorname,Abteilung,o.Datum,Beginn,Gehen,Tagescode,Arbeitsmuster,Zuweisung,Bemerkung,Telefon,AnzahlLizenzen,ZugNameB from pep_tool.mitarbeiter_static p left join pep_tool.mitarbeiter_change o ON o.mitarbeiter_static_PersNr = p.PersNr ORDER BY Name", conn);
+ // list.Clear();
+ // adp.Fill(list);
+ // conn.Close();
+ // }
+
+ // list.DefaultView.RowFilter = filter;
+ // return list;
+ //}
+
+ //public static async Task ReadAllData(string filter = "")
+ //{
+ // try
+ // {
+ // DataTable list = new DataTable("UserList");
+
+ // using (conn)
+ // {
+ // if (conn.State == ConnectionState.Open) conn.Close();
+
+ // conn.Open();
+ // adp.SelectCommand = new MySqlCommand("select PersNr,Name,Vorname,Abteilung,o.Datum,Beginn,Gehen,Tagescode,Arbeitsmuster,Zuweisung,Bemerkung,Telefon,AnzahlLizenzen,ZugNameB from pep_tool.mitarbeiter_static p left join pep_tool.mitarbeiter_change o ON o.mitarbeiter_static_PersNr = p.PersNr ORDER BY Name", conn);
+ // list.Columns.Clear();
+ // adp.Fill(list);
+ // conn.Close();
+ // }
+
+ // list.DefaultView.RowFilter = filter;
+ // return list;
+ // }
+ // catch (Exception ex)
+ // {
+ // System.Diagnostics.Debug.WriteLine(ex);
+ // return await ReadAllData();
+ // }
+ //}
+ }
+}
diff --git a/ZKuP/Signature.xaml b/ZKuP/Signature.xaml
new file mode 100644
index 0000000..b144e8d
--- /dev/null
+++ b/ZKuP/Signature.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZKuP/Signature.xaml.cs b/ZKuP/Signature.xaml.cs
new file mode 100644
index 0000000..ff68c3d
--- /dev/null
+++ b/ZKuP/Signature.xaml.cs
@@ -0,0 +1,114 @@
+using signotec.STPadLibNet;
+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 ZKuP
+{
+ ///
+ /// Interaktionslogik für Signature.xaml
+ ///
+ public partial class Signature : Window
+ {
+ public System.Drawing.Bitmap Result { get; set; }
+ public byte[] ResultByte { get; set; }
+ //private STPadLibControl _stPad = new STPadLibControl();
+
+ public Signature(string Name = "", string Firma = "", string Kennzeichen = "", bool showDisclaimer = true)
+ {
+ InitializeComponent();
+
+ try
+ {
+ if (signoPad._stPad.DeviceGetCount() <= 0)
+ {
+ this.Close();
+ return;
+ }
+
+ signoPad._stPad = new STPadLibControl();
+ STPadLibControlHost.Child = signoPad._stPad;
+ signoPad._stPad.ControlMirrorDisplay = MirrorMode.Signature;
+
+ signoPad.ShowDisclaimer(Name, Firma, Kennzeichen, showDisclaimer);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteLog(ex.ToString());
+ MessageBox.Show($"Es ist ein Fehler aufgetreten\n\nInterne Meldung: {ex.Message}");
+ }
+ }
+
+ private void btnConfirm_Click(object sender, RoutedEventArgs e)
+ {
+ System.Drawing.Imaging.ImageFormat format;
+ SignatureImageFlag options = SignatureImageFlag.None;
+
+ format = System.Drawing.Imaging.ImageFormat.Tiff;
+
+ int resolution = 300;
+ int width = 0;
+ int height = 0;
+ int penWidth = 0;
+ System.Drawing.Color penColor = System.Drawing.Color.FromArgb(255,0,0,0);
+
+ options = signotec.STPadLibNet.SignatureImageFlag.Timestamp | signotec.STPadLibNet.SignatureImageFlag.TimestampRelToImage | signotec.STPadLibNet.SignatureImageFlag.DontSmooth;
+
+ try
+ {
+ string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\temp.tif";
+ // save as file
+ //Result = signoPad._stPad.SignatureSaveAsStreamEx(resolution, width, height, penWidth, penColor, options);
+ signoPad._stPad.SignatureSaveAsFileEx(path, resolution, width, height, System.Drawing.Imaging.ImageFormat.Tiff, penWidth,penColor, options);
+
+ ResultByte = DBImageManager.ImageFromFileToByte(path);
+ MessageBox.Show(this, "Unterschrift erfolgreich gespeichert", "Gespeichert", MessageBoxButton.OK, MessageBoxImage.Information);
+
+ //signoPad.CloseConnection();
+ this.Close();
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //signoPad.CloseConnection();
+ this.Close();
+ }
+
+ }
+
+ private async void GetSignatureImage()
+ {
+ //System.Drawing.Bitmap bitmap = SQL.ReadSingleBitmap("");
+
+ //// display image
+ //ImageView imageView = new ImageView();
+ //imageView.BackgroundImage = Helper.ConvertBitmapToImage(bitmap);
+ //imageView.ShowDialog();
+ }
+
+
+
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ signoPad.CloseConnection();
+ }
+
+ private void btnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ //signoPad.CloseConnection();
+ this.Close();
+ }
+ }
+}
diff --git a/ZKuP/ZKuP.csproj b/ZKuP/ZKuP.csproj
new file mode 100644
index 0000000..fbf3dc6
--- /dev/null
+++ b/ZKuP/ZKuP.csproj
@@ -0,0 +1,444 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}
+ WinExe
+ ZKuP
+ ZKuP
+ v4.5.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+
+ false
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ true
+ 0
+ 1.0.0.%2a
+ false
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ ZKuP.ico
+
+
+ true
+ bin\x64\Debug\
+ false
+ win-x64
+ true
+ true
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ bin\x64\Release\
+ win-x64
+ true
+ true
+
+
+ true
+ none
+ x64
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ 3C16B2C32C7121098E02D5B8C9B97FB987E781D1
+
+
+ ZKuP_TemporaryKey.pfx
+
+
+ false
+
+
+ false
+
+
+ LocalIntranet
+
+
+ Properties\app.manifest
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ bin\x86\Release\
+ true
+ x86
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+ ..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll
+
+
+ ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
+
+
+ ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll
+
+
+ ..\packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll
+ True
+
+
+ ..\packages\MySql.Data.8.0.18\lib\net452\MySql.Data.dll
+
+
+ ..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll
+
+
+ ..\..\..\..\..\..\Program Files\signotec\signoPAD-API\STPadLibNet\STPadLibNet.dll
+ False
+ True
+
+
+
+ ..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll
+
+
+
+
+
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net45\System.Diagnostics.DiagnosticSource.dll
+
+
+
+
+
+
+ ..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll
+
+
+
+ ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ AddCardUser.xaml
+
+
+ Arrivals.xaml
+
+
+ ArrivalsOverview.xaml
+
+
+ AspInfo.xaml
+
+
+ Cards.xaml
+
+
+ CheckParkausweis.xaml
+
+
+ CreateFirma.xaml
+
+
+ CreateParkausweis.xaml
+
+
+ CreateVisitor.xaml
+
+
+ CreateVisitor_List.xaml
+
+
+
+ Delivery.xaml
+
+
+ GrantParkausweis.xaml
+
+
+ ImageView.xaml
+
+
+
+ ManageDeliveries.xaml
+
+
+ ManageParkausweis.xaml
+
+
+ ManageVisitor.xaml
+
+
+
+ ManageAsp.xaml
+
+
+ ManageUsers.xaml
+
+
+ ParkausweisDisclaimer.xaml
+
+
+ PrintParkausweis.xaml
+
+
+ Signature.xaml
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.5.2 %28x86 und x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {0002E157-0000-0000-C000-000000000046}
+ 5
+ 3
+ 0
+ primary
+ False
+ True
+
+
+
+
+
+
+
+
+
+ Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".
+
+
+
+
+
\ No newline at end of file
diff --git a/ZKuP/ZKuP.ico b/ZKuP/ZKuP.ico
new file mode 100644
index 0000000..4fc2cfc
Binary files /dev/null and b/ZKuP/ZKuP.ico differ
diff --git a/ZKuP/packages.config b/ZKuP/packages.config
new file mode 100644
index 0000000..2d09f1c
--- /dev/null
+++ b/ZKuP/packages.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZKuP/signoPad.cs b/ZKuP/signoPad.cs
new file mode 100644
index 0000000..4ada6e8
--- /dev/null
+++ b/ZKuP/signoPad.cs
@@ -0,0 +1,868 @@
+using signotec.STPadLibNet;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Windows.Media.Imaging;
+using static ZKuP.signoPad;
+
+namespace ZKuP
+{
+ public class signoPad
+ {
+ public enum PadModel
+ {
+ Sigma,
+ Zeta,
+ Omega,
+ Gamma,
+ Delta,
+ Alpha
+ }
+
+
+ //private static STPadLibControl _stPad = new STPadLibControl();
+ private static STPadLibControl sTPad = new STPadLibControl();
+ public static STPadLibControl _stPad
+ {
+ get { return sTPad; }
+ set { sTPad = value; }
+ }
+
+
+ private static SignPad[] _signPads = null;
+ private static DisplayTarget _storeIdSigning = DisplayTarget.NewStandardStore;
+ private static DisplayTarget _storeIdOverlay = DisplayTarget.NewStandardStore;
+
+ private static int _buttonCancelId = -1;
+ private static int _buttonRetryId = -1;
+ private static int _buttonConfirmId = -1;
+
+ static string _disclaimer = "";
+
+
+ private static void GetDevices()
+ {
+ try
+ {
+ //sTPad = new STPadLibControl();
+ // get number of connected devices
+ int deviceCount = _stPad.DeviceGetCount();
+
+ // erase all entries
+ //ListOfDevices.Items.Clear();
+
+ // build list
+ if (deviceCount <= 0)
+ { // no devices detected
+ _signPads = null;
+ System.Windows.MessageBox.Show("Kein Unterschriftenpad gefunden!", "Fehler", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
+ //ListOfDevices.Items.Add("No Devices");
+ //ListOfDevices.Items.Add("detected");
+ //ListOfDevices.IsEnabled = false;
+ //ButtonOpenClose.Content = "Open";
+ //ButtonOpenClose.IsEnabled = false;
+ //ButtonStartCancel.IsEnabled = false;
+ //ButtonRetry.IsEnabled = false;
+ //ButtonConfirm.IsEnabled = false;
+ //ImagePad.Source = GetBitmapFromResource(STPadLibNet_Demo_App.Properties.Resources.Welcome, System.Drawing.Imaging.ImageFormat.Png);
+ //ImagePad.Visibility = Visibility.Visible;
+ //ImageLed.Visibility = Visibility.Hidden;
+ //STPadLibControlHost.Visibility = Visibility.Hidden;
+ //LabelType.Content = "Type: -";
+ //LabelPort.Content = "Port: -";
+ //LabelFirmware.Content = "Firmware: -";
+ //LabelSerial.Content = "Serial: -";
+ //LabelDisplay.Content = "Display: -";
+ }
+ else
+ { // build device list
+ _signPads = new SignPad[deviceCount];
+ for (int i = 0; i < deviceCount; i++)
+ {
+ _signPads[i] = new SignPad(_stPad, i);
+ //ListOfDevices.Items.Add(String.Format("Device {0}", i + 1));
+ }
+ //ListOfDevices.IsEnabled = true;
+
+ // select first element of list
+ //if (deviceCount > 0)
+ // 0 = 0;
+ _stPad.SensorHotSpotPressed += new SensorHotSpotPressedEventHandler(STPad_SensorHotSpotPressed);
+ _stPad.ControlMirrorDisplay = MirrorMode.Signature;
+
+ }
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ throw;
+ }
+
+ }
+
+
+
+ public static bool ShowDisclaimer(string Name = "", string Firma = "", string Kennzeichen = "", bool showDisclaimer = true)
+ {
+ // display disclaimer and two buttons "Cancel" and "Confirm"
+ GetDevices();
+
+ try
+ {
+
+ _stPad.DeviceOpen(0,true);
+
+ _stPad.DisplaySetStandbyImage(Helper.LoadBitmapFromResource("Resources/db-logo.png"));
+ // clear all hot spots
+ ClearHotSpots();
+
+ // clear signature window
+ _stPad.SensorClearSignRect();
+
+ // erase LCD and background buffer
+ _stPad.DisplayErase();
+
+ // set font
+ float fontSize = 0;
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ fontSize = 20;
+ break;
+ case PadModel.Omega:
+ fontSize = 40;
+ break;
+ case PadModel.Gamma:
+ fontSize = 45;
+ break;
+ case PadModel.Delta:
+ case PadModel.Alpha:
+ fontSize = 60;
+ break;
+ }
+ _stPad.DisplaySetFont(new System.Drawing.Font("Arial", fontSize));
+
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ // do all the following drawing operations in the background buffer
+ _stPad.DisplaySetTarget(DisplayTarget.BackgroundBuffer);
+
+ // load button bitmaps and set hot spots
+ // "Cancel" button
+ System.Drawing.Bitmap button = Helper.LoadBitmapFromResource("Resources/Cancel BW.png");
+ int x = 20;
+ int y = _stPad.DisplayHeight - button.Height - 7;
+ _stPad.DisplaySetImage(x, y, button);
+ _buttonCancelId = _stPad.SensorAddHotSpot(x, y, button.Width, button.Height);
+
+ // "Confirm" button
+ button = Helper.LoadBitmapFromResource("Resources/OK BW.png");
+ x = _stPad.DisplayWidth - button.Width - 20;
+ _stPad.DisplaySetImage(x, y, button);
+ _buttonConfirmId = _stPad.SensorAddHotSpot(x, y, button.Width, button.Height);
+
+ if (showDisclaimer) // display disclaimer
+ {
+ if (Firma != "" && Name != "" && Kennzeichen != "")
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Ich bestätige hiermit dass ich eine Einweisung inkl. Flyer vom Pförtner erhalten habe\n\nFirma / Besucher: {Firma}\nVerantwortlicher: {Name}\nKennzeichen: {Kennzeichen}");
+ else if (Firma != "" && Name != "" && Kennzeichen == "")
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Ich bestätige hiermit dass ich eine Einweisung inkl. Flyer vom Pförtner erhalten habe\n\nFirma / Besucher: {Firma}\nVerantwortlicher: {Name}");
+ else
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Ich bestätige hiermit dass ich eine Einweisung inkl. Flyer vom Pförtner erhalten habe\n\nFirma / Besucher: {Firma}");
+ }
+ else
+ {
+ if (Firma != "" && Name != "" && Kennzeichen != "")
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Firma / Besucher: {Firma}\nVerantwortlicher: {Name}\nKennzeichen: {Kennzeichen}");
+ else if (Firma != "" && Name != "" && Kennzeichen == "")
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Firma / Besucher: {Firma}\nVerantwortlicher: {Name}");
+ else
+ _stPad.DisplaySetTextInRect(10, 10, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 60, signotec.STPadLibNet.TextAlignment.Left, $"Firma / Besucher: {Firma}");
+ }
+
+
+ break;
+ case PadModel.Omega:
+ case PadModel.Gamma:
+ case PadModel.Delta:
+ if (_signPads[0].FastConnection)
+ // fast connection: do all drawing operations in the overlay buffer
+ _storeIdOverlay = _stPad.DisplaySetTarget(DisplayTarget.OverlayBuffer);
+ else
+ // do all the following drawing operations in the permanent memory
+ _storeIdOverlay = _stPad.DisplaySetTarget(_storeIdOverlay);
+
+ // load button bitmaps and set hot spots for toolbar
+ // "Cancel" button
+ button = Helper.LoadBitmapFromResource("Resources/Cancel RGB.png");
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Omega:
+ x = 24;
+ break;
+ default:
+ x = 45;
+ break;
+ }
+ y = _stPad.DisplayHeight - button.Height - 14;
+ _stPad.DisplaySetImage(x, y, button);
+ _buttonCancelId = _stPad.SensorAddHotSpot(x, y, button.Width, button.Height);
+
+ // "Confirm" button
+ button = Helper.LoadBitmapFromResource("Resources/OK RGB.png");
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Omega:
+ x = 234;
+ break;
+ case PadModel.Gamma:
+ x = 315;
+ break;
+ case PadModel.Delta:
+ x = 555;
+ break;
+ }
+ _stPad.DisplaySetImage(x, y, button);
+ _buttonConfirmId = _stPad.SensorAddHotSpot(x, y, button.Width, button.Height);
+
+ // Scroll buttons
+ button = Helper.LoadBitmapFromResource("Resources/Scroll RGB.png");
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Omega:
+ x = 444;
+ break;
+ case PadModel.Gamma:
+ x = 585;
+ break;
+ case PadModel.Delta:
+ x = 1065;
+ break;
+ }
+ _stPad.DisplaySetImage(x, y, button);
+ _stPad.SensorAddScrollHotSpot(x, y, 66, 66, ScrollOption.ScrollDown);
+ x += 104;
+ _stPad.SensorAddScrollHotSpot(x, y, 66, 66, ScrollOption.ScrollUp);
+
+ if (!_signPads[0].FastConnection)
+ {
+ // do all the following drawing operations in the overlay buffer
+ _stPad.DisplaySetTarget(DisplayTarget.OverlayBuffer);
+
+ // copy stored image to overlay buffer
+ _stPad.DisplaySetImageFromStore(_storeIdOverlay);
+ }
+
+ // do all the following drawing operations in the background buffer
+ _stPad.DisplaySetTarget(DisplayTarget.BackgroundBuffer);
+
+ // draw disclaimer
+ x = 10;
+ y = 10;
+ int size = _stPad.DisplaySetTextInRect(x, y, _stPad.DisplayWidth - 20, _stPad.DisplayHeight - 80, signotec.STPadLibNet.TextAlignment.Left, _disclaimer);
+
+ // use font size of the disclaimer text
+ if (size != (int)fontSize)
+ _stPad.DisplaySetFont(new System.Drawing.Font("Arial", size, System.Drawing.FontStyle.Regular));
+
+ // set scroll text
+ y = _stPad.DisplayHeight - 80;
+ _stPad.DisplaySetTextInRect(x, y, _stPad.DisplayWidth - 20, 100, signotec.STPadLibNet.TextAlignment.Left, "Congratulations! If you can read this text you have found the scroll buttons!");
+ if (_signPads[0].PadModel == PadModel.Delta)
+ {
+ y += _stPad.DisplayHeight;
+ _stPad.DisplaySetTextInRect(x, y, _stPad.DisplayWidth - 20, 200, 0, "Doesn't the Delta have an impressive large image buffer?");
+ const int x2 = 320;
+ while ((y + _stPad.DisplayHeight) < _stPad.DisplayTargetHeight)
+ {
+ y += _stPad.DisplayHeight;
+ _stPad.DisplaySetTextInRect(x, y, _stPad.DisplayWidth - 20, 200, 0, String.Format("You've reached line {0} of {1}!", y, _stPad.DisplayTargetHeight));
+
+ if ((y + _stPad.DisplayHeight) < _stPad.DisplayTargetHeight)
+ {
+ y += _stPad.DisplayHeight;
+ _stPad.DisplaySetTextInRect(x2, y, _stPad.DisplayWidth - 2 * x2, 200, signotec.STPadLibNet.TextAlignment.CenterCenteredVertically, "Click me, I'm a scrollable button!");
+ _stPad.SensorAddScrollHotSpot(x2, y, _stPad.DisplayWidth - 2 * x2, 200, ScrollOption.Scrollable);
+ }
+ }
+ }
+
+ // set end text
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Omega:
+ y = _stPad.DisplayTargetHeight - 120;
+ break;
+ case PadModel.Gamma:
+ y = _stPad.DisplayTargetHeight - 140;
+ break;
+ case PadModel.Delta:
+ y = _stPad.DisplayTargetHeight - 160;
+ break;
+ }
+ _stPad.DisplaySetTextInRect(x, y, _stPad.DisplayWidth - 20, 60, signotec.STPadLibNet.TextAlignment.Left, "You have scrolled to the end of this text!");
+
+ // set overlay rect
+ y = _stPad.DisplayHeight - 80;
+ _stPad.DisplaySetOverlayRect(0, y, _stPad.DisplayWidth, 80);
+ break;
+ }
+
+ // do all drawing operations on the LCD
+ _stPad.DisplaySetTarget(DisplayTarget.ForegroundBuffer);
+
+ // draw buffered image
+ _stPad.DisplaySetImageFromStore(DisplayTarget.BackgroundBuffer);
+
+ // set complete buffer for scrolling
+ _stPad.SensorSetScrollArea(0, 0, 0, 0);
+
+ if (_signPads[0].SupportsPenScrolling)
+ // enable pen scrolling
+ _stPad.SensorSetPenScrollingEnabled(true);
+
+ //ButtonRetry.IsEnabled = false;
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //throw;
+ return false;
+ }
+ finally
+ {
+ //this.Cursor = Cursors.Arrow;
+ }
+ return true;
+ }
+
+ private void CancelProcess()
+ {
+ try
+ {
+ if (_stPad.SignatureState)
+ // cancel capturing (this clears the LCD, too)
+ _stPad.SignatureCancel();
+ else
+ {
+ // disable pen scrolling
+ _stPad.SensorSetPenScrollingEnabled(false);
+
+ // erase LCD
+ _stPad.DisplayErase();
+ }
+
+ // clear all hot spots
+ ClearHotSpots();
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //throw;
+ return;
+ }
+ finally
+ {
+ //this.Cursor = Cursors.Arrow;
+ }
+
+ //ButtonStartCancel.Content = "Start";
+ //ButtonStartCancel.IsEnabled = true;
+ //ButtonRetry.IsEnabled = false;
+ //ButtonConfirm.IsEnabled = false;
+ try
+ {
+ // ImageLed.Source = GetBitmapFromResource(STPadLibNet_Demo_App.Properties.Resources.LED_Yellow, System.Drawing.Imaging.ImageFormat.Png);
+ }
+ catch { }
+ }
+
+
+
+ private static void STPad_SensorHotSpotPressed(object sender, SensorHotSpotPressedEventArgs e)
+ {
+ SensorHotSpotPressedEventHandler handler = new SensorHotSpotPressedEventHandler(SensorHotSpotPressed);
+ System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(handler, new object[] { sender, e });
+ }
+
+ private static void SensorHotSpotPressed(object sender, SensorHotSpotPressedEventArgs e)
+ {
+ if (e.hotSpotId == _buttonCancelId) System.Diagnostics.Debug.WriteLine("test");
+ //ButtonStartCancel_Click(this, new System.Windows.RoutedEventArgs());
+ else if (e.hotSpotId == _buttonRetryId)
+ ButtonRetry_Click(sender, new System.Windows.RoutedEventArgs());
+ else if (e.hotSpotId == _buttonConfirmId)
+ ButtonConfirm_Click(sender, new System.Windows.RoutedEventArgs());
+ else
+ MessageBox.Show(String.Format("Hot Spot {0} clicked.", e.hotSpotId + 1));
+ }
+
+
+
+
+
+
+ public static void CloseConnection()
+ {
+ try
+ {
+ // erase display
+ _stPad.DisplayErase();
+
+ // clear hot spots
+ ClearHotSpots();
+
+ _stPad.DeviceClose(0);
+
+ //_signPads = null;
+ //_stPad = null;
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ private static void ButtonRetry_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ try
+ {
+ if (_stPad.SignatureState == true)
+ _stPad.SignatureRetry();
+ else
+ StartDefaultCapturing();
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //throw;
+ }
+ }
+
+ private static void ButtonConfirm_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ if (_stPad.SignatureState == false)
+ // accept disclaimer and start capturing
+ StartDefaultCapturing();
+ else
+ ConfirmCapturing();
+ }
+
+ private static bool StartDefaultCapturing()
+ {
+ try
+ {
+ // disable pen scrolling
+ _stPad.SensorSetPenScrollingEnabled(false);
+
+ // erase display
+ _stPad.DisplayErase();
+
+ // clear hot spots
+ ClearHotSpots();
+
+ if (_signPads[0].HasDisplay)
+ {
+ if (_signPads[0].FastConnection)
+ { // "fast" pad or connection
+ // do all drawing operations in the background buffer
+ _stPad.DisplaySetTarget(DisplayTarget.BackgroundBuffer);
+ }
+ else
+ { // "slow" pad or connection: do all drawing operations in the permanent memory
+ // make sure that always the second permanent memory is used
+ if (_storeIdOverlay < 0)
+ _storeIdOverlay = _stPad.DisplaySetTarget(_storeIdOverlay);
+ // set permanent memory as target
+ _storeIdSigning = _stPad.DisplaySetTarget(_storeIdSigning);
+ }
+
+ // draw the bitmaps
+ System.Drawing.Bitmap bitmap = null;
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ bitmap = Helper.LoadBitmapFromResource("Resources/Capture Sigma.png");
+ break;
+ }
+ _stPad.DisplaySetImage(0, 0, bitmap);
+
+ if (!_signPads[0].FastConnection)
+ {
+ // do all drawing operations in the background buffer
+ _stPad.DisplaySetTarget(DisplayTarget.BackgroundBuffer);
+
+ // draw stored image
+ _stPad.DisplaySetImageFromStore(_storeIdSigning);
+ }
+
+ if (_signPads[0].PadModel == PadModel.Alpha)
+ // draw disclaimer
+ _stPad.DisplaySetTextInRect(50, 250, _stPad.DisplayWidth - 100, 300, signotec.STPadLibNet.TextAlignment.Left, "With my signature, I certify that I'm excited about the signotec LCD Signature Pad and the signotec Pad Capture Control. This demo application has blown me away and I can't wait to integrate all these great features in my own application.");
+
+ // do all drawing operations on the LCD directly
+ _stPad.DisplaySetTarget(DisplayTarget.ForegroundBuffer);
+
+ // draw buffered image
+ _stPad.DisplaySetImageFromStore(DisplayTarget.BackgroundBuffer);
+
+ // set default signature window
+ int x = 0;
+ int y = 0;
+ int width = 0;
+ int height = 0;
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ y = 50;
+ break;
+ case PadModel.Omega:
+ case PadModel.Gamma:
+ case PadModel.Delta:
+ y = 100;
+ break;
+ case PadModel.Alpha:
+ x = 90;
+ y = 600;
+ width = 590;
+ height = 370;
+ break;
+ }
+ _stPad.SensorSetSignRect(x, y, width, height);
+
+ // add default hotspots
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ x = 12;
+ y = 9;
+ width = 85;
+ height = 33;
+ break;
+ case PadModel.Omega:
+ case PadModel.Gamma:
+ x = 24;
+ y = 18;
+ width = 170;
+ height = 66;
+ break;
+ case PadModel.Delta:
+ x = 150;
+ y = 18;
+ width = 170;
+ height = 66;
+ break;
+ case PadModel.Alpha:
+ x = 30;
+ y = 30;
+ width = 80;
+ height = 80;
+ break;
+ }
+ _buttonCancelId = _stPad.SensorAddHotSpot(x, y, width, height);
+
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ x = 117;
+ break;
+ case PadModel.Omega:
+ x = 234;
+ break;
+ case PadModel.Gamma:
+ x = 315;
+ break;
+ case PadModel.Delta:
+ x = 555;
+ break;
+ case PadModel.Alpha:
+ x = 344;
+ break;
+ }
+ _buttonRetryId = _stPad.SensorAddHotSpot(x, y, width, height);
+
+ switch (_signPads[0].PadModel)
+ {
+ case PadModel.Sigma:
+ case PadModel.Zeta:
+ x = 222;
+ break;
+ case PadModel.Omega:
+ x = 444;
+ break;
+ case PadModel.Gamma:
+ x = 605;
+ break;
+ case PadModel.Delta:
+ x = 960;
+ break;
+ case PadModel.Alpha:
+ x = 658;
+ break;
+ }
+ _buttonConfirmId = _stPad.SensorAddHotSpot(x, y, width, height);
+ }
+
+ // start capturing
+ _stPad.SignatureStart();
+
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //throw;
+ return false;
+ }
+ finally
+ {
+ }
+ return true;
+ }
+
+ private static void ConfirmCapturing()
+ {
+ try
+ {
+ // confirm capturing
+ _stPad.SignatureConfirm();
+
+ // clear hot spots
+ ClearHotSpots();
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ MessageBox.Show(exc.Message);
+ //throw;
+ }
+ }
+
+
+
+
+ #region helper methods
+
+ private static void ClearHotSpots()
+ {
+ try
+ {
+ _stPad.SensorClearHotSpots();
+ }
+ catch (STPadException exc)
+ {
+ Log.WriteLog(exc.ToString());
+ if (exc.ErrorCode != -22)
+ throw exc;
+ }
+ //_buttonCancelId = -1;
+ //_buttonRetryId = -1;
+ //_buttonConfirmId = -1;
+ }
+
+ private System.Windows.Media.Imaging.BitmapImage GetBitmapFromResource(System.Drawing.Bitmap bitmap, System.Drawing.Imaging.ImageFormat imageFormat)
+ {
+ System.IO.MemoryStream ms = new System.IO.MemoryStream();
+ bitmap.Save(ms, imageFormat);
+ System.Windows.Media.Imaging.BitmapImage bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.StreamSource = ms;
+ bitmapImage.EndInit();
+ return bitmapImage;
+ }
+
+ #endregion
+
+ }
+
+
+
+
+
+ public class SignPad
+ {
+ private STPadLibControl _stPad = null;
+ private int _index = -1;
+ private int _padType = 0;
+ private int _connectionType = 0;
+ private string _serial = "";
+ private int _fwMajor = 0;
+ private int _fwMinor = 0;
+
+ public SignPad()
+ {
+ }
+
+ public SignPad(STPadLibControl stPad, int index)
+ {
+ _stPad = stPad;
+ _index = index;
+
+ // get serial and type of selected device
+ _stPad.DeviceGetInfo(out _serial, out _padType, index);
+
+ // get connection type
+ _connectionType = _stPad.DeviceGetConnectionType(index);
+
+ // get firmware version
+ string version = _stPad.DeviceGetVersion(index);
+ string[] versionArray = version.Split('.');
+ if ((versionArray != null) && (versionArray.Length > 1))
+ {
+ _fwMajor = Int32.Parse(versionArray[0]);
+ _fwMinor = Int32.Parse(versionArray[1]);
+ }
+ }
+
+ public int PadType
+ {
+ get { return _padType; }
+ }
+
+ public PadModel PadModel
+ {
+ get
+ {
+ switch (PadType)
+ {
+ case 1:
+ case 2:
+ return PadModel.Sigma;
+ case 5:
+ case 6:
+ return PadModel.Zeta;
+ case 11:
+ case 12:
+ return PadModel.Omega;
+ case 15:
+ case 16:
+ return PadModel.Gamma;
+ case 21:
+ case 22:
+ case 23:
+ return PadModel.Delta;
+ case 31:
+ case 32:
+ case 33:
+ return PadModel.Alpha;
+ default:
+ throw new Exception("This pad type is not supported by this demo application!");
+ };
+ }
+ }
+
+ public string PadName
+ {
+ get
+ {
+ switch (_padType)
+ {
+ case 1:
+ return "Sigma USB";
+ case 2:
+ return "Sigma Serial";
+ case 5:
+ return "Zeta USB";
+ case 6:
+ return "Zeta Serial";
+ case 11:
+ return "Omega USB";
+ case 12:
+ return "Omega Serial";
+ case 15:
+ return "Gamma USB";
+ case 16:
+ return "Gamma Serial";
+ case 21:
+ return "Delta USB";
+ case 22:
+ return "Delta Serial";
+ case 23:
+ return "Delta IP";
+ case 31:
+ return "Alpha USB";
+ case 32:
+ return "Alpha Serial";
+ case 33:
+ return "Alpha IP";
+ default:
+ return "Unkown pad type " + _padType;
+ }
+ }
+ }
+
+ public string ConnectionName
+ {
+ get
+ {
+ switch (_connectionType)
+ {
+ case 0:
+ return "HID";
+ case 1:
+ return "USB";
+ case 2:
+ return String.Format("COM{0}", _stPad.DeviceGetComPort(_index));
+ case 3:
+ return _stPad.DeviceGetIPAddress(_index);
+ default:
+ return "Unkown connection type " + _connectionType;
+ }
+ }
+ }
+
+ public bool USB
+ {
+ get { return (_connectionType == 1); }
+ }
+
+ public string Serial
+ {
+ get { return _serial; }
+ }
+
+ public bool FastConnection
+ {
+ get { return (USB || (PadModel == PadModel.Sigma)); }
+ }
+
+ public string Firmware
+ {
+ get { return String.Format("{0}.{1}", _fwMajor, _fwMinor); }
+ }
+
+ public bool HasDisplay
+ {
+ get
+ {
+ if (_stPad == null)
+ return false;
+ else
+ return _stPad.DeviceGetCapabilities(_index).HasDisplay;
+ }
+ }
+
+ public bool SupportsPenScrolling
+ {
+ get
+ {
+ if (_stPad == null)
+ return false;
+ else
+ return _stPad.DeviceGetCapabilities(_index).SupportsPenScrolling;
+ }
+ }
+ }
+}
diff --git a/ZKuPProject.sln b/ZKuPProject.sln
new file mode 100644
index 0000000..e45e788
--- /dev/null
+++ b/ZKuPProject.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30320.27
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZKuP", "ZKuP\ZKuP.csproj", "{B4348CE1-446F-46A5-BD8A-62C071D4AD10}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|x64.ActiveCfg = Debug|x64
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|x64.Build.0 = Debug|x64
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|x86.ActiveCfg = Debug|x86
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Debug|x86.Build.0 = Debug|x86
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|x64.ActiveCfg = Release|x64
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|x64.Build.0 = Release|x64
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|x86.ActiveCfg = Release|x86
+ {B4348CE1-446F-46A5-BD8A-62C071D4AD10}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FBD172F2-AE5F-46FB-A93D-2296F8CD63E4}
+ EndGlobalSection
+EndGlobal