|
@@ -39,8 +39,13 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
private IDynamicDataGrid? _grid;
|
|
|
|
|
|
private Type? _selectedType;
|
|
|
+
|
|
|
+ // The id of the entity currently being edited.
|
|
|
private Guid _entityID;
|
|
|
+ // The id of the entity we selected from the grid, as it was when we selected it; this is to cancel, because the lookup for the item
|
|
|
+ // updates _entityID, and we need to set it back when cancelling.
|
|
|
private Guid _originalID;
|
|
|
+
|
|
|
private bool _processenabled;
|
|
|
|
|
|
private Entity? _entity;
|
|
@@ -56,10 +61,10 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
if(_isChanged != value)
|
|
|
{
|
|
|
_isChanged = value;
|
|
|
- Editor.HideButtons = !value;// (_entity?.IsChanged() != true) && (_originalID == _entityID);
|
|
|
+ Editor.HideButtons = !value;
|
|
|
if (_process != null)
|
|
|
- _process.IsEnabled = value;// ((_entity?.ID ?? Guid.Empty) != Guid.Empty) || (_entity?.IsChanged() != false);
|
|
|
- _documents._dataEntryGrid.IsEnabled = !value;// (_entity?.IsChanged() != true) && (_originalID == _entityID);
|
|
|
+ _process.IsEnabled = value;
|
|
|
+ _documents._dataEntryGrid.IsEnabled = !value;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -73,12 +78,10 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
|
|
|
if (_selectedType != null)
|
|
|
{
|
|
|
- ClearEditor();
|
|
|
CreateEditor();
|
|
|
PopulateEditor();
|
|
|
//LoadPopup();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void ScanPanel_OnSelectScan(string appliesto, Guid entityid, bool processenabled)
|
|
@@ -174,6 +177,11 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
var result = MessageBox.Show("You have changes that have not been saved; do you wish to save these changes?", "Save Changes?", MessageBoxButton.YesNoCancel);
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
{
|
|
|
+ if (!Editor.Validate())
|
|
|
+ {
|
|
|
+ cancel.Cancel = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
DoSave(false);
|
|
|
if (!cancel.Cancel)
|
|
|
MessageBox.Show("Item saved.");
|
|
@@ -249,7 +257,7 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
Editor.OnCancel += () =>
|
|
|
{
|
|
|
_entityID = _originalID;
|
|
|
- Select(_selectedType,_entityID);
|
|
|
+ Select(_selectedType, _entityID);
|
|
|
};
|
|
|
Editor.OnChanged += (sender, args) => IsChanged = true;
|
|
|
|
|
@@ -340,7 +348,7 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
}
|
|
|
|
|
|
var doc = (IEntityDocument)Activator.CreateInstance(doctype)!;
|
|
|
- CoreUtils.SetPropertyValue(doc,"EntityLink.ID",_entityID);
|
|
|
+ CoreUtils.SetPropertyValue(doc, "EntityLink.ID", _entityID);
|
|
|
doc.DocumentLink.ID = dataEntryDocument.Document.ID;
|
|
|
doc.Thumbnail = dataEntryDocument.Thumbnail;
|
|
|
ClientFactory.CreateClient(doctype).Save(doc,"Added from Data Entry Screen");
|
|
@@ -352,11 +360,12 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
var cancel = new System.ComponentModel.CancelEventArgs();
|
|
|
if (markasprocessed && (_entity is IDataEntryInstance scannable))
|
|
|
scannable.DataEntered = DateTime.Now;
|
|
|
- Editor.SaveItem(cancel);
|
|
|
+ Editor.SaveItem(cancel, validate: false);
|
|
|
|
|
|
if (!cancel.Cancel)
|
|
|
{
|
|
|
_originalID = _entityID;
|
|
|
+ _entityID = _entity.ID;
|
|
|
IsChanged = false;
|
|
|
var row = _documents._dataEntryGrid.SelectedRows.FirstOrDefault();
|
|
|
if (row != null)
|
|
@@ -410,7 +419,13 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
|
|
|
Padding = new Thickness(10, 0, 10, 0),
|
|
|
IsEnabled = _processenabled
|
|
|
};
|
|
|
- _process.Click += (sender, args) => DoSave(true);
|
|
|
+ _process.Click += (sender, args) =>
|
|
|
+ {
|
|
|
+ if (Editor.Validate())
|
|
|
+ {
|
|
|
+ DoSave(true);
|
|
|
+ }
|
|
|
+ };
|
|
|
Editor.AddButton(_process);
|
|
|
IsChanged = false;
|
|
|
|