diff --git a/ENI-2/ENI2/ENI2/AnmeldungenControl.xaml b/ENI-2/ENI2/ENI2/AnmeldungenControl.xaml index caec8fad..97614ea3 100644 --- a/ENI-2/ENI2/ENI2/AnmeldungenControl.xaml +++ b/ENI-2/ENI2/ENI2/AnmeldungenControl.xaml @@ -12,12 +12,12 @@ - + - + - + diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config index 85221ef7..b793453c 100644 --- a/ENI-2/ENI2/ENI2/App.config +++ b/ENI-2/ENI2/ENI2/App.config @@ -17,7 +17,7 @@ Sample license text. - Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs index fa179ea3..22f580d1 100644 --- a/ENI-2/ENI2/ENI2/App.xaml.cs +++ b/ENI-2/ENI2/ENI2/App.xaml.cs @@ -1,10 +1,5 @@ // Copyright (c) 2017 Informatibüro Daniel Schick -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; + using System.Windows; namespace ENI2 @@ -14,5 +9,17 @@ namespace ENI2 /// public partial class App : Application { + + public App() : base() + { + this.Dispatcher.UnhandledException += Dispatcher_UnhandledException; + } + + private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) + { + string errorMessage = string.Format("An unhandled exception occurred: {0}\r\n{1}", e.Exception.Message, e.Exception.StackTrace); + MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + e.Handled = true; + } } } diff --git a/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs b/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs index a58d347d..7d7267b0 100644 --- a/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs +++ b/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs @@ -60,12 +60,21 @@ namespace ENI2.Controls } */ + // das hier bildet 1:1 das Kontext-Menü des ANSW ab + public event Action EditRequested; public event Action DeleteRequested; public event Action CreateRequested; + public event Action PrintRequested; + public event Action ExportRequested; + public event Action ShowTextRequested; + public void Initialize() { + + this.MouseDoubleClick += dataGrid_MouseDoubleClick; + this.ContextMenu = new ContextMenu(); MenuItem addItem = new MenuItem(); @@ -86,6 +95,26 @@ namespace ENI2.Controls editItem.Click += this.editItem; this.ContextMenu.Items.Add(editItem); + this.ContextMenu.Items.Add(new Separator()); + + MenuItem printItem = new MenuItem(); + printItem.Header = "_Print"; + printItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/printer.png")) }; + printItem.Click += this.printItem; + this.ContextMenu.Items.Add(printItem); + + MenuItem exportItem = new MenuItem(); + exportItem.Header = "_Export"; + exportItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/floppy_disk_blue.png")) }; + exportItem.Click += this.exportItem; + this.ContextMenu.Items.Add(exportItem); + + MenuItem showTextItem = new MenuItem(); + showTextItem.Header = "_Show data as text"; + showTextItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/document_plain.png")) }; + showTextItem.Click += this.showTextItem; + this.ContextMenu.Items.Add(showTextItem); + } protected void addItem(object sender, RoutedEventArgs e) @@ -118,5 +147,51 @@ namespace ENI2.Controls } } + protected void printItem(object sender, RoutedEventArgs e) + { + if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1)) + { + DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity; + if (selectedEntity != null) + this.PrintRequested?.Invoke(selectedEntity); + } + } + + protected void exportItem(object sender, RoutedEventArgs e) + { + if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1)) + { + DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity; + if (selectedEntity != null) + this.ExportRequested?.Invoke(selectedEntity); + } + } + + protected void showTextItem(object sender, RoutedEventArgs e) + { + if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1)) + { + DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity; + if (selectedEntity != null) + this.ShowTextRequested?.Invoke(selectedEntity); + } + } + + private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) + { + if (sender != null) + { + DataGrid grid = sender as DataGrid; + if ((grid != null) && (grid.SelectedItems != null) && (grid.SelectedItems.Count == 1)) + { + DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow; + DatabaseEntity selectedEntity = grid.SelectedItem as DatabaseEntity; + if (selectedEntity != null) + this.EditRequested?.Invoke(selectedEntity); + } + } + } + + } } diff --git a/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs new file mode 100644 index 00000000..0ebc6f4e --- /dev/null +++ b/ENI-2/ENI2/ENI2/Controls/EditWindowBase.cs @@ -0,0 +1,47 @@ +// Copyright (c) 2017 schick Informatik +// Description: Basisklasse für Bearbeitungsfensterle +// Position merken usw. + +using System; +using System.Windows; +using System.Windows.Controls; +using System.ComponentModel; + +namespace ENI2.Controls +{ + /// + /// Basisklasse aller Bearbeitungsdialoge. OK/Cancel Buttons und Window Placement + /// + [TemplatePart(Name = "buttonOK",Type = typeof(Button))] + [TemplatePart(Name = "buttonCancel", Type = typeof(Button))] + public class EditWindowBase : Window + { + static EditWindowBase() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(EditWindowBase), new FrameworkPropertyMetadata(typeof(EditWindowBase))); + } + + public EditWindowBase() + { + Loaded += (_, __) => + { + var okButton = (Button)Template.FindName("buttonOK", this); + var cancelButton = (Button)Template.FindName("buttonCancel", this); + okButton.Click += (s, e) => DialogResult = true; + cancelButton.Click += (s, e) => DialogResult = false; + }; + } + + private void Window_Closing(object sender, CancelEventArgs e) + { + // ENI2.Properties.Settings.Default.M + } + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + // this.SetPlacement(..) + } + + } +} diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs index 437ccea3..3b6e15c4 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs @@ -20,6 +20,7 @@ using System.Windows.Shapes; using bsmd.database; using bsmd.ExcelReadService; using ENI2; +using ENI2.EditControls; namespace ENI2.DetailViewControls { @@ -70,6 +71,10 @@ namespace ENI2.DetailViewControls this.dataGridCallPurposes.Initialize(); this.dataGridCallPurposes.ItemsSource = _noa_nod.CallPurposes; + this.dataGridCallPurposes.EditRequested += DataGridCallPurposes_EditRequested; + this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem; + this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested; + this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested; this.agentGroupBox.DataContext = _agnt; @@ -81,7 +86,34 @@ namespace ENI2.DetailViewControls this.dateTimePicker_ETDFromPortOfCall.DataContext = _noa_nod; - } + } + private void DataGridCallPurposes_DeleteRequested(DatabaseEntity obj) + { + // throw new NotImplementedException(); + } + + private void DataGridCallPurposes_CreateRequested() + { + //throw new NotImplementedException(); + } + + private void DataGridCallPurposes_AddingNewItem(object sender, AddingNewItemEventArgs e) + { + //throw new NotImplementedException(); + } + + private void DataGridCallPurposes_EditRequested(DatabaseEntity obj) + { + EditCallPurposeDialog ecpd = new EditCallPurposeDialog(); + if(ecpd.ShowDialog() ?? false) + { + // Edit successful + } + else + { + // cancelled out.. + } + } } } diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 53091cb0..d9a09cb3 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -35,7 +35,7 @@ 3.5.1.0 true publish.html - 3 + 6 3.5.6.%2a false true @@ -51,6 +51,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -101,6 +102,7 @@ packages\System.Data.SQLite.Core.1.0.105.0\lib\net451\System.Data.SQLite.dll True + False @@ -157,6 +159,7 @@ Locode\LocodeDB.cs + LocodeControl.xaml @@ -204,6 +207,9 @@ WasteDetailControl.xaml + + EditCallPurposeDialog.xaml + SucheControl.xaml @@ -275,6 +281,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -317,6 +327,15 @@ Settings.settings True + + Always + + + Always + + + + @@ -431,6 +450,7 @@ + diff --git a/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml new file mode 100644 index 00000000..7f18ce7a --- /dev/null +++ b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs new file mode 100644 index 00000000..07d99b0c --- /dev/null +++ b/ENI-2/ENI2/ENI2/EditControls/EditCallPurposeDialog.xaml.cs @@ -0,0 +1,29 @@ +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; + +using ENI2.Controls; + +namespace ENI2.EditControls +{ + /// + /// Interaction logic for EditCallPurposeDialog.xaml + /// + public partial class EditCallPurposeDialog : EditWindowBase + { + public EditCallPurposeDialog() + { + InitializeComponent(); + } + } +} diff --git a/ENI-2/ENI2/ENI2/MainWindow.xaml b/ENI-2/ENI2/ENI2/MainWindow.xaml index e764aadf..cb39e3e1 100644 --- a/ENI-2/ENI2/ENI2/MainWindow.xaml +++ b/ENI-2/ENI2/ENI2/MainWindow.xaml @@ -5,13 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ENI2" mc:Ignorable="d" - Title="ENI 2" Height="350" Width="525" Icon="Resources/logo_schwarz.ico" Loaded="Window_Loaded" Closing="Window_Closing" SourceInitialized="Window_SourceInitialized"> + Title="ENI 2" Height="350" Width="525" Icon="Resources/logo_schwarz.ico" Loaded="Window_Loaded" Closing="Window_Closing" + SourceInitialized="Window_SourceInitialized"> -