diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml index d5ca2996..cead6e4e 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs index bd8b1bb9..c7ac08a7 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; +using System.Diagnostics; using bsmd.database; using ENI2.EditControls; @@ -19,8 +20,18 @@ namespace ENI2.DetailViewControls /// public partial class PortCallDetailControl : DetailBaseControl { + + #region Fields + private NOA_NOD _noa_nod; - private AGNT _agnt; + private AGNT _agnt; + private static List _agntTemplates = null; + private AGNT_Template _currentTemplate; + private AGNT_Template _undoTemplate; + + #endregion + + #region Construction public PortCallDetailControl() { @@ -28,6 +39,10 @@ namespace ENI2.DetailViewControls this.Loaded += PortCallDetailControl_Loaded; } + #endregion + + #region Loading / initialize + private void PortCallDetailControl_Loaded(object sender, RoutedEventArgs e) { // NOA_NOD @@ -106,8 +121,19 @@ namespace ENI2.DetailViewControls this.dateTimePicker_ETDFromPortOfCall.DataContext = _noa_nod; this.checkBox_IsAnchored.IsEnabled = this.Core.IsDK; + + if(_agntTemplates == null) + { + _agntTemplates = DBManager.Instance.GetAGNTTemplates(); // inital full load + _agntTemplates.Sort(); + Trace.WriteLine(string.Format("{0} agent templates loaded", _agntTemplates.Count)); + } + this.comboBox_AgentTemplate.ItemsSource = _agntTemplates; + } + #endregion + #region datagrid call purposes private void DataGridCallPurposes_DeleteRequested(DatabaseEntity obj) @@ -223,7 +249,139 @@ namespace ENI2.DetailViewControls e.Handled = true; } - #endregion + #endregion + + #region AGNT templates combo + + private void comboBox_AgentTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + Trace.WriteLine("combo selection changed"); + AGNT_Template at = this.comboBox_AgentTemplate.SelectedItem as AGNT_Template; + if(at != null) + { + this.textBoxTemplateTitle.Text = at.AgentTitle; + this.buttonDeleteTemplate.IsEnabled = true; + this.buttonSetTemplate.IsEnabled = true; + this._currentTemplate = at; + } + + } + + private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e) + { + if (_currentTemplate != null) + { + if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) + { + this.comboBox_AgentTemplate.SelectedItem = null; + this.comboBox_AgentTemplate.ItemsSource = null; + DBManager.Instance.Delete(_currentTemplate); + _agntTemplates.Remove(_currentTemplate); + this.textBoxTemplateTitle.Text = null; + this.buttonDeleteTemplate.IsEnabled = false; + this.comboBox_AgentTemplate.ItemsSource = _agntTemplates; + this.buttonSetTemplate.IsEnabled = false; + } + } + } + + private void buttonSaveTemplate_Click(object sender, RoutedEventArgs e) + { + string title = this.textBoxTemplateTitle.Text.Trim(); + if(title.IsNullOrEmpty()) + { + MessageBox.Show("Title may not be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + AGNT_Template existingTemplate = null; + foreach(AGNT_Template anExistingTemplate in _agntTemplates) + { + if(anExistingTemplate.AgentTitle.Equals(title,StringComparison.OrdinalIgnoreCase)) + { + existingTemplate = anExistingTemplate; + break; + } + } + + if(existingTemplate != null) + { + if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) + return; + } + + this._currentTemplate = createFromCurrentText(title, existingTemplate); + DBManager.Instance.Save(this._currentTemplate); + + if(existingTemplate == null) + { + comboBox_AgentTemplate.ItemsSource = null; + _agntTemplates.Add(this._currentTemplate); + _agntTemplates.Sort(); + comboBox_AgentTemplate.ItemsSource = _agntTemplates; + } + + MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information); + } + + private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e) + { + + this.textBox_AgentCity.Text = this._undoTemplate.AgentCity; + this.textBox_AgentCompanyName.Text = this._undoTemplate.AgentCompanyName; + this.textBox_AgentCountry.Text = this._undoTemplate.AgentCountry; + this.textBox_AgentEMail.Text = this._undoTemplate.AgentEMail; + this.textBox_AgentFax.Text = this._undoTemplate.AgentFax; + this.textBox_AgentFirstName.Text = this._undoTemplate.AgentFirstName; + this.textBox_AgentLastName.Text = this._undoTemplate.AgentLastName; + this.textBox_AgentPhone.Text = this._undoTemplate.AgentPhone; + this.textBox_AgentPostalCode.Text = this._undoTemplate.AgentPostalCode; + this.textBox_AgentStreetAndNumber.Text = this._undoTemplate.AgentStreetAndNumber; + + this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo + } + + private void buttonSetTemplate_Click(object sender, RoutedEventArgs e) + { + this._undoTemplate = createFromCurrentText(null, null); + + this.textBox_AgentCity.Text = this._currentTemplate.AgentCity; + this.textBox_AgentCompanyName.Text = this._currentTemplate.AgentCompanyName; + this.textBox_AgentCountry.Text = this._currentTemplate.AgentCountry; + this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail; + this.textBox_AgentFax.Text = this._currentTemplate.AgentFax; + this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName; + this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName; + this.textBox_AgentPhone.Text = this._currentTemplate.AgentPhone; + this.textBox_AgentPostalCode.Text = this._currentTemplate.AgentPostalCode; + this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; + + this.buttonUndoTemplate.IsEnabled = true; + + } + + private AGNT_Template createFromCurrentText(string title, AGNT_Template existingTemplate) + { + AGNT_Template at = new AGNT_Template(); + if (existingTemplate != null) + at = existingTemplate; + + at.AgentTitle = title; + at.AgentCity = this.textBox_AgentCity.Text; + at.AgentCompanyName = this.textBox_AgentCompanyName.Text; + at.AgentCountry = this.textBox_AgentCountry.Text; + at.AgentEMail = this.textBox_AgentEMail.Text; + at.AgentFax = this.textBox_AgentFax.Text; + at.AgentFirstName = this.textBox_AgentFirstName.Text; + at.AgentLastName = this.textBox_AgentLastName.Text; + at.AgentPhone = this.textBox_AgentPhone.Text; + at.AgentPostalCode = this.textBox_AgentPostalCode.Text; + at.AgentStreetAndNumber = textBox_AgentStreetAndNumber.Text; + + return at; + } + + #endregion } } diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 150b6c63..43c05501 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -706,6 +706,7 @@ + Always diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs index 9935d79f..2a6ada13 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs +++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs @@ -803,6 +803,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Template. + /// + public static string textAgentTemplate { + get { + return ResourceManager.GetString("textAgentTemplate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Declaration is already cancelled!. /// @@ -4448,6 +4457,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Title. + /// + public static string textTitle { + get { + return ResourceManager.GetString("textTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show message core database fields (Detail). /// @@ -4956,6 +4974,16 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap undo { + get { + object obj = ResourceManager.GetObject("undo", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx index 3359d5ce..f565d10c 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.resx +++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx @@ -1729,4 +1729,13 @@ Message status + + Template + + + Title + + + ..\Resources\undo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ENI-2/ENI2/ENI2/Resources/undo.png b/ENI-2/ENI2/ENI2/Resources/undo.png new file mode 100644 index 00000000..5990e849 Binary files /dev/null and b/ENI-2/ENI2/ENI2/Resources/undo.png differ diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index ff4495ca..7fb90cd4 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/7.0/Folienvortrag NSW Betriebs-Aspekte21.pdf b/nsw/7.0/Folienvortrag NSW Betriebs-Aspekte21.pdf new file mode 100644 index 00000000..ef8e0da5 Binary files /dev/null and b/nsw/7.0/Folienvortrag NSW Betriebs-Aspekte21.pdf differ diff --git a/nsw/Source/SQL/Update_6.0.10_To_6.5.sql b/nsw/Source/SQL/Update_6.0.10_To_6.5.sql new file mode 100644 index 00000000..f405ab67 --- /dev/null +++ b/nsw/Source/SQL/Update_6.0.10_To_6.5.sql @@ -0,0 +1,33 @@ +PRINT N'Creating [dbo].[AGNT_template]...'; + +GO +CREATE TABLE [dbo].[AGNT_template] ( + [Id] UNIQUEIDENTIFIER NOT NULL, + [Title] NVARCHAR (50) NULL, + [AgentCompanyName] NVARCHAR (100) NULL, + [AgentStreetAndNumber] NVARCHAR (100) NULL, + [AgentPostalCode] NVARCHAR (25) NULL, + [AgentCity] NVARCHAR (100) NULL, + [AgentCountry] NVARCHAR (100) NULL, + [AgentLastName] NVARCHAR (100) NULL, + [AgentFirstName] NVARCHAR (100) NULL, + [AgentPhone] NVARCHAR (100) NULL, + [AgentFax] NVARCHAR (100) NULL, + [AgentEMail] NVARCHAR (100) NULL, + [Created] DATETIME NULL DEFAULT CURRENT_TIMESTAMP, + [Changed] DATETIME NULL, + PRIMARY KEY CLUSTERED ([Id] ASC) +); + +GO + +CREATE TRIGGER AGNT_template_Trigger_Change_Log +ON + dbo.AGNT_TEMPLATE + FOR UPDATE + AS + SET NOCOUNT ON + IF NOT UPDATE([Changed]) + UPDATE AGNT_TEMPLATE SET [Changed] = GETDATE() WHERE Id IN (SELECT Id FROM [inserted]) + +GO \ No newline at end of file diff --git a/nsw/Source/bsmd.database/AGNT.cs b/nsw/Source/bsmd.database/AGNT.cs index a34d66b8..96585cca 100644 --- a/nsw/Source/bsmd.database/AGNT.cs +++ b/nsw/Source/bsmd.database/AGNT.cs @@ -51,7 +51,7 @@ namespace bsmd.database [ShowReport] [LookupName("AGNT.AgentPostalCode")] - [MaxLength(99)] + [MaxLength(24)] [ENI2Validation] [DataMember] public string AgentPostalCode { get; set; } diff --git a/nsw/Source/bsmd.database/AGNT_Template.cs b/nsw/Source/bsmd.database/AGNT_Template.cs new file mode 100644 index 00000000..8585eee1 --- /dev/null +++ b/nsw/Source/bsmd.database/AGNT_Template.cs @@ -0,0 +1,159 @@ +// Copyright (c) 2020-present schick Informatik +// Description: Save location for AGNT templates (lookup / pre-filled) + +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Runtime.Serialization; + + +namespace bsmd.database +{ + public class AGNT_Template : DatabaseEntity, IComparable + { + #region Construction + + public AGNT_Template() + { + this.tablename = "[dbo].[AGNT_template]"; + } + + #endregion + + #region Properties + + [MaxLength(49)] + public string AgentTitle { get; set; } + + [MaxLength(99)] + public string AgentCompanyName { get; set; } + + [MaxLength(99)] + public string AgentStreetAndNumber { get; set; } + + [MaxLength(24)] + public string AgentPostalCode { get; set; } + + [MaxLength(99)] + public string AgentCity { get; set; } + + [MaxLength(99)] + public string AgentCountry { get; set; } + + [MaxLength(99)] + public string AgentLastName { get; set; } + + [MaxLength(99)] + public string AgentFirstName { get; set; } + + [MaxLength(99)] + public string AgentPhone { get; set; } + + [MaxLength(99)] + public string AgentFax { get; set; } + + [MaxLength(99)] + public string AgentEMail { get; set; } + + #endregion + + #region DatabaseEntity implementation + + public override void PrepareSave(System.Data.IDbCommand cmd) + { + SqlCommand scmd = cmd as SqlCommand; + + if (this.AgentTitle != null) scmd.Parameters.AddWithValue("@P1", this.AgentTitle); + else scmd.Parameters.AddWithValue("@P1", DBNull.Value); + if (this.AgentCompanyName != null) scmd.Parameters.AddWithValue("@P2", this.AgentCompanyName); + else scmd.Parameters.AddWithValue("@P2", DBNull.Value); + if (this.AgentStreetAndNumber != null) scmd.Parameters.AddWithValue("@P3", this.AgentStreetAndNumber); + else scmd.Parameters.AddWithValue("@P3", DBNull.Value); + if (this.AgentPostalCode != null) scmd.Parameters.AddWithValue("@P4", this.AgentPostalCode); + else scmd.Parameters.AddWithValue("@P4", DBNull.Value); + if (this.AgentCity != null) scmd.Parameters.AddWithValue("@P5", this.AgentCity); + else scmd.Parameters.AddWithValue("@P5", DBNull.Value); + if (this.AgentCountry != null) scmd.Parameters.AddWithValue("@P6", this.AgentCountry); + else scmd.Parameters.AddWithValue("@P6", DBNull.Value); + if (this.AgentLastName != null) scmd.Parameters.AddWithValue("@P7", this.AgentLastName); + else scmd.Parameters.AddWithValue("@P7", DBNull.Value); + if (this.AgentFirstName != null) scmd.Parameters.AddWithValue("@P8", this.AgentFirstName); + else scmd.Parameters.AddWithValue("@P8", DBNull.Value); + if (this.AgentPhone != null) scmd.Parameters.AddWithValue("@P9", this.AgentPhone); + else scmd.Parameters.AddWithValue("@P9", DBNull.Value); + if (this.AgentFax != null) scmd.Parameters.AddWithValue("@P10", this.AgentFax); + else scmd.Parameters.AddWithValue("@P10", DBNull.Value); + if (this.AgentEMail != null) scmd.Parameters.AddWithValue("@P11", this.AgentEMail); + else scmd.Parameters.AddWithValue("@P11", DBNull.Value); + + if (this.IsNew) + { + this.CreateId(); + scmd.Parameters.AddWithValue("@ID", this.Id); + cmd.CommandText = string.Format("INSERT INTO {0} (Id, Title, AgentCompanyName, AgentStreetAndNumber, " + + "AgentPostalCode, AgentCity, AgentCountry, AgentLastName, AgentFirstName, AgentPhone, AgentFax, " + + "AgentEMail) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11)", this.Tablename); + } + else + { + cmd.CommandText = string.Format("UPDATE {0} SET Title = @P1, AgentCompanyName = @P2, AgentStreetAndNumber = @P3, AgentPostalCode = @P4, AgentCity = @P5, " + + "AgentCountry = @P6, AgentLastName = @P7, AgentFirstName = @P8, AgentPhone = @P9, AgentFax = @P10, " + + "AgentEMail = @P11 WHERE Id = @ID", this.Tablename); + scmd.Parameters.AddWithValue("@ID", this.Id); + } + } + + public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) + { + string query = string.Format("SELECT Id, Title, AgentCompanyName, AgentStreetAndNumber, AgentPostalCode, AgentCity, AgentCountry, " + + "AgentLastName, AgentFirstName, AgentPhone, AgentFax, AgentEMail FROM {0} ", this.Tablename); + + switch (filter) + { + case Message.LoadFilter.ALL: + default: + + break; + } + cmd.CommandText = query; + } + + public override List LoadList(System.Data.IDataReader reader) + { + List result = new List(); + + while (reader.Read()) + { + AGNT_Template agnt_t = new AGNT_Template(); + agnt_t.id = reader.GetGuid(0); + if (!reader.IsDBNull(1)) agnt_t.AgentTitle = reader.GetString(1); + if (!reader.IsDBNull(2)) agnt_t.AgentCompanyName = reader.GetString(2); + if (!reader.IsDBNull(3)) agnt_t.AgentStreetAndNumber = reader.GetString(3); + if (!reader.IsDBNull(4)) agnt_t.AgentPostalCode = reader.GetString(4); + if (!reader.IsDBNull(5)) agnt_t.AgentCity = reader.GetString(5); + if (!reader.IsDBNull(6)) agnt_t.AgentCountry = reader.GetString(6); + if (!reader.IsDBNull(7)) agnt_t.AgentLastName = reader.GetString(7); + if (!reader.IsDBNull(8)) agnt_t.AgentFirstName = reader.GetString(8); + if (!reader.IsDBNull(9)) agnt_t.AgentPhone = reader.GetString(9); + if (!reader.IsDBNull(10)) agnt_t.AgentFax = reader.GetString(10); + if (!reader.IsDBNull(11)) agnt_t.AgentEMail = reader.GetString(11); + + result.Add(agnt_t); + } + reader.Close(); + return result; + } + + public int CompareTo(object obj) + { + if (obj is AGNT_Template) + { + return AgentTitle.CompareTo(((AGNT_Template)obj).AgentTitle); + } + return 0; + } + + #endregion + + } +} diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs index 398750c8..e56f337e 100644 --- a/nsw/Source/bsmd.database/DBManager.cs +++ b/nsw/Source/bsmd.database/DBManager.cs @@ -707,6 +707,29 @@ namespace bsmd.database } } + public List GetAGNTTemplates() + { + List result = new List(); + try + { + using (SqlCommand cmd = new SqlCommand()) + { + AGNT_Template agnt_template = new AGNT_Template(); + agnt_template.PrepareLoadCommand(cmd, Message.LoadFilter.ALL); + IDataReader reader = this.PerformCommand(cmd); + List a_list = agnt_template.LoadList(reader); + foreach (AGNT_Template aTemplate in a_list) + result.Add(aTemplate); + reader.Close(); + } + } + catch(Exception ex) + { + _log.ErrorFormat("Error loading AGNT templates: {0}", ex.Message); + } + return result; + } + #endregion #region internal/private funcs diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj index 99c87c07..61995071 100644 --- a/nsw/Source/bsmd.database/bsmd.database.csproj +++ b/nsw/Source/bsmd.database/bsmd.database.csproj @@ -65,6 +65,7 @@ + diff --git a/nsw/Source/bsmd.database/versions.md b/nsw/Source/bsmd.database/versions.md index 664bb21d..6b7194ca 100644 --- a/nsw/Source/bsmd.database/versions.md +++ b/nsw/Source/bsmd.database/versions.md @@ -5,8 +5,8 @@ ___ # Planung -ENI 6.5.0 - +ENI 6.5.0: Korrektur SEC / AGNT Vorlagen +ReportGenerator 6.5 (wartet auf Freigabe) # Aktuell installiert bei BSMD