From c46881698fad5cdd04ff1af878c534c87d210f10 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sat, 24 Aug 2024 07:19:24 +0200 Subject: [PATCH] Fixed bug and added functionality to BKRD, LADG and WAS_RCPT --- .../ArrivalNotificationDetailControl.xaml.cs | 15 ++++++++---- .../DepartureNotificationDetailControl.xaml | 20 ++++++++++++++-- ...DepartureNotificationDetailControl.xaml.cs | 7 ++++++ .../PortNotificationDetailControl.xaml | 23 +++++++++++++++++-- .../PortNotificationDetailControl.xaml.cs | 9 +++++++- .../WasteDetailControl.xaml | 13 +++++++++-- .../WasteDetailControl.xaml.cs | 10 ++++++-- 7 files changed, 84 insertions(+), 13 deletions(-) diff --git a/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs index 0d916772..7e778cd4 100644 --- a/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs @@ -38,9 +38,9 @@ namespace ENI2.DetailViewControls this.RegisterIntegerUpDownChange(this.integerUpDownCrewMemberOnBoard, Message.NotificationClass.POBA); this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBA); this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBA); - this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA); - startupComplete = true; + this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA); this.dataGridBKRA.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.BKRA); }; + startupComplete = true; } public override void Initialize() @@ -184,6 +184,8 @@ namespace ENI2.DetailViewControls private void DataGridBKRA_CreateRequested() { + this.dataGridBKRA.CancelEdit(); + this.dataGridBKRA.CancelEdit(); EditBKRDialog ebd = new EditBKRDialog(); ebd.BRKA = new BRKA(); ebd.BRKA.Identifier = BRKA.GetNewIdentifier(this._bkraMessage.Elements); @@ -216,6 +218,8 @@ namespace ENI2.DetailViewControls { if (obj is BRKA brka) { + this.dataGridBKRA.CancelEdit(); + this.dataGridBKRA.CancelEdit(); // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brka); this._bkraMessage.Elements.Remove(brka); @@ -226,8 +230,11 @@ namespace ENI2.DetailViewControls } private void DataGridBKRA_EditRequested(DatabaseEntity obj) - { - + { + // I am not shitting you: this has to be called TWICE(!) in a row in order to work + // see: https://stackoverflow.com/questions/20204592/wpf-datagrid-refresh-is-not-allowed-during-an-addnew-or-edititem-transaction-m + this.dataGridBKRA.CancelEdit(); + this.dataGridBKRA.CancelEdit(); EditBKRDialog eld = new EditBKRDialog(); eld.IsDeparture = false; eld.BRKA = obj as BRKA; diff --git a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml index 0c5dd6fa..aff5d676 100644 --- a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml +++ b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml @@ -70,8 +70,24 @@ AutoGenerateColumns="False" Margin="0,5,0,0"> - - + + + + + + + + + + + + + + + + + + diff --git a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs index b639df90..c26de806 100644 --- a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs @@ -40,6 +40,7 @@ namespace ENI2.DetailViewControls this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBD); this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBD); this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBD); + this.dataGridBKRD.CellEditEnding += (obj, ev) => { this.OnNotificationClassChanged(Message.NotificationClass.BKRD); }; startupComplete = true; } @@ -167,6 +168,8 @@ namespace ENI2.DetailViewControls private void DataGridBKRD_CreateRequested() { + this.dataGridBKRD.CancelEdit(); + this.dataGridBKRD.CancelEdit(); EditBKRDialog ebd = new EditBKRDialog(); ebd.IsDeparture = true; ebd.BRKD = new BRKD(); @@ -199,6 +202,8 @@ namespace ENI2.DetailViewControls { if (obj is BRKD brkd) { + this.dataGridBKRD.CancelEdit(); + this.dataGridBKRD.CancelEdit(); // are you sure dialog is in base class this._bkrdMessage.Elements.Remove(brkd); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brkd); @@ -210,6 +215,8 @@ namespace ENI2.DetailViewControls private void DataGridBKRD_EditRequested(DatabaseEntity obj) { + this.dataGridBKRD.CancelEdit(); + this.dataGridBKRD.CancelEdit(); EditBKRDialog eld = new EditBKRDialog(); eld.IsDeparture = true; eld.BRKD = obj as BRKD; diff --git a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml index d8ff8127..62f1dbc3 100644 --- a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml +++ b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml @@ -105,8 +105,27 @@ - - + + + + + + + + + + + + + + + + + + + + + diff --git a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs index df66ee58..0b632902 100644 --- a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs @@ -56,7 +56,7 @@ namespace ENI2.DetailViewControls this.RegisterDoubleUpDownChange(this.doubleUpDownDisplacementSummerDraught, Message.NotificationClass.INFO); this.RegisterTextboxChange(this.textSpecialRequirements, Message.NotificationClass.INFO); this.RegisterTextboxChange(this.textConstructionCharacteristics, Message.NotificationClass.INFO); - + this.dataGridLADG.CellEditEnding += (obj, ev) => { this.OnNotificationClassChanged(Message.NotificationClass.LADG); }; } public override void Initialize() @@ -174,6 +174,8 @@ namespace ENI2.DetailViewControls private void DataGridLADG_CreateRequested() { + this.dataGridLADG.CancelEdit(); + this.dataGridLADG.CancelEdit(); EditLADGDialog eld = new EditLADGDialog(); eld.LADG = new LADG(); eld.LADG.MessageHeader = _ladgMessage; @@ -206,6 +208,8 @@ namespace ENI2.DetailViewControls { if (obj is LADG ladg) { + this.dataGridLADG.CancelEdit(); + this.dataGridLADG.CancelEdit(); // are you sure dialog is in base class this._ladgMessage.Elements.Remove(ladg); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ladg); @@ -217,6 +221,9 @@ namespace ENI2.DetailViewControls private void DataGridLADG_EditRequested(DatabaseEntity obj) { + this.dataGridLADG.CancelEdit(); + this.dataGridLADG.CancelEdit(); + LADG ladg = obj as LADG; EditLADGDialog eld = new EditLADGDialog(); diff --git a/ENI2/DetailViewControls/WasteDetailControl.xaml b/ENI2/DetailViewControls/WasteDetailControl.xaml index 6a02896f..53bfa5f4 100644 --- a/ENI2/DetailViewControls/WasteDetailControl.xaml +++ b/ENI2/DetailViewControls/WasteDetailControl.xaml @@ -196,7 +196,7 @@ - + + + + + + + + + + diff --git a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs index b48102a0..08bb0c24 100644 --- a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs @@ -47,7 +47,7 @@ namespace ENI2.DetailViewControls this.RegisterCheckboxChange(this.checkBoxValidExemption, Message.NotificationClass.WAS); this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS); this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS); - + this.dataGridWasteReceived.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.WAS_RCPT); }; } private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e) @@ -290,7 +290,8 @@ namespace ENI2.DetailViewControls { if (obj is WasteReceived wasteReceived) { - + this.dataGridWasteReceived.CancelEdit(); + this.dataGridWasteReceived.CancelEdit(); // are you sure dialog is in base class _selectedWAS_RCPT.WasteReceived.Remove(wasteReceived); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(wasteReceived); @@ -303,6 +304,8 @@ namespace ENI2.DetailViewControls private void DataGridWasteReceived_CreateRequested() { if (_selectedWAS_RCPT == null) return; + this.dataGridWasteReceived.CancelEdit(); + this.dataGridWasteReceived.CancelEdit(); EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog(); ewrd.WasteReceived = new WasteReceived(); ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT; @@ -336,6 +339,9 @@ namespace ENI2.DetailViewControls private void DataGridWasteReceived_EditRequested(DatabaseEntity obj) { + this.dataGridWasteReceived.CancelEdit(); + this.dataGridWasteReceived.CancelEdit(); + EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog(); ewrd.WasteReceived = obj as WasteReceived;