C2020-038: When deleting a procedure, add a prompt so that user has to enter a reason that is saved to database
This commit is contained in:
@@ -391,6 +391,12 @@ namespace Volian.Controls.Library
|
||||
get { return _MyUserInfo; }
|
||||
set { _MyUserInfo = value; }
|
||||
}
|
||||
private string _DelProcReason; // C2020-038: request reason for delete procedure so this can be saved in database
|
||||
public string DelProcReason
|
||||
{
|
||||
get { return _DelProcReason; }
|
||||
set { _DelProcReason = value; }
|
||||
}
|
||||
#region Local Vars
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -3046,9 +3052,13 @@ namespace Volian.Controls.Library
|
||||
typeDescription = "Folder"; //C2020-026 specific description of what user is trying to delete
|
||||
}
|
||||
//C2020-026 added standardized wording when attempting to delete
|
||||
DialogResult result = FlexibleMessageBox.Show("Are you sure you want to delete this " + typeDescription + "?", "Verify Delete",
|
||||
DialogResult result = DialogResult.No;
|
||||
if (_LastProcedureInfo == null)
|
||||
{
|
||||
result = FlexibleMessageBox.Show("Are you sure you want to delete this " + typeDescription + "?", "Verify Delete",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
}
|
||||
if (_LastProcedureInfo != null || result == DialogResult.Yes)
|
||||
{
|
||||
if (_LastFolderInfo != null)
|
||||
{
|
||||
@@ -3090,27 +3100,41 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else if (_LastProcedureInfo != null)
|
||||
{
|
||||
//If there are enhanced, they will also need deleted, save the ids so that they
|
||||
// can be deleted after this item gets deleted.
|
||||
List<int> enhIds = new List<int>();
|
||||
ProcedureConfig prc = _LastProcedureInfo.MyConfig as ProcedureConfig;
|
||||
foreach (EnhancedDocument ed in prc.MyEnhancedDocuments)
|
||||
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastProcedureInfo)) return false;
|
||||
_LastProcedureInfo = null;
|
||||
foreach (int enhId in enhIds)
|
||||
dlgDelProcReason dlgDPA = new dlgDelProcReason(this); // C2020-038: prompt user for reason
|
||||
DialogResult res = dlgDPA.ShowDialog(this);
|
||||
if (res == DialogResult.OK)
|
||||
{
|
||||
ProcedureInfo pi = ProcedureInfo.Get(enhId);
|
||||
// if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
|
||||
// above will go through user interface code that deletes the enhanced, so 'Get'
|
||||
// will return a null (i.e. the data no longer exists).
|
||||
if (pi != null)
|
||||
//If there are enhanced, they will also need deleted, save the ids so that they
|
||||
// can be deleted after this item gets deleted.
|
||||
List<int> enhIds = new List<int>();
|
||||
// C2020-038: request reason for delete procedure so this can be saved in database
|
||||
ProcedureConfig prc = _LastProcedureInfo.MyConfig as ProcedureConfig;
|
||||
prc.General_DelProcReason = DelProcReason;
|
||||
using (Item itm = Item.Get(_LastProcedureInfo.ItemID))
|
||||
{
|
||||
if (!DeleteItemInfoAndChildren(pi)) Console.WriteLine("do an error log item");
|
||||
itm.MyContent.Config = prc.ToString();
|
||||
itm.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.Save();
|
||||
}
|
||||
foreach (EnhancedDocument ed in prc.MyEnhancedDocuments)
|
||||
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastProcedureInfo)) return false;
|
||||
|
||||
_LastProcedureInfo = null;
|
||||
foreach (int enhId in enhIds)
|
||||
{
|
||||
ProcedureInfo pi = ProcedureInfo.Get(enhId);
|
||||
// if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
|
||||
// above will go through user interface code that deletes the enhanced, so 'Get'
|
||||
// will return a null (i.e. the data no longer exists).
|
||||
if (pi != null)
|
||||
{
|
||||
if (!DeleteItemInfoAndChildren(pi)) Console.WriteLine("do an error log item");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (_LastSectionInfo != null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user