diff --git a/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs index 142fae87..9fff4639 100644 --- a/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs +++ b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs @@ -91,6 +91,19 @@ namespace ENI2.Controls } } + public bool IsCancelled + { + private get { return false; } + set + { + if (value) + { + this.textBlock.Foreground = Brushes.Gray; + this.textBlock.Background = Brushes.LightGray; + } + } + } + public void SetHeaderText(string headerText, bool lockedTab) { // Container for header controls diff --git a/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs b/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs index 65dbb705..561645b5 100644 --- a/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs +++ b/ENI-2/ENI2/ENI2/Controls/ENIDataGrid.cs @@ -18,7 +18,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using bsmd.database; - +using System.Windows.Controls.Primitives; namespace ENI2.Controls { @@ -118,6 +118,48 @@ namespace ENI2.Controls } + #region public + + public DataGridRow GetRow(int index) + { + DataGridRow row = (DataGridRow)this.ItemContainerGenerator.ContainerFromIndex(index); + if(row == null) + { + this.UpdateLayout(); + this.ScrollIntoView(this.Items[index]); + row = (DataGridRow)this.ItemContainerGenerator.ContainerFromIndex(index); + } + return row; + } + + public DataGridCell GetCell(DataGridRow row, int column) + { + if (row != null) + { + DataGridCellsPresenter presenter = GetVisualChild(row); + + if (presenter == null) + { + this.ScrollIntoView(row, this.Columns[column]); + presenter = GetVisualChild(row); + } + + DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column); + return cell; + } + return null; + } + + public DataGridCell GetCell(int rowIndex, int columnIndex) + { + DataGridRow row = this.GetRow(rowIndex); + return this.GetCell(row, columnIndex); + } + + #endregion + + #region protected + protected void addItem(object sender, RoutedEventArgs e) { if (!this.IsReadOnly) @@ -182,6 +224,10 @@ namespace ENI2.Controls } } + #endregion + + #region private + private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender != null) @@ -197,6 +243,31 @@ namespace ENI2.Controls } } + #endregion + + #region private static + + private static T GetVisualChild(Visual parent) where T : Visual + { + T child = default(T); + int numVisuals = VisualTreeHelper.GetChildrenCount(parent); + for (int i = 0; i < numVisuals; i++) + { + Visual v = (Visual)VisualTreeHelper.GetChild(parent, i); + child = v as T; + if (child == null) + { + child = GetVisualChild(v); + } + if (child != null) + { + break; + } + } + return child; + } + + #endregion } } diff --git a/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml b/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml new file mode 100644 index 00000000..4ff8dbcf --- /dev/null +++ b/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml.cs b/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml.cs new file mode 100644 index 00000000..bdcfbc7d --- /dev/null +++ b/ENI-2/ENI2/ENI2/Controls/RuleControl.xaml.cs @@ -0,0 +1,95 @@ +// Copyright (c) 2017 schick Informatik +// Description: Liste der Validierungsregeln +// + +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; + +using bsmd.database; +using ENI2.EditControls; + +namespace ENI2.Controls +{ + /// + /// Interaction logic for RuleControl.xaml + /// + public partial class RuleControl : UserControl + { + public RuleControl() + { + InitializeComponent(); + Loaded += RuleControl_Loaded; + } + + public List ValidationRules { get; set; } + + public ReportingParty UserEntity { get; set; } + + private void RuleControl_Loaded(object sender, RoutedEventArgs e) + { + this.dataGridValidationRules.Initialize(); + this.dataGridValidationRules.ItemsSource = this.ValidationRules; + + this.dataGridValidationRules.CreateRequested += DataGridValidationRules_CreateRequested; + this.dataGridValidationRules.AddingNewItem += DataGridValidationRules_AddingNewItem; + this.dataGridValidationRules.EditRequested += DataGridValidationRules_EditRequested; + this.dataGridValidationRules.DeleteRequested += DataGridValidationRules_DeleteRequested; + } + + private void DataGridValidationRules_DeleteRequested(bsmd.database.DatabaseEntity obj) + { + bsmd.database.ValidationRule vr = obj as bsmd.database.ValidationRule; + if (vr != null) + { + DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(vr); + this.ValidationRules.Remove(vr); + this.dataGridValidationRules.Items.Refresh(); + } + } + + private void DataGridValidationRules_EditRequested(bsmd.database.DatabaseEntity obj) + { + bsmd.database.ValidationRule vr = obj as bsmd.database.ValidationRule; + if (vr != null) + { + EditRulesDialog eld = new EditRulesDialog(); + eld.ValidationRule = vr; + + if (eld.ShowDialog() ?? false) + { + if (!vr.IsNew) + { + vr.Changed = DateTime.Now; + vr.ChangedBy = this.UserEntity.Logon; + } + DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(vr); + this.dataGridValidationRules.Items.Refresh(); + } + } + } + + private void DataGridValidationRules_AddingNewItem(object sender, AddingNewItemEventArgs e) + { + this.DataGridValidationRules_CreateRequested(); + } + + private void DataGridValidationRules_CreateRequested() + { + bsmd.database.ValidationRule vr = new bsmd.database.ValidationRule(); + vr.Created = DateTime.Now; + vr.CreatedBy = this.UserEntity.Logon; + + EditRulesDialog erd = new EditRulesDialog(); + erd.ValidationRule = vr; + + if (erd.ShowDialog() ?? false) + { + DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(vr); + this.ValidationRules.Add(vr); + this.dataGridValidationRules.Items.Refresh(); + } + } + } +} diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs index 9abc39a7..631b2753 100644 --- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs @@ -138,7 +138,7 @@ namespace ENI2 detailControl.Initialize(); detailControl.IsEnabled = !this.LockedByOtherUser; - if (!detailControl.IsEnabled && (detailControl is OverViewDetailControl)) + if (!detailControl.IsEnabled && (detailControl is OverViewDetailControl) && !(_core.Cancelled ?? false)) ((OverViewDetailControl)detailControl).ShowLockedBy(this.LockedBy); controlCache.Add(mg.MessageGroupName, detailControl); diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml index 06a13a57..be8ebd79 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml @@ -37,9 +37,9 @@ - - - + + + diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml index 89c384de..1b157f50 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml @@ -33,7 +33,7 @@ - + - + diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml index 224aa0ed..584bd4fc 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml @@ -35,6 +35,7 @@ + @@ -105,9 +106,10 @@ --> +