1276 lines
47 KiB
C#
1276 lines
47 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Threading;
|
|
|
|
|
|
#pragma warning disable CS4014 // Da dieser Aufruf nicht abgewartet wird, wird die Ausführung der aktuellen Methode fortgesetzt, bevor der Aufruf abgeschlossen ist
|
|
#pragma warning disable CC0001 // Use var instead
|
|
|
|
namespace PEP_Tool
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
|
{
|
|
public static MainWindow main;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
FileSystemWatcher fs = new FileSystemWatcher(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\", "*.json");
|
|
|
|
|
|
DispatcherTimer bemerkungTimer = new DispatcherTimer();
|
|
DispatcherTimer telefonTimer = new DispatcherTimer();
|
|
DispatcherTimer newVersionTimer = new DispatcherTimer();
|
|
DispatcherTimer lastChangeTimer = new DispatcherTimer();
|
|
|
|
#region Properties
|
|
|
|
public List<string> ZuweisungsMoeglichkeiten { get; set; }
|
|
public Dictionary<string, Tuple<string, string>> AbteilungsNamen { get; set; }
|
|
|
|
|
|
private string lastChangeTime;
|
|
public string LastChangeTime
|
|
{
|
|
get
|
|
{
|
|
return lastChangeTime;
|
|
}
|
|
set
|
|
{
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
lastChangeTime = value;
|
|
lblLastChange.Text = lastChangeTime;
|
|
lblLastChange.Foreground = new SolidColorBrush(Colors.Red);
|
|
}));
|
|
}
|
|
}
|
|
|
|
public DataTable sqlList = new DataTable("UserList");
|
|
|
|
#endregion
|
|
|
|
public MainWindow()
|
|
{
|
|
if (Properties.Settings.Default.newVersionString != Properties.Settings.Default.Version)
|
|
{
|
|
Properties.Settings.Default.newVersionScreen = true;
|
|
Properties.Settings.Default.newVersionString = Properties.Settings.Default.Version;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
|
|
if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Version.txt"))
|
|
{
|
|
main = this;
|
|
PreStart(1);
|
|
}
|
|
#if !DEBUG
|
|
else if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))
|
|
{
|
|
main = this;
|
|
PreStart(2);
|
|
}
|
|
#endif
|
|
//else if (Environment.CurrentDirectory == @"\\bku\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung")
|
|
//{
|
|
// MessageBox.Show($"Achtung:{Environment.NewLine}Dieses Programm darf nicht mehr aus dem Gruppenlaufwerk gestartet werden!{Environment.NewLine}Bitte die PEP-Tool.exe auf den Desktop kopieren und von dort starten", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
// Application.Current.Shutdown();
|
|
//}
|
|
else
|
|
{
|
|
if (Properties.Settings.Default.newVersionScreen)
|
|
{
|
|
InitializeComponent();
|
|
|
|
NewVersionScreen nVs = new NewVersionScreen();
|
|
nVs.ShowDialog();
|
|
|
|
GetDesktopShortcuts();
|
|
|
|
main = this;
|
|
|
|
Start();
|
|
}
|
|
else
|
|
{
|
|
InitializeComponent();
|
|
|
|
GetDesktopShortcuts();
|
|
|
|
main = this;
|
|
|
|
Start();
|
|
}
|
|
}
|
|
|
|
|
|
this.Title += Properties.Settings.Default.Version;
|
|
}
|
|
|
|
public static bool MessageShown { get; set; } = false;
|
|
public static bool propertyChangeAllowed { get; set; } = true;
|
|
//public static bool PersonalNummerIsEnabled { get; set; } = true;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="VersionOrMaintenance">1: Neue Version, 2: Wartungsarbeiten</param>
|
|
private async void PreStart(int VersionOrMaintenance)
|
|
{
|
|
|
|
onStartup = true;
|
|
if (VersionOrMaintenance == 1)
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
NewVersionMessageBox nVMB = new NewVersionMessageBox("Es ist eine neue Version verfügbar\nDie Anwendung kann bis zur Aktualisierung nicht gestartet werden.\n\nDie neue Version sollte in wenigen Minuten verfügbar sein.", 10, true);
|
|
nVMB.Show();
|
|
}));
|
|
});
|
|
|
|
Task.Run(() =>
|
|
{
|
|
while (!MessageShown) { }
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
main.Close();
|
|
}));
|
|
});
|
|
}
|
|
else if (VersionOrMaintenance == 2)
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
NewVersionMessageBox nVMB = new NewVersionMessageBox("Die Anwendung kann wegen Wartungsarbeiten nicht gestartet werden.\n\nDas System sollte in wenigen Minuten wieder verfügbar sein.", 10, true);
|
|
nVMB.Show();
|
|
}));
|
|
});
|
|
|
|
Task.Run(() =>
|
|
{
|
|
while (!MessageShown) { }
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
main.Close();
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
|
|
private async void Start()
|
|
{
|
|
bemerkungTimer.Interval = TimeSpan.FromSeconds(10);
|
|
bemerkungTimer.Tick += (sender, e) => { BemerkungTimer_Tick(sender, e); };
|
|
|
|
telefonTimer.Interval = TimeSpan.FromSeconds(10);
|
|
telefonTimer.Tick += TelefonTimer_Tick;
|
|
|
|
newVersionTimer.Interval = TimeSpan.FromSeconds(10);
|
|
newVersionTimer.Tick += NewVersionTimer_Tick;
|
|
|
|
li.Visibility = Visibility.Visible;
|
|
|
|
await Task.Run(() =>
|
|
{
|
|
ZuweisungsMoeglichkeiten = Reader.ReadZuweisungsMoeglichkeiten();
|
|
AbteilungsNamen = Reader.ReadAbteilungsNamen();
|
|
});
|
|
|
|
await Task.Run(() =>
|
|
{
|
|
sqlList = SQL.ReadAllData(sqlList).Result;
|
|
});
|
|
|
|
var abtFilterList = AbteilungsNamen.Select(p => p.Value.Item2).Distinct().ToList();
|
|
//abtFilterList.Insert(0, "");
|
|
abtFilterList.Sort();
|
|
cBFilterAbteilung.ItemsSource = cBFilterAbteilung2.ItemsSource = cBFilterAbteilung3.ItemsSource = abtFilterList;
|
|
|
|
flowDocu.DataContext = sqlList;
|
|
|
|
btnFrueh.IsEnabled = true;
|
|
btnSpaet.IsEnabled = true;
|
|
btnNacht.IsEnabled = true;
|
|
//btnZugZuweisungen.IsEnabled = true;
|
|
|
|
li.Visibility = Visibility.Collapsed;
|
|
|
|
newVersionTimer.Start();
|
|
|
|
FileWatcher();
|
|
|
|
for (var i = 0; i <= 7; i++)
|
|
flowDocu.Columns[i].Width = flowDocu.Columns[i].ActualWidth + 40;
|
|
|
|
SQL.WriteSQL($"REPLACE INTO track SET `Client` = '{Environment.MachineName}', `User` = '{Environment.UserName}', `Online` = true, `Version` = '{Properties.Settings.Default.Version}'");
|
|
}
|
|
|
|
bool versionMessage = false;
|
|
private void NewVersionTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Version.txt"))
|
|
{
|
|
if (!versionMessage)
|
|
{
|
|
//Task.Run(() => MessageBox.Show("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.", "Neue Version", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification));
|
|
NewVersionMessageBox nVMB = new NewVersionMessageBox("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.\n\n" +
|
|
"Die neue Version sollte in wenigen Minuten verfügbar sein.\n\n" +
|
|
"Sie können während der nächsten 60 Sekunden weitere Eintragungen vornehmen, die Liste drucken oder exportieren.\n\n\n", 60, false);
|
|
nVMB.ShowDialog();
|
|
versionMessage = true;
|
|
}
|
|
}
|
|
|
|
if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))//@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))
|
|
{
|
|
if (!versionMessage)
|
|
{
|
|
flowDocu.IsEnabled = false;
|
|
DisableFilterChange();
|
|
li.Visibility = Visibility.Visible;
|
|
//Task.Run(() => MessageBox.Show("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.", "Neue Version", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification));
|
|
MessageBox.Show(this, "Die Anwendung kann aufgrund von Wartungsarbeiten aktuell nicht genutzt werden\nDie Anwendung wird anschließend automatisch freigeschaltet.\n\n", "Info", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
|
|
|
|
versionMessage = true;
|
|
}
|
|
}
|
|
|
|
if (versionMessage && !File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))
|
|
{
|
|
sqlList = SQL.ReadAllData(sqlList.DefaultView.RowFilter).Result;
|
|
flowDocu.DataContext = sqlList;
|
|
|
|
flowDocu.IsEnabled = true;
|
|
EnableFilterChange();
|
|
li.Visibility = Visibility.Collapsed;
|
|
MessageBox.Show(this, "Die Anwendung steht Ihnen jetzt wieder zur Verfügung!\n\n", "Info", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
|
|
versionMessage = false;
|
|
}
|
|
}
|
|
|
|
|
|
private void FileWatcher()
|
|
{
|
|
FileSystemWatcher fs = new FileSystemWatcher(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\", "sql.lck");
|
|
fs.EnableRaisingEvents = true;
|
|
fs.IncludeSubdirectories = false;
|
|
|
|
fs.Changed += Fs_Changed;
|
|
|
|
li.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
|
|
int fsChangeError = 0;
|
|
bool checkOldJsonData = true;
|
|
string eName = "";
|
|
private async void Fs_Changed(object sender, FileSystemEventArgs e)
|
|
{
|
|
var x = File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\sql.lck").ToString("HH:mm:ss dd.MM.yy");
|
|
LastChangeTime = x;
|
|
|
|
//await Task.Delay(20);
|
|
Dispatcher.BeginInvoke(new Action(() =>
|
|
{
|
|
sqlList = SQL.ReadAllData(sqlList.DefaultView.RowFilter).Result;
|
|
flowDocu.DataContext = sqlList;
|
|
}));
|
|
}
|
|
|
|
|
|
private async void Zuweisung_DropDownClosed(object sender, EventArgs e)
|
|
{
|
|
li.Visibility = Visibility.Visible;
|
|
flowDocu.IsEnabled = false;
|
|
|
|
try
|
|
{
|
|
var box = sender as ComboBox;
|
|
DataGridRow dataGridRow = FindParent<DataGridRow>(box);
|
|
int index = dataGridRow.GetIndex();
|
|
|
|
TextBlock persnummer = null;
|
|
var datum = flowDocu.Columns[2].GetCellContent(flowDocu.Items[index]) as TextBlock;
|
|
persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
|
|
var zuw = box.SelectedItem.ToString();
|
|
|
|
await SQL.WriteSQL($"UPDATE `mitarbeiter_static` `p` left join `mitarbeiter_change` `o` ON o.mitarbeiter_static_PersNr = p.PersNr SET Zuweisung = '{zuw}' WHERE p.PersNr = '{persnummer.Text}' AND o.Datum = '{Convert.ToDateTime(datum.Text).ToString("yyyy-MM-dd")}'", sqlList);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
li.Visibility = Visibility.Hidden;
|
|
flowDocu.IsEnabled = true;
|
|
|
|
|
|
fs.Changed += Fs_Changed;
|
|
}
|
|
|
|
private void Zuweisung_DropDownOpened(object sender, EventArgs e)
|
|
{
|
|
fs.Changed -= Fs_Changed;
|
|
}
|
|
|
|
#region Bemerkung
|
|
|
|
|
|
private void Bemerkung_PreviewKeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var box = sender as TextBox;
|
|
|
|
if (!Helper.keyIsSpecialKey(e.Key))
|
|
{
|
|
if (box.Text.ToLower().Contains("krank")) MessageBox.Show("Bitte nicht \"Krank\" eintragen (Datenschutz)\nWenn möglich stattdessen Zuweisung auf \"nicht Anwesend\" stellen", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
e.Handled = false;
|
|
}
|
|
else e.Handled = true;
|
|
|
|
bemerkungTimer.Stop();
|
|
bemerkungTimer.Start();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine(ex.ToString());
|
|
}
|
|
}
|
|
|
|
private async void Bemerkung_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
|
{
|
|
Mouse.OverrideCursor = Cursors.Wait;
|
|
//li.Visibility = Visibility.Visible;
|
|
await Task.Delay(10);
|
|
SaveBemerkung(sender);
|
|
}
|
|
|
|
private void BemerkungTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
Keyboard.ClearFocus();
|
|
bemerkungTimer.Stop();
|
|
}
|
|
|
|
private async void SaveBemerkung(object sender)
|
|
{
|
|
bemerkungTimer.Stop();
|
|
|
|
try
|
|
{
|
|
var x = (sender as TextBox);
|
|
var y = x.DataContext as DataRowView;
|
|
var z = y.Row.ItemArray[0];
|
|
var datum = y.Row.ItemArray[4];
|
|
|
|
await SQL.WriteSQL($"UPDATE `mitarbeiter_static` `p` left join `mitarbeiter_change` `o` ON o.mitarbeiter_static_PersNr = p.PersNr SET Bemerkung = '{x.Text}' WHERE p.PersNr = '{z}' AND o.Datum = '{Convert.ToDateTime(datum).ToString("yyyy-MM-dd")}'", sqlList);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine(ex.ToString());
|
|
}
|
|
//li.Visibility = Visibility.Collapsed;
|
|
Mouse.OverrideCursor = Cursors.Arrow;
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Bemerkung_GotFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
(sender as TextBox).Focus();
|
|
bemerkungTimer.Start();
|
|
fs.Changed -= Fs_Changed;
|
|
|
|
var box = sender as TextBox;
|
|
box.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
|
|
box.Height = 50;
|
|
}
|
|
|
|
private void Bemerkung_LostFocus(object sender, RoutedEventArgs e)
|
|
{
|
|
var box = sender as TextBox;
|
|
box.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
|
|
box.Height = 30;
|
|
|
|
fs.Changed += Fs_Changed;
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisableFilterChange()
|
|
{
|
|
btnFrueh.IsEnabled = false;
|
|
btnSpaet.IsEnabled = false;
|
|
btnNacht.IsEnabled = false;
|
|
cBFrueh.IsEnabled = false;
|
|
cBSpaet.IsEnabled = false;
|
|
cBNacht.IsEnabled = false;
|
|
|
|
btnAllDays.IsEnabled = false;
|
|
btnDatePickerToday.IsEnabled = false;
|
|
dPDatum.IsEnabled = false;
|
|
btnSearch.IsEnabled = false;
|
|
btnMinusDay.IsEnabled = false;
|
|
btnPlusDay.IsEnabled = false;
|
|
}
|
|
|
|
private void EnableFilterChange()
|
|
{
|
|
btnFrueh.IsEnabled = true;
|
|
btnSpaet.IsEnabled = true;
|
|
btnNacht.IsEnabled = true;
|
|
cBFrueh.IsEnabled = true;
|
|
cBSpaet.IsEnabled = true;
|
|
cBNacht.IsEnabled = true;
|
|
|
|
btnAllDays.IsEnabled = true;
|
|
btnDatePickerToday.IsEnabled = true;
|
|
dPDatum.IsEnabled = true;
|
|
btnSearch.IsEnabled = true;
|
|
btnMinusDay.IsEnabled = true;
|
|
btnPlusDay.IsEnabled = true;
|
|
}
|
|
#endregion
|
|
|
|
#region Telefon
|
|
|
|
private void Telefon_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (Helper.isTelNumber(e.Key))
|
|
{
|
|
telefonTimer.Stop();
|
|
telefonTimer.Start();
|
|
}
|
|
else e.Handled = true;
|
|
}
|
|
|
|
private void TelefonTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
Keyboard.ClearFocus();
|
|
telefonTimer.Stop();
|
|
}
|
|
|
|
private void Telefon_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
|
{
|
|
Mouse.OverrideCursor = Cursors.Wait;
|
|
SaveTelefon(sender);
|
|
}
|
|
|
|
private async void SaveTelefon(object sender)
|
|
{
|
|
//li.Visibility = Visibility.Visible;
|
|
telefonTimer.Stop();
|
|
|
|
try
|
|
{
|
|
var x = (sender as TextBox);
|
|
var y = x.DataContext as DataRowView;
|
|
var z = y.Row.ItemArray[0];
|
|
|
|
await SQL.WriteSQL($"UPDATE `mitarbeiter_static` `p` left join `mitarbeiter_change` `o` ON o.mitarbeiter_static_PersNr = p.PersNr SET Telefon = '{x.Text}' WHERE p.PersNr = '{z}'", sqlList);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine(ex.ToString());
|
|
}
|
|
//li.Visibility = Visibility.Collapsed;
|
|
|
|
Mouse.OverrideCursor = Cursors.Arrow;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Lizenzen
|
|
|
|
private async void Lizenzen_DropDownOpened(object sender, EventArgs e)
|
|
{
|
|
var box = sender as ComboBox;
|
|
DataGridRow dataGridRow = FindParent<DataGridRow>(box);
|
|
int index = dataGridRow.GetIndex();
|
|
|
|
TextBlock persnummer = null;
|
|
|
|
persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
|
|
|
|
var l = await SQL.ReadSQL($"select lizenz from lizenzen_has_mitarbeiter_static m left join lizenzen l ON m.lizenzen_ID = l.ID where m.mitarbeiter_static_PersNr = {persnummer.Text}");
|
|
|
|
var t = Helper.DataTableToListString(l);
|
|
|
|
t.Insert(0, "");
|
|
|
|
box.ItemsSource = t;
|
|
}
|
|
|
|
private void Lizenzen_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
var combo = sender as ComboBox;
|
|
combo.SelectedIndex = 0;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Schaltzustand
|
|
|
|
private async void BtnSchalt_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var x = sender as Button;
|
|
|
|
Zugzuweisung z = new Zugzuweisung(x);
|
|
z.ShowDialog();
|
|
}
|
|
|
|
private void BtnZugZuweisungen_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Zugzuweisung z = new Zugzuweisung();
|
|
z.ShowDialog();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Filter
|
|
|
|
string abtFilter = "";
|
|
string abtFilter2 = "";
|
|
string abtFilter3 = "";
|
|
private async void cBFilterAbteilung_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
|
|
|
|
FilterList();
|
|
|
|
if (cBFilterAbteilung.SelectedItem != null && cBFilterAbteilung.SelectedItem.ToString() != "") cBFilterAbteilung2.IsEnabled = true;
|
|
else if (cBFilterAbteilung.SelectedItem == null || cBFilterAbteilung.SelectedItem.ToString() == "")
|
|
{
|
|
cBFilterAbteilung2.IsEnabled = cBFilterAbteilung3.IsEnabled = false;
|
|
cBFilterAbteilung2.SelectedIndex = cBFilterAbteilung3.SelectedIndex = 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private async void cBFilterAbteilung2_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
|
|
abtFilter2 = cBFilterAbteilung2.SelectedItem == null ? "" : cBFilterAbteilung2.SelectedItem.ToString();
|
|
|
|
FilterList();
|
|
|
|
if (cBFilterAbteilung2.SelectedItem != null && cBFilterAbteilung2.SelectedItem.ToString() != "") cBFilterAbteilung3.IsEnabled = true;
|
|
else if (cBFilterAbteilung2.SelectedItem == null || cBFilterAbteilung2.SelectedItem.ToString() == "")
|
|
{
|
|
cBFilterAbteilung3.IsEnabled = false;
|
|
cBFilterAbteilung3.SelectedIndex = 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private async void cBFilterAbteilung3_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
|
|
abtFilter2 = cBFilterAbteilung2.SelectedItem == null ? "" : cBFilterAbteilung2.SelectedItem.ToString();
|
|
abtFilter3 = cBFilterAbteilung3.SelectedItem == null ? "" : cBFilterAbteilung3.SelectedItem.ToString();
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
string lastButton = "";
|
|
private async void btnFrueh_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lastButton = "MT;MF";
|
|
|
|
uncheck_Boxes();
|
|
|
|
btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
|
|
btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private async void btnSpaet_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lastButton = "MS";
|
|
|
|
uncheck_Boxes();
|
|
|
|
btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
|
|
btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private async void btnNacht_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
lastButton = "MN";
|
|
|
|
uncheck_Boxes();
|
|
|
|
btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void cBFrueh_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (((lastButton == "MS" || lastButton == "MN") && !cBSpaet.IsChecked.Value && !cBNacht.IsChecked.Value)) lastButton = "";
|
|
if (!lastButton.Contains("MT;MF")) lastButton = lastButton + ";MT;MF";
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
|
|
btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void cBSpaet_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (((lastButton == "MT;MF" || lastButton == "MN") && !cBFrueh.IsChecked.Value && !cBNacht.IsChecked.Value)) lastButton = "";
|
|
if (!lastButton.Contains("MS")) lastButton = lastButton + ";MS";
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
|
|
btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void cBNacht_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (((lastButton == "MT;MF" || lastButton == "MS") && !cBSpaet.IsChecked.Value && !cBFrueh.IsChecked.Value)) lastButton = "";
|
|
if (!lastButton.Contains("MN")) lastButton = lastButton + ";MN";
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
|
|
btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void cBFrueh_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
lastButton = lastButton.Replace("MT;MF", "");
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
|
|
private void cBSpaet_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
lastButton = lastButton.Replace("MS", "");
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
|
|
private void cBNacht_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
lastButton = lastButton.Replace("MN", "");
|
|
lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
|
|
btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
|
|
|
|
FilterList();
|
|
}
|
|
|
|
private void uncheck_Boxes()
|
|
{
|
|
cBFrueh.Unchecked -= cBFrueh_Unchecked;
|
|
cBSpaet.Unchecked -= cBSpaet_Unchecked;
|
|
cBNacht.Unchecked -= cBNacht_Unchecked;
|
|
cBFrueh.IsChecked = false;
|
|
cBSpaet.IsChecked = false;
|
|
cBNacht.IsChecked = false;
|
|
cBFrueh.Unchecked += cBFrueh_Unchecked;
|
|
cBSpaet.Unchecked += cBSpaet_Unchecked;
|
|
cBNacht.Unchecked += cBNacht_Unchecked;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void tbSearch_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Key == Key.Return)
|
|
{
|
|
btnSearch.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
|
|
}
|
|
}
|
|
|
|
private void btnSearch_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FilterList(tbSearch.Text, true, cBSearchWithFilters.IsChecked.Value);
|
|
tbSearch.Text = "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void dPDatum_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FilterList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
private void btnDatePickerToday_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
dPDatum.SelectedDate = DateTime.Now.Date;
|
|
}
|
|
|
|
private void btnAllDays_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
dPDatum.SelectedDate = null;
|
|
}
|
|
|
|
|
|
private void BtnMinusDay_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (dPDatum.SelectedDate != null)
|
|
dPDatum.SelectedDate = dPDatum.SelectedDate - TimeSpan.FromDays(1);
|
|
else
|
|
dPDatum.SelectedDate = DateTime.Now.Date;
|
|
}
|
|
|
|
private void BtnPlusDay_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (dPDatum.SelectedDate != null)
|
|
dPDatum.SelectedDate = dPDatum.SelectedDate + TimeSpan.FromDays(1);
|
|
else
|
|
dPDatum.SelectedDate = DateTime.Now.Date + TimeSpan.FromDays(1);
|
|
}
|
|
|
|
private async void FilterList(string search = "", bool isSearch = false, bool searchWithFilter = false)
|
|
{
|
|
try
|
|
{
|
|
var date = dPDatum.SelectedDate.HasValue ? dPDatum.SelectedDate.ToString() : "";
|
|
|
|
sqlList = await TableCreater.CreateList(sqlList, abtFilter, abtFilter2, abtFilter3, lastButton, date, search, searchWithFilter, isSearch);
|
|
|
|
|
|
//flowDocu.ItemsSource = UserList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogFile.WriteLine(ex.ToString());
|
|
LogFile.WriteLine("Message: " + ex.Message);
|
|
//LogFile.WriteLine("UserList: " + UserList.Count + " Items");
|
|
if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Print and Export
|
|
|
|
private async void btnPrint_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
propertyChangeAllowed = false;
|
|
|
|
Print print = new Print();
|
|
|
|
bar.IsIndeterminate = true;
|
|
bar.Visibility = Visibility.Visible;
|
|
|
|
DataGrid printList = new DataGrid();
|
|
|
|
DataGrid grid = new DataGrid();
|
|
|
|
grid = print.CreatePrintGrid(sqlList);
|
|
grid.ItemsSource = sqlList.DefaultView;
|
|
|
|
//if (printList.Rows.Count > 100) lblBar.Visibility = Visibility.Visible;
|
|
|
|
string listTitle = "";
|
|
switch (lastButton)
|
|
{
|
|
case "MT;MF":
|
|
listTitle = " für Früh- / Tagschicht";
|
|
break;
|
|
case "MS":
|
|
listTitle = " für Spätschicht";
|
|
break;
|
|
case "MN":
|
|
listTitle = " für Nachtschicht";
|
|
break;
|
|
default:
|
|
listTitle = "";
|
|
break;
|
|
}
|
|
|
|
print.printDG(grid, "Personaleinsatzplanung" + listTitle);
|
|
|
|
bar.Visibility = Visibility.Collapsed;
|
|
lblBar.Visibility = Visibility.Collapsed;
|
|
//PrintDialog pd = new PrintDialog();
|
|
//print.PrintDataGrid(null, grid, null, pd);
|
|
propertyChangeAllowed = true;
|
|
}
|
|
|
|
private void btnExport_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Export.ExportCSV(sqlList.DefaultView);
|
|
}
|
|
|
|
private Visibility barVisibility;
|
|
public Visibility BarVisibility
|
|
{
|
|
get { return barVisibility; }
|
|
set
|
|
{
|
|
barVisibility = value;
|
|
bar.Visibility = value;
|
|
}
|
|
}
|
|
|
|
private bool barIsIndeterminate;
|
|
public bool BarIsIndeterminate
|
|
{
|
|
get { return barIsIndeterminate; }
|
|
set
|
|
{
|
|
barIsIndeterminate = value;
|
|
bar.IsIndeterminate = value;
|
|
}
|
|
}
|
|
|
|
private double barMax;
|
|
public double BarMax
|
|
{
|
|
get { return barMax; }
|
|
set
|
|
{
|
|
barMax = value;
|
|
bar.Maximum = value;
|
|
}
|
|
}
|
|
|
|
private double barValue;
|
|
public double BarValue
|
|
{
|
|
get { return barValue; }
|
|
set
|
|
{
|
|
barValue = value;
|
|
bar.Value = value;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Extensions
|
|
|
|
public static Parent FindParent<Parent>(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<Parent>(parentObject);
|
|
}
|
|
}
|
|
|
|
public ScrollViewer GetScrollViewer(UIElement element)
|
|
{
|
|
//Dispatcher.BeginInvoke(new Action(() => {
|
|
if (element == null) return null;
|
|
|
|
ScrollViewer retour = null;
|
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element) && retour == null; i++)
|
|
{
|
|
if (VisualTreeHelper.GetChild(element, i) is ScrollViewer)
|
|
{
|
|
retour = (ScrollViewer)(VisualTreeHelper.GetChild(element, i));
|
|
}
|
|
else
|
|
{
|
|
retour = GetScrollViewer(VisualTreeHelper.GetChild(element, i) as UIElement);
|
|
}
|
|
}
|
|
return retour;
|
|
//}));
|
|
}
|
|
|
|
public IEnumerable<DataGridRow> GetDataGridRows(DataGrid grid)
|
|
{
|
|
var itemsSource = grid.ItemsSource;
|
|
if (null == itemsSource) yield return null;
|
|
foreach (var item in itemsSource)
|
|
{
|
|
var row = grid.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow;
|
|
if (null != row) yield return row;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Settings
|
|
|
|
private void btnSettings_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
tBAbtTranslatePath.Text = Properties.Settings.Default.AbteilungsnamenPath;
|
|
tBZuweisungenPath.Text = Properties.Settings.Default.ZuweisungenPath;
|
|
|
|
|
|
gridSettings.Visibility = Visibility.Visible;
|
|
canvasSettings.Visibility = Visibility.Visible;
|
|
|
|
gridToolbar.Visibility = Visibility.Collapsed;
|
|
gridTable.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
private void btnCloseSettings_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasSettings.Visibility = Visibility.Collapsed;
|
|
gridSettings.Visibility = Visibility.Collapsed;
|
|
gridToolbar.Visibility = Visibility.Visible;
|
|
gridTable.Visibility = Visibility.Visible;
|
|
Properties.Settings.Default.AbteilungsnamenPath = tBAbtTranslatePath.Text;
|
|
Properties.Settings.Default.ZuweisungenPath = tBZuweisungenPath.Text;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
|
|
private void btnCancelSettings_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasSettings.Visibility = Visibility.Collapsed;
|
|
gridSettings.Visibility = Visibility.Collapsed;
|
|
gridToolbar.Visibility = Visibility.Visible;
|
|
gridTable.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void btnSelectAbtTranslateFile_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var p = Reader.OpenFile("Abteilungsnamen");
|
|
var lines = System.IO.File.ReadAllLines(p);
|
|
|
|
if (lines[0].StartsWith("Abteilung;")) tBAbtTranslatePath.Text = p;
|
|
else
|
|
{
|
|
var x = MessageBox.Show("Keine gültige Abteilungsliste ausgewählt!", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
|
|
btnSelectAbtTranslateFile.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
|
|
}
|
|
}
|
|
|
|
private void btnSelectZuweisungenFile_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var p = Reader.OpenFile("Zuweisungen");
|
|
var lines = System.IO.File.ReadAllLines(p);
|
|
|
|
if (!lines.Contains(";")) tBZuweisungenPath.Text = p;
|
|
else
|
|
{
|
|
var x = MessageBox.Show("Keine gültige Zuweisungen-Liste ausgewählt!", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
|
|
btnSelectZuweisungenFile.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
|
|
}
|
|
}
|
|
|
|
private void btnImpressum_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasImpressum.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void btnCloseImpressum_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasImpressum.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
|
|
private void btnVersionInfo_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasVersionInfo.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void btnCloseVersionInfo_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
canvasVersionInfo.Visibility = Visibility.Collapsed;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
private void Window_Deactivated(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void btnHideToolbar_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (gridToolbar.Height == 184)
|
|
{
|
|
gridToolbar.Height = 14;
|
|
btnHideToolbar.Content = "˅˅";
|
|
flowDocu.Height = ActualHeight + 170;
|
|
btnHideToolbar.ToolTip = "Toolbar öffnen";
|
|
}
|
|
else
|
|
{
|
|
gridToolbar.Height = 184;
|
|
btnHideToolbar.Content = "^^";
|
|
flowDocu.Height = ActualHeight - 170;
|
|
btnHideToolbar.ToolTip = "Toolbar schließen";
|
|
}
|
|
|
|
gridTable.Height = main.ActualHeight - gridToolbar.Height - 40;
|
|
flowDocu.Height = gridTable.Height;
|
|
}
|
|
|
|
bool onStartup = false;
|
|
private async void Window_Closing(object sender, CancelEventArgs e)
|
|
{
|
|
await SQL.WriteSQL($"REPLACE INTO track SET `Client` = '{Environment.MachineName}', `Online` = false");
|
|
|
|
if (!onStartup) Application.Current.Shutdown();
|
|
}
|
|
|
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
gridTable.Height = main.ActualHeight - gridToolbar.Height - 40;
|
|
flowDocu.Height = gridTable.Height;
|
|
|
|
}
|
|
|
|
private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
//var scroll = Helper.FindVisualChild<ScrollViewer>((DependencyObject)sender);
|
|
|
|
//int firstRow = (int)scroll.VerticalOffset;
|
|
//int lastRow = (int)scroll.VerticalOffset + (int)scroll.ViewportHeight - 1;
|
|
|
|
//if (firstRow != lastVisibleFirstRow)
|
|
//{
|
|
// lastVisibleFirstRow = firstRow;
|
|
// DispatcherTimer ChangeTimer = new DispatcherTimer();
|
|
// ChangeTimer.Interval = TimeSpan.FromSeconds(10);
|
|
// ChangeTimer.Tick += (s, ev) => { ChangeTimer_Tick(sender, e, firstRow, lastRow, ChangeTimer); };
|
|
// ChangeTimer.Start();
|
|
//}
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void GetDesktopShortcuts()
|
|
{
|
|
if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat") || File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat") != File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\UpdatePEP.bat"))
|
|
{
|
|
File.Copy(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\UpdatePEP.bat", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat", true);
|
|
GetDesktopShortcuts();
|
|
}
|
|
else
|
|
{
|
|
if (File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\PEP-Tool.exe") < File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\PEP-Tool.exe"))
|
|
{
|
|
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat");
|
|
Application.Current.Shutdown();
|
|
}
|
|
}
|
|
|
|
foreach (var link in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)))
|
|
{
|
|
if (System.IO.Path.GetExtension(link) == ".lnk")
|
|
{
|
|
var target = ResolveShortcut(link);
|
|
|
|
if (target.EndsWith("AV-Tool.exe"))
|
|
{
|
|
ChangeShortcutTarget(link);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static string ResolveShortcut(string filePath)
|
|
{
|
|
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
|
|
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
|
|
|
|
try
|
|
{
|
|
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
|
return shortcut.TargetPath;
|
|
}
|
|
catch (System.Runtime.InteropServices.COMException)
|
|
{
|
|
// A COMException is thrown if the file is not a valid shortcut (.lnk) file
|
|
return null;
|
|
}
|
|
}
|
|
|
|
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
|
|
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
|
|
|
|
static void ChangeShortcutTarget(string filePath)
|
|
{
|
|
File.Delete(filePath);
|
|
}
|
|
|
|
|
|
|
|
private void BtnPlannedKT_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
KTOverview kT = new KTOverview();
|
|
kT.Show();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
Debug.WriteLine("PropertyChanged " + propertyName);
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|