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:
2020-10-22 10:21:53 +00:00
parent 1f559a0d12
commit b172dc3080
8 changed files with 370 additions and 20 deletions

View File

@@ -1634,6 +1634,7 @@ namespace VEPROMS.CSLA.Library
// remove the enhanced document link information - fixes delete/restore issue of linked steps.
// B2017-070 - when retoring a step that once had enhanced links, remove the link info for the notes and cautions as well
tmp.RemoveEnhancedFromConfig();
Item.ClearDelProcReason(tmp); // C2020-038: reason was added when procedure was deleted, clear on restore
return tmp;
}
catch (Exception ex)

View File

@@ -2362,6 +2362,7 @@ namespace VEPROMS.CSLA.Library
}
catch (Exception ex)
{
ClearDelProcReason(item); // C2020-038: reason was added when procedure was deleted, but delete failed so remove it
System.Data.SqlClient.SqlException exSQL = SqlException(ex);
if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###"))
throw exSQL;
@@ -2370,6 +2371,19 @@ namespace VEPROMS.CSLA.Library
}
//_MyTimer.ShowElapsedTimes("DeleteItemAndChildren");
}
// C2020-038: reason was added when procedure was deleted, provide a way to remove it if delete failed
public static void ClearDelProcReason(ItemInfo ii)
{
if (!ii.IsProcedure) return;
ProcedureConfig prc = ii.MyConfig as ProcedureConfig;
prc.General_DelProcReason = string.Empty;
using (Item itm = Item.Get(ii.ItemID))
{
itm.MyContent.Config = prc.ToString();
itm.UserID = Volian.Base.Library.VlnSettings.UserID;
itm.Save();
}
}
private static System.Data.SqlClient.SqlException SqlException(Exception ex)
{
Type sqlExType = typeof(System.Data.SqlClient.SqlException);