diff --git a/ZKuP/AddCardUser.xaml b/ZKuP/AddCardUser.xaml index ba7b53e..1c65db6 100644 --- a/ZKuP/AddCardUser.xaml +++ b/ZKuP/AddCardUser.xaml @@ -17,12 +17,8 @@ - - - - - - + + diff --git a/ZKuP/AddCardUser.xaml.cs b/ZKuP/AddCardUser.xaml.cs index 91ae8e7..4eaf782 100644 --- a/ZKuP/AddCardUser.xaml.cs +++ b/ZKuP/AddCardUser.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -19,16 +20,35 @@ namespace ZKuP /// public partial class AddCardUser : Window { - public AddCardUser(string user = "") + string _user = ""; + string _ansprechpartnerFirma = ""; + List comboList = new List() { "Grün", "Rot", "Gerätewagen" }; + List comboListNurRot = new List() { "Rot" }; + + byte[] _signature = null; + string _ap = ""; + bool _needTel = true; + + public AddCardUser(string user = "", bool isBesucher = false, string nr = "", string ap = "", bool needTel = true) { + _user = user; + _ap = ap; + _needTel = needTel; + InitializeComponent(); + this.Title = "Karten ausgeben - " + nr; + + //cbColor.ItemsSource = isBesucher ? comboListNurRot : comboList; + cbColor.ItemsSource = comboListNurRot; + if (!user.Contains("[")) { tbUser.Text = user; try { - tbTelnr.Text = SQL.ReadSingleValue($"SELECT Tel_Nr_Verantwortlicher_Firma FROM zkup.firmen WHERE Name='{user}'"); + if (user != "") + tbTelnr.Text = SQL.ReadSingleValue($"SELECT Tel_Nr_Verantwortlicher_Firma FROM {MainWindow.table}.firmen WHERE Name='{user}'"); } catch (Exception) { @@ -37,7 +57,7 @@ namespace ZKuP else { tbUser.Text = user.Split(',')[1].TrimEnd(']').Trim(); - tbTelnr.Text = SQL.ReadSingleValue($"SELECT TelNr FROM zkup.family WHERE Name='{tbUser.Text}'"); + tbTelnr.Text = SQL.ReadSingleValue($"SELECT TelNr FROM {MainWindow.table}.family WHERE Name='{tbUser.Text}'"); cbColor.SelectedIndex = 0; tbNummer.Focus(); } @@ -50,19 +70,31 @@ namespace ZKuP 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, "Benutzer angeben!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); + else if (_needTel && 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}')"); + var sig = new Signature(Signature.DisclaimerType.Rot, tbUser.Text, tbTelnr.Text); - MessageBox.Show(this, "Karte erfolgreich verknüpft", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information); + if (sig.ShowDialog() == false) + { + _signature = sig.ResultByte; + + if (_signature != null) + { + await SQL.WriteSQL($"REPLACE INTO karten (kartennr,farbe,benutzer,telnr,AusgegebenDurch,AusgegebenTimestamp,Signature,Ansprechpartner) VALUES ('{tbNummer.Text}','{cbColor.SelectedValue.ToString()}','{tbUser.Text}','{tbTelnr.Text}','{Environment.UserName}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', @signature, '{_ap}')", _signature); + + MessageBox.Show(this, "Karte erfolgreich verknüpft", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information); + + ResetValues(); + this.Close(); + } + else MessageBox.Show("Unterschrift nicht gefunden\nVorgang bitte wiederholen"); + } - ResetValues(); - //this.Close(); } catch (MySql.Data.MySqlClient.MySqlException ex) { diff --git a/ZKuP/AddVisitorsList.xaml b/ZKuP/AddVisitorsList.xaml new file mode 100644 index 0000000..e3f4677 --- /dev/null +++ b/ZKuP/AddVisitorsList.xaml @@ -0,0 +1,15 @@ + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + diff --git a/ZKuP/Cards.xaml.cs b/ZKuP/Cards.xaml.cs index 6e0e10b..e667134 100644 --- a/ZKuP/Cards.xaml.cs +++ b/ZKuP/Cards.xaml.cs @@ -1,5 +1,7 @@ -using System; +using ControlzEx.Standard; +using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -33,10 +35,10 @@ namespace ZKuP { InitializeComponent(); - karten = SQL.ReadSQL("Select * from zkup.karten", karten).Result; + karten = SQL.ReadSQL($"Select * from {MainWindow.table}.karten", karten).Result; dgCards.DataContext = karten; - mcFit = SQL.ReadSQL("SELECT * FROM zkup.mcFit", mcFit).Result; + mcFit = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.mcFit", mcFit).Result; dgMcFit.DataContext = mcFit; textInputTimer.Interval = TimeSpan.FromSeconds(0.5); @@ -45,20 +47,7 @@ namespace ZKuP 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 = await SQL.ReadSQL("Select * FROM zkup.karten", karten); - dgCards.DataContext = karten; - } - } + if (e.Key == Key.Delete) await DeleteCard(); } private void btnAdd_Click(object sender, RoutedEventArgs e) @@ -67,7 +56,7 @@ namespace ZKuP addCardUser.Owner = this; addCardUser.ShowDialog(); - karten = SQL.ReadSQL("Select * from zkup.karten", karten).Result; + karten = SQL.ReadSQL($"Select * from {MainWindow.table}.karten", karten).Result; dgCards.DataContext = karten; } @@ -81,18 +70,101 @@ namespace ZKuP else btnDelete.IsEnabled = false; } private async void btnDelete_Click(object sender, RoutedEventArgs e) + { + await DeleteCard(); + } + + private async Task DeleteCard() { 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) + string cardsQuery = ""; + string cardsQueryTimestamp = ""; + string rueckgeber = ""; + + for (int i = 0; i < dg.Items.Count; i++) { + DataRowView item = dg.Items[i] as DataRowView; + var r = dg.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow; + if (r != null) + { + var mycheckbox = dg.Columns[0].GetCellContent(r) as CheckBox; + if ((bool)mycheckbox.IsChecked) + { + cardsQuery += (item as DataRowView).Row.ItemArray[1].ToString() + ";"; + cardsQueryTimestamp += (item as DataRowView).Row.ItemArray[6].ToString() + ";"; - await SQL.WriteSQL($"DELETE FROM zkup.karten WHERE `kartennr` = '{arr[1]}'"); + if (!string.IsNullOrWhiteSpace((item as DataRowView).Row.ItemArray[7].ToString())) + rueckgeber = (item as DataRowView).Row.ItemArray[7].ToString(); + } + } + } - karten = await SQL.ReadSQL("Select * FROM zkup.karten", karten); - dgCards.DataContext = karten; + if (cardsQuery == "") + { + if (MessageBox.Show(this, $"Karte {arr[1]},\nausgegeben an {arr[3]} wurde zurückgegeben?\n\nUnterschrift des Zurückgebers wird abgefragt...", "Karte zurückgegeben?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) + { + var sig = new Signature(Signature.DisclaimerType.Rueck, arr[3].ToString(), arr[1].ToString(), "", true, arr[7].ToString()); + + if (sig.ShowDialog() == false) + { + _signature = sig.ResultByte; + + if (_signature != null) + { + await SQL.WriteSQL($"DELETE FROM {MainWindow.table}.karten WHERE `kartennr` = '{arr[1]}'"); + + karten = await SQL.ReadSQL($"Select * FROM {MainWindow.table}.karten", karten); + dgCards.DataContext = karten; + + await SQL.WriteSQL($"UPDATE {MainWindow.table}.kartenLog SET RueckgabeSignature = @signature, Ansprechpartner = '{arr[7]}' WHERE idkarten = '{arr[0]}' AND Ausgebucht = 1 AND `timestamp` > (now() - INTERVAL 2 MINUTE)", _signature); + + this.Close(); + } + } + } + } + else + { + string cards = ""; + string delCards = ""; + string delCardsLog = ""; + for(var i = 0; i < cardsQuery.Split(';').Length - 1; i++) + { + cards += $"{cardsQuery.Split(';')[i].Trim()} ausgegeben am: {cardsQueryTimestamp.Split(';')[i]}\n"; + delCards += $"`kartennr` = '{cardsQuery.Split(';')[i].Trim()}' OR "; + + delCardsLog += $"(`kartennr` = '{cardsQuery.Split(';')[i].Trim()}' AND Ausgebucht = 1 AND `timestamp` > (now() - INTERVAL 2 MINUTE)) OR "; + } + int lastIndex = delCards.LastIndexOf(" OR "); + if (lastIndex != -1) delCards = delCards.Remove(lastIndex); + + int lastIndexLog = delCardsLog.LastIndexOf(" OR "); + if (lastIndexLog != -1) delCardsLog = delCardsLog.Remove(lastIndexLog); + + if (MessageBox.Show(this, $"Die Karten\n\n{cards}\nwurden zurückgegeben?\n\nUnterschrift des Zurückgebers wird abgefragt...", "Karten zurückgegeben?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) + { + var sig = new Signature(Signature.DisclaimerType.Rueck, arr[3].ToString(), arr[1].ToString(), "", true, rueckgeber); + + if (sig.ShowDialog() == false) + { + _signature = sig.ResultByte; + + if (_signature != null) + { + await SQL.WriteSQL($"DELETE FROM {MainWindow.table}.karten WHERE {delCards}"); + + karten = await SQL.ReadSQL($"Select * FROM {MainWindow.table}.karten", karten); + dgCards.DataContext = karten; + + await SQL.WriteSQL($"UPDATE {MainWindow.table}.kartenLog SET RueckgabeSignature = @signature WHERE {delCardsLog}", _signature); + + this.Close(); + } + } + } } } @@ -117,7 +189,7 @@ namespace ZKuP { textInputTimer.Stop(); - var cBItemSource = await SQL.ReadListStringMultipleColumns($"SELECT idmcFitUsers, Name, Vorname FROM zkup.mcFitUsers WHERE `Name` LIKE '{lastTextBox.Text}%'"); + var cBItemSource = await SQL.ReadListStringMultipleColumns($"SELECT idmcFitUsers, Name, Vorname FROM {MainWindow.table}.mcFitUsers WHERE `Name` LIKE '{lastTextBox.Text}%'"); List temp = new List(); foreach (var line in cBItemSource) @@ -139,7 +211,7 @@ namespace ZKuP { if (cBNameAusgabe != null && cBNameAusgabe.SelectedItem != null) { - var result = await SQL.ReadListStringMultipleColumns($"SELECT Name,Vorname,Abteilung,Handynr,Email FROM zkup.mcFitUsers WHERE idmcFitUsers = '{cBNameAusgabe.SelectedItem.ToString().Split(' ')[0]}'", 5); + var result = await SQL.ReadListStringMultipleColumns($"SELECT Name,Vorname,Abteilung,Handynr,Email FROM {MainWindow.table}.mcFitUsers WHERE idmcFitUsers = '{cBNameAusgabe.SelectedItem.ToString().Split(' ')[0]}'", 5); tbAusNachname.TextChanged -= tbAusNachname_TextChanged; @@ -157,7 +229,7 @@ namespace ZKuP { int Kartennr = Convert.ToInt32(cBZurKarte.SelectedValue.ToString().Split(' ')[2]); - var result = await SQL.ReadListStringMultipleColumns($"SELECT Nachname,Vorname,Abteilung,Handynr,Email FROM zkup.mcFit WHERE Kartennr = '{Kartennr}'", 5); + var result = await SQL.ReadListStringMultipleColumns($"SELECT Nachname,Vorname,Abteilung,Handynr,Email FROM {MainWindow.table}.mcFit WHERE Kartennr = '{Kartennr}'", 5); tbZurNachname.Text = result.First().Split(';')[0]; tbZurVorname.Text = result.First().Split(';')[1]; @@ -190,9 +262,9 @@ namespace ZKuP int Kartennr = Convert.ToInt32(cBAusKarte.SelectedValue.ToString().Split(' ')[2]); - await SQL.WriteSQL($"UPDATE zkup.mcFit SET Vorname = '{tbAusVorname.Text}', Nachname = '{tbAusNachname.Text}', Abteilung = '{tbAusAbteilung.Text}', Handynr = '{tbAusHandy.Text}', Email = '{tbAusEmail.Text}', AusgabeTimestamp = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', ZurueckTimestamp = null, AktuellAusgegeben = '1', Signature = @signature WHERE Kartennr = '{Kartennr}'", _signature); + await SQL.WriteSQL($"UPDATE {MainWindow.table}.mcFit SET Vorname = '{tbAusVorname.Text}', Nachname = '{tbAusNachname.Text}', Abteilung = '{tbAusAbteilung.Text}', Handynr = '{tbAusHandy.Text}', Email = '{tbAusEmail.Text}', AusgabeTimestamp = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', ZurueckTimestamp = null, AktuellAusgegeben = '1', Signature = @signature, AusgegebenDruch = '{Environment.UserName}' WHERE Kartennr = '{Kartennr}'", _signature); - mcFit = SQL.ReadSQL("SELECT * FROM zkup.mcFit", mcFit).Result; + mcFit = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.mcFit", mcFit).Result; dgMcFit.DataContext = mcFit; } } @@ -212,9 +284,9 @@ namespace ZKuP { int Kartennr = Convert.ToInt32(cBZurKarte.SelectedValue.ToString().Split(' ')[2]); - await SQL.WriteSQL($"UPDATE zkup.mcFit SET ZurueckTimestamp = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', AktuellAusgegeben = '0' WHERE Kartennr = '{Kartennr}'"); + await SQL.WriteSQL($"UPDATE {MainWindow.table}.mcFit SET ZurueckTimestamp = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', AktuellAusgegeben = '0' WHERE Kartennr = '{Kartennr}'"); - mcFit = SQL.ReadSQL("SELECT * FROM zkup.mcFit", mcFit).Result; + mcFit = SQL.ReadSQL($"SELECT * FROM {MainWindow.table}.mcFit", mcFit).Result; dgMcFit.DataContext = mcFit; } @@ -222,7 +294,7 @@ namespace ZKuP { var signBtn = ((sender as Button).DataContext) as System.Data.DataRowView; - var i = SQL.ReadSingleByteArr($"SELECT Signature FROM zkup.mcFit WHERE Kartennr = '{(signBtn).Row.ItemArray[0].ToString()}'"); + var i = SQL.ReadSingleByteArr($"SELECT Signature FROM {MainWindow.table}.mcFit WHERE Kartennr = '{(signBtn).Row.ItemArray[0].ToString()}'"); BitmapImage image = null; if (i != null) @@ -234,5 +306,15 @@ namespace ZKuP iv.Owner = this; iv.ShowDialog(); } + + private void GruenRot_Click(object sender, RoutedEventArgs e) + { + tabcontrol.SelectedIndex = 0; + } + + private void McFit_Click(object sender, RoutedEventArgs e) + { + tabcontrol.SelectedIndex = 1; + } } } diff --git a/ZKuP/CheckKennzeichen.xaml.cs b/ZKuP/CheckKennzeichen.xaml.cs index d735b1c..1dd000a 100644 --- a/ZKuP/CheckKennzeichen.xaml.cs +++ b/ZKuP/CheckKennzeichen.xaml.cs @@ -40,7 +40,7 @@ namespace ZKuP { if (!string.IsNullOrWhiteSpace(tbKennzeichen.Text)) { - var list = SQL.ReadSQL($"SELECT Kennzeichen, Name, Ansprechpartner, DATE_FORMAT(Zutritt, \"%d.%m.%y %I:%i\") AS \"Zutritt\" FROM zkup.zutritte WHERE Kennzeichen LIKE '%{tbKennzeichen.Text}%'").Result; + var list = SQL.ReadSQL($"SELECT Kennzeichen, Name, Ansprechpartner, DATE_FORMAT(Zutritt, \"%d.%m.%y %I:%i\") AS \"Zutritt\" FROM {MainWindow.table}.zutritte WHERE Kennzeichen LIKE '%{tbKennzeichen.Text}%'").Result; if (list.Rows.Count == 0) list.Rows.Add("Keine Ergebnisse..."); diff --git a/ZKuP/CheckParkausweis.xaml.cs b/ZKuP/CheckParkausweis.xaml.cs index 771408b..497b7a7 100644 --- a/ZKuP/CheckParkausweis.xaml.cs +++ b/ZKuP/CheckParkausweis.xaml.cs @@ -23,14 +23,14 @@ namespace ZKuP { InitializeComponent(); - var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM zkup.parkausweise WHERE Genehmigt = '1'").Result; + var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM {MainWindow.table}.parkausweise WHERE Genehmigt = '1'").Result; dgCheck.DataContext = list; } private void btnSearch_Click(object sender, RoutedEventArgs e) { - var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM zkup.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result; + var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM {MainWindow.table}.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result; dgCheck.DataContext = list; } @@ -49,7 +49,7 @@ namespace ZKuP { if(e.Key == Key.Enter) { - var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM zkup.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result; + var list = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM {MainWindow.table}.parkausweise WHERE Genehmigt = '1' AND Kennzeichen LIKE '%{tbSearch.Text}%'").Result; dgCheck.DataContext = list; } } @@ -60,7 +60,7 @@ namespace ZKuP await Task.Run(() => { - var res = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM zkup.parkausweise WHERE Gedruckt = '1'").Result; + var res = SQL.ReadSQL($"SELECT Kennzeichen, MA_Vorname AS Vorname, MA_Name AS Nachname, Telefon, Abteilung, Vorgesetzter FROM {MainWindow.table}.parkausweise WHERE Gedruckt = '1'").Result; var ex = new ExcelExporter(); ex.Export(res); }); diff --git a/ZKuP/CreateFirma.xaml b/ZKuP/CreateFirma.xaml index 9bb6ac3..e1543b9 100644 --- a/ZKuP/CreateFirma.xaml +++ b/ZKuP/CreateFirma.xaml @@ -7,7 +7,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" x:Class="ZKuP.CreateFirma" mc:Ignorable="d" Title="Firmen verwalten" Height="682" Width="1378" - WindowStartupLocation="CenterOwner"> + WindowStartupLocation="CenterOwner" Closing="Window_Closing"> @@ -191,7 +191,7 @@ - + @@ -205,8 +205,8 @@ - - + + + + Setter setter = new Setter(); + setter.Property = Calendar.TemplateProperty; + ControlTemplate template = new ControlTemplate(typeof(Calendar)); + var stackPanel = new FrameworkElementFactory(typeof(StackPanel)); + stackPanel.Name = "PART_Root"; + stackPanel.SetValue(StackPanel.HorizontalAlignmentProperty, HorizontalAlignment.Center); + + var calendar = new FrameworkElementFactory(typeof(CalendarItem)); + calendar.Name = "PART_CalendarItem"; + + calendar.SetBinding(CalendarItem.BackgroundProperty, + new Binding(CalendarItem.BackgroundProperty.Name) + { + Path = new PropertyPath(Control.BackgroundProperty), + RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) + }); + + calendar.SetBinding(CalendarItem.BorderBrushProperty, new Binding(CalendarItem.BorderBrushProperty.Name) + { + Path = new PropertyPath(Control.BorderBrushProperty), + RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) + }); + + calendar.SetBinding(CalendarItem.BorderThicknessProperty, new Binding(CalendarItem.BorderThicknessProperty.Name) + { + Path = new PropertyPath(Control.BorderThicknessProperty), + RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) + }); + + calendar.SetBinding(CalendarItem.StyleProperty, new Binding(CalendarItem.StyleProperty.Name) + { + Path = new PropertyPath(Calendar.CalendarItemStyleProperty), + RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent) + }); + + stackPanel.AppendChild(calendar); + + var btn = new FrameworkElementFactory(typeof(Button)); + btn.SetValue(Button.ContentProperty, GetShowTodayButtonContent(d)); + + var SelectToday = new RoutedCommand("Today", typeof(DatePickerHelper)); + + d.CommandBindings.Add(new CommandBinding(SelectToday, + (s, ea) => + { + (s as DatePicker).SelectedDate = DateTime.Now.Date; + (s as DatePicker).IsDropDownOpen = false; + }, + (s, ea) => { ea.CanExecute = true; })); + + btn.SetValue(Button.CommandProperty, SelectToday); + + stackPanel.AppendChild(btn); + + template.VisualTree = stackPanel; + setter.Value = template; + + Style Temp = new Style(typeof(Calendar)); + + Temp.Setters.Add(setter); + + d.CalendarStyle = Temp; + } + } + } + + [AttachedPropertyBrowsableForType(typeof(DatePicker))] + public static bool GetShowTodayButton(DependencyObject obj) + { + return (bool)obj.GetValue(ShowTodayButtonProperty); + } + + [AttachedPropertyBrowsableForType(typeof(DatePicker))] + public static void SetShowTodayButton(DependencyObject obj, bool value) + { + obj.SetValue(ShowTodayButtonProperty, value); + } + + [AttachedPropertyBrowsableForType(typeof(DatePicker))] + public static string GetShowTodayButtonContent(Control obj) + { + return (string)obj.GetValue(ShowTodayButtonContentProperty); + } + + [AttachedPropertyBrowsableForType(typeof(DatePicker))] + public static void SetShowTodayButtonContent(Control obj, string value) + { + obj.SetValue(ShowTodayButtonContentProperty, value); + } + } } diff --git a/ZKuP/ImageView.xaml b/ZKuP/ImageView.xaml index aa29814..8185861 100644 --- a/ZKuP/ImageView.xaml +++ b/ZKuP/ImageView.xaml @@ -5,20 +5,28 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ZKuP" mc:Ignorable="d" - Title="Unterschriftenanzeige" Height="342" Width="419"> + Title="Unterschriftenanzeige" Height="370" Width="419" Loaded="Window_Loaded"> + + + + + + + - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/ZKuP/PrintParkausweis.xaml.cs b/ZKuP/PrintParkausweis.xaml.cs index 05d5acd..8d7a0e1 100644 --- a/ZKuP/PrintParkausweis.xaml.cs +++ b/ZKuP/PrintParkausweis.xaml.cs @@ -33,7 +33,7 @@ namespace ZKuP 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 (Helper.OpenAndEditWord($"{arr[1].ToString()} {arr[2].ToString()}", arr[3].ToString(), arr[7].ToString(), arr[0].ToString(), Convert.ToInt16(arr[19]), arr[6].ToString())) { if (MessageBox.Show(this, "Wurde der Parkausweis erfolgreich gedruckt?", "Erfolgreich gedruckt?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { diff --git a/ZKuP/Resources/AusweisGruen.png b/ZKuP/Resources/AusweisGruen.png new file mode 100644 index 0000000..b104cfa Binary files /dev/null and b/ZKuP/Resources/AusweisGruen.png differ diff --git a/ZKuP/Resources/AusweisGruen_small.png b/ZKuP/Resources/AusweisGruen_small.png new file mode 100644 index 0000000..1f460d4 Binary files /dev/null and b/ZKuP/Resources/AusweisGruen_small.png differ diff --git a/ZKuP/Resources/AusweisRot.png b/ZKuP/Resources/AusweisRot.png new file mode 100644 index 0000000..d55f26d Binary files /dev/null and b/ZKuP/Resources/AusweisRot.png differ diff --git a/ZKuP/Resources/AusweisRot_small.png b/ZKuP/Resources/AusweisRot_small.png new file mode 100644 index 0000000..af2cccc Binary files /dev/null and b/ZKuP/Resources/AusweisRot_small.png differ diff --git a/ZKuP/Resources/Bike.png b/ZKuP/Resources/Bike.png new file mode 100644 index 0000000..1859de6 Binary files /dev/null and b/ZKuP/Resources/Bike.png differ diff --git a/ZKuP/Resources/Bike_dark.png b/ZKuP/Resources/Bike_dark.png new file mode 100644 index 0000000..e4bb2c7 Binary files /dev/null and b/ZKuP/Resources/Bike_dark.png differ diff --git a/ZKuP/Resources/ConnBackground.png b/ZKuP/Resources/ConnBackground.png new file mode 100644 index 0000000..f5fb7e8 Binary files /dev/null and b/ZKuP/Resources/ConnBackground.png differ diff --git a/ZKuP/Resources/Connected.png b/ZKuP/Resources/Connected.png new file mode 100644 index 0000000..866ae7e Binary files /dev/null and b/ZKuP/Resources/Connected.png differ diff --git a/ZKuP/Resources/Disconnected.png b/ZKuP/Resources/Disconnected.png new file mode 100644 index 0000000..1c36f7e Binary files /dev/null and b/ZKuP/Resources/Disconnected.png differ diff --git a/ZKuP/Resources/Edit.png b/ZKuP/Resources/Edit.png new file mode 100644 index 0000000..91d078f Binary files /dev/null and b/ZKuP/Resources/Edit.png differ diff --git a/ZKuP/Resources/In.png b/ZKuP/Resources/In.png new file mode 100644 index 0000000..5ae3527 Binary files /dev/null and b/ZKuP/Resources/In.png differ diff --git a/ZKuP/Resources/KarteAusgeben_small.png b/ZKuP/Resources/KarteAusgeben_small.png new file mode 100644 index 0000000..eca1147 Binary files /dev/null and b/ZKuP/Resources/KarteAusgeben_small.png differ diff --git a/ZKuP/Resources/KarteZuruecknehmen_small.png b/ZKuP/Resources/KarteZuruecknehmen_small.png new file mode 100644 index 0000000..4233274 Binary files /dev/null and b/ZKuP/Resources/KarteZuruecknehmen_small.png differ diff --git a/ZKuP/Resources/Karten.png b/ZKuP/Resources/Karten.png new file mode 100644 index 0000000..c9e8fff Binary files /dev/null and b/ZKuP/Resources/Karten.png differ diff --git a/ZKuP/Resources/KartenTausch.png b/ZKuP/Resources/KartenTausch.png new file mode 100644 index 0000000..c71fd9a Binary files /dev/null and b/ZKuP/Resources/KartenTausch.png differ diff --git a/ZKuP/Resources/LKW.png b/ZKuP/Resources/LKW.png new file mode 100644 index 0000000..25c1594 Binary files /dev/null and b/ZKuP/Resources/LKW.png differ diff --git a/ZKuP/Resources/LKWLang.png b/ZKuP/Resources/LKWLang.png new file mode 100644 index 0000000..86d2733 Binary files /dev/null and b/ZKuP/Resources/LKWLang.png differ diff --git a/ZKuP/Resources/LKWLang_button.png b/ZKuP/Resources/LKWLang_button.png new file mode 100644 index 0000000..be930ef Binary files /dev/null and b/ZKuP/Resources/LKWLang_button.png differ diff --git a/ZKuP/Resources/LKWLang_dark.png b/ZKuP/Resources/LKWLang_dark.png new file mode 100644 index 0000000..df4b726 Binary files /dev/null and b/ZKuP/Resources/LKWLang_dark.png differ diff --git a/ZKuP/Resources/LKW_button.png b/ZKuP/Resources/LKW_button.png new file mode 100644 index 0000000..ec77823 Binary files /dev/null and b/ZKuP/Resources/LKW_button.png differ diff --git a/ZKuP/Resources/LKW_dark.png b/ZKuP/Resources/LKW_dark.png new file mode 100644 index 0000000..ef86da3 Binary files /dev/null and b/ZKuP/Resources/LKW_dark.png differ diff --git a/ZKuP/Resources/Out.png b/ZKuP/Resources/Out.png new file mode 100644 index 0000000..dcb6287 Binary files /dev/null and b/ZKuP/Resources/Out.png differ diff --git a/ZKuP/Resources/PKW.png b/ZKuP/Resources/PKW.png new file mode 100644 index 0000000..40a554a Binary files /dev/null and b/ZKuP/Resources/PKW.png differ diff --git a/ZKuP/Resources/PKW_button.png b/ZKuP/Resources/PKW_button.png new file mode 100644 index 0000000..00c187f Binary files /dev/null and b/ZKuP/Resources/PKW_button.png differ diff --git a/ZKuP/Resources/PKW_dark.png b/ZKuP/Resources/PKW_dark.png new file mode 100644 index 0000000..c2641cf Binary files /dev/null and b/ZKuP/Resources/PKW_dark.png differ diff --git a/ZKuP/Resources/PadDanke.png b/ZKuP/Resources/PadDanke.png new file mode 100644 index 0000000..ea4db10 Binary files /dev/null and b/ZKuP/Resources/PadDanke.png differ diff --git a/ZKuP/Resources/Sprinter.png b/ZKuP/Resources/Sprinter.png new file mode 100644 index 0000000..74bfd4b Binary files /dev/null and b/ZKuP/Resources/Sprinter.png differ diff --git a/ZKuP/Resources/Sprinter_button.png b/ZKuP/Resources/Sprinter_button.png new file mode 100644 index 0000000..baa32b2 Binary files /dev/null and b/ZKuP/Resources/Sprinter_button.png differ diff --git a/ZKuP/Resources/Sprinter_dark.png b/ZKuP/Resources/Sprinter_dark.png new file mode 100644 index 0000000..6eca6e7 Binary files /dev/null and b/ZKuP/Resources/Sprinter_dark.png differ diff --git a/ZKuP/SQL.cs b/ZKuP/SQL.cs index 01a099b..9fbb139 100644 --- a/ZKuP/SQL.cs +++ b/ZKuP/SQL.cs @@ -6,6 +6,7 @@ using System.Data.SqlClient; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -17,9 +18,35 @@ namespace ZKuP private static string s = "KYgjkRVn0edFDca2GbZq/A=="; private static string u = "F/u2njMf6aE4krZGTjzgZw=="; private static string d = "xWb4X9gPEzwe76zqpysF3w=="; + private static string dTest = "e+tv3ZaP+cewOJgE7jNNlA=="; static MySqlConnection conn = new MySqlConnection(GetConnstr()); static MySqlDataAdapter adp = new MySqlDataAdapter(); + public static bool CheckOnline() + { + 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(GetIP()); + 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 + { + return false; + } + return false; + } + } public static bool CheckDeviceConnection() { @@ -57,10 +84,17 @@ namespace ZKuP internal static string GetConnstr() { +#if !DEBUG return $"Server={GetIP()};" + $"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" + $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" + $"database={Crypto.Decrypt(Crypto.GetHashKey("8EB0CC56E502BFC5C19F6A0A0A53D543"), d)}"; +#elif DEBUG + return $"Server={GetIP()};" + + $"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" + + $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" + + $"database={Crypto.Decrypt(Crypto.GetHashKey("B79DE37BC846D9B1054EE837AAA45D83"), dTest)}"; +#endif } public static MySqlDataAdapter GetAdapter() { @@ -591,9 +625,14 @@ namespace ZKuP } - public static async Task RowExists(string Table, string Column, string Value) + public static async Task RowExists(string Table, string Column, string Value, bool isLike = false) { - MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand($"SELECT EXISTS(SELECT * FROM {Table} WHERE {Column} = '{Value}')", conn); + MySqlCommand cmd; + + if (!isLike) + cmd = new MySql.Data.MySqlClient.MySqlCommand($"SELECT EXISTS(SELECT * FROM {Table} WHERE {Column} = '{Value}')", conn); + else + cmd = new MySql.Data.MySqlClient.MySqlCommand($"SELECT EXISTS(SELECT * FROM {Table} WHERE {Column} LIKE '%{Value}%')", conn); object queryResult; var res = 0; diff --git a/ZKuP/SetHinweis.xaml.cs b/ZKuP/SetHinweis.xaml.cs index bbcdb76..622b748 100644 --- a/ZKuP/SetHinweis.xaml.cs +++ b/ZKuP/SetHinweis.xaml.cs @@ -25,19 +25,19 @@ namespace ZKuP { InitializeComponent(); - Text = SQL.ReadSingleValue("SELECT Hinweis FROM zkup.misc"); + Text = SQL.ReadSingleValue($"SELECT Hinweis FROM {MainWindow.table}.misc"); lblHinweis.Text = Text; } private async void btnSetHinweis_Click(object sender, RoutedEventArgs e) { - await SQL.WriteSQL($"REPLACE INTO zkup.misc VALUES (1,'{lblHinweis.Text}','{Environment.UserName}')"); + await SQL.WriteSQL($"REPLACE INTO {MainWindow.table}.misc VALUES (1,'{lblHinweis.Text}','{Environment.UserName}')"); this.Close(); } private async void btnDeleteHinweis_Click(object sender, RoutedEventArgs e) { - await SQL.WriteSQL($"REPLACE INTO zkup.misc VALUES (1,'','{Environment.UserName}')"); + await SQL.WriteSQL($"REPLACE INTO {MainWindow.table}.misc VALUES (1,'','{Environment.UserName}')"); this.Close(); } diff --git a/ZKuP/Signature.xaml b/ZKuP/Signature.xaml index 279e1d7..ccdba15 100644 --- a/ZKuP/Signature.xaml +++ b/ZKuP/Signature.xaml @@ -49,6 +49,9 @@ + + + diff --git a/ZKuP/Signature.xaml.cs b/ZKuP/Signature.xaml.cs index 7d1fbbe..a1c4915 100644 --- a/ZKuP/Signature.xaml.cs +++ b/ZKuP/Signature.xaml.cs @@ -1,6 +1,7 @@ using signotec.STPadLibNet; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -25,7 +26,7 @@ namespace ZKuP //private STPadLibControl _stPad = new STPadLibControl(); System.Windows.Threading.DispatcherTimer confirmedTimer = new System.Windows.Threading.DispatcherTimer(); - public Signature(DisclaimerType type, string Name = "", string Firma_Abteilung = "", string Kennzeichen_Handynr = "", bool showDisclaimer = true) + public Signature(DisclaimerType type, string Name = "", string Firma_Abteilung = "", string Kennzeichen_Handynr = "", bool showDisclaimer = true, string ansprechpartner = "") { InitializeComponent(); @@ -55,6 +56,15 @@ namespace ZKuP case DisclaimerType.McFit: signoPad.ShowDisclaimerMcFit(Name, Firma_Abteilung, Kennzeichen_Handynr, showDisclaimer); break; + case DisclaimerType.Gruen: + signoPad.ShowDisclaimerGruen(Name, Kennzeichen_Handynr, showDisclaimer); + break; + case DisclaimerType.Rot: + signoPad.ShowDisclaimerRot(Name, Kennzeichen_Handynr, showDisclaimer); + break; + case DisclaimerType.Rueck: + signoPad.ShowDisclaimerRueck(ansprechpartner, showDisclaimer); + break; default: signoPad.ShowDisclaimerParken(Name, Firma_Abteilung, Kennzeichen_Handynr, showDisclaimer); break; @@ -73,44 +83,46 @@ namespace ZKuP { if (signoPad.SignatureConfirmed) { + STPadLibControlHost.Visibility = Visibility.Collapsed; btnConfirm.IsEnabled = true; confirmedTimer.Stop(); + + if (signoPad.Result != null) + imgSignature.Source = Helper.ConvertBitmapToImage(signoPad.Result); + else + { + MessageBox.Show("Fehler beim Erfassen der Unterschrift\nBitte erneut versuchen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); + Log.WriteLog("Fehler bei Erfassen der Unterschrift"); + signoPad._stPad.SignatureRetry(); + } } } private void btnConfirm_Click(object sender, RoutedEventArgs e) - { + { System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Tiff; - SignatureImageFlag options = signotec.STPadLibNet.SignatureImageFlag.Timestamp | signotec.STPadLibNet.SignatureImageFlag.TimestampRelToImage | signotec.STPadLibNet.SignatureImageFlag.DontSmooth;; - + SignatureImageFlag options = signotec.STPadLibNet.SignatureImageFlag.Timestamp | signotec.STPadLibNet.SignatureImageFlag.TimestampRelToImage | signotec.STPadLibNet.SignatureImageFlag.DontSmooth; ; + int resolution = 300; int width = 0; int height = 0; int penWidth = 0; - System.Drawing.Color penColor = System.Drawing.Color.FromArgb(255,0,0,0); + System.Drawing.Color penColor = System.Drawing.Color.FromArgb(255, 0, 0, 0); try { - string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\temp.tif"; - // save as file - //Result = signoPad._stPad.SignatureSaveAsStreamEx(resolution, width, height, penWidth, penColor, options); - //if (signoPad._stPad.SignatureState == true) - //{ - signoPad._stPad.SignatureSaveAsFileEx(path, resolution, width, height, System.Drawing.Imaging.ImageFormat.Tiff, 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); + //ResultByte = DBImageManager.ImageFromFileToByte(signoPad.signaturePath); + ResultByte = Helper.ConvertImageToByteArray(signoPad.Result); + MessageBox.Show(this, "Unterschrift erfolgreich gespeichert", "Gespeichert", MessageBoxButton.OK, MessageBoxImage.Information); + + //signoPad.CloseConnection(); + this.Close(); - //signoPad.CloseConnection(); - this.Close(); - //} - //else - //{ - // MessageBox.Show($"Unterschriftenerfassung wurde noch nicht gestartet\nErfassung über Pad starten oder mit \"Abbrechen\" das Fenster schließen"); - //} } catch (STPadException exc) { @@ -119,7 +131,7 @@ namespace ZKuP //signoPad.CloseConnection(); this.Close(); } - + } private async void GetSignatureImage() @@ -150,7 +162,10 @@ namespace ZKuP public enum DisclaimerType { Parken, - McFit + McFit, + Gruen, + Rot, + Rueck } } } diff --git a/ZKuP/XMessageBox.xaml.cs b/ZKuP/XMessageBox.xaml.cs index 1ee99ad..6369f11 100644 --- a/ZKuP/XMessageBox.xaml.cs +++ b/ZKuP/XMessageBox.xaml.cs @@ -22,13 +22,16 @@ namespace ZKuP System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); int timerCount = 0; - public XMessageBox(string Title, string Message, MessageBoxImage image) + public XMessageBox(string Title, string Message, MessageBoxImage image, bool withTimer = true) { InitializeComponent(); - timer.Interval = TimeSpan.FromSeconds(1); - timer.Tick += Timer_Tick; - timer.Start(); + if (withTimer) + { + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += Timer_Tick; + timer.Start(); + } this.Title = Title; this.Message.Text = Message; diff --git a/ZKuP/XMessageBoxWithReturn.xaml b/ZKuP/XMessageBoxWithReturn.xaml new file mode 100644 index 0000000..d80eed1 --- /dev/null +++ b/ZKuP/XMessageBoxWithReturn.xaml @@ -0,0 +1,18 @@ + + +