diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs index bc9b2fbb..a2cd8534 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs @@ -259,6 +259,23 @@ namespace VEPROMS.CSLA.Library return s; } #endregion + #region DelProcReason + [Category("General")] + [DisplayName("DelProcReason")] + [RefreshProperties(RefreshProperties.All)] + [Description("Delete Procedure Reason")] + public string General_DelProcReason // C2020-038: reason was added when procedure was deleted + { + get + { + return _Xp["General", "DelProcReason"]; + } + set + { + _Xp["General", "DelProcReason"] = value; + } + } + #endregion #region FormatCategory //[TypeConverter(typeof(EnumDescConverter))] //public enum FormatColumns : int diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs index f1b7d3be..f30de3f1 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs @@ -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) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 88cce0d9..7b0c9412 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -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); diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.cs b/PROMS/Volian.Controls.Library/DisplayHistory.cs index 918cf3cd..9aa4fdd5 100644 --- a/PROMS/Volian.Controls.Library/DisplayHistory.cs +++ b/PROMS/Volian.Controls.Library/DisplayHistory.cs @@ -504,7 +504,27 @@ namespace Volian.Controls.Library #region new style if (deletedItems == null) deletedItems = tvAudits.Nodes.Add("Deleted Items"); - TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()); + string strR = null; + // see if a deleted procedure, from itemaudit, get contentaudit + ContentAuditInfoList lDelC = ContentAuditInfoList.GetByDeleteStatus(iai.DeleteStatus); + foreach (ContentAuditInfo delC in lDelC) + { + if (delC.Type >= 0 && delC.Type < 1000) + { + int indx = delC.Config.IndexOf("DelProcReason"); + if (indx >= 0 && delC.Config.Length > indx+15) // 15 accounts for 'DelProcReason = "' + { + string reason = delC.Config.Substring(indx + 15); + if (reason != null && reason.Length > 0) + { + indx = reason.IndexOf("\""); + if (indx > 0) strR = reason.Substring(0, reason.IndexOf("\"")); + } + break; + } + } + } + TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()+"; Reason: " + strR); tnn.Tag = iai; #endregion } diff --git a/PROMS/Volian.Controls.Library/dlgDelProcReason.cs b/PROMS/Volian.Controls.Library/dlgDelProcReason.cs new file mode 100644 index 00000000..e616b2bd --- /dev/null +++ b/PROMS/Volian.Controls.Library/dlgDelProcReason.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace Volian.Controls.Library +{ + // C2020-038: request reason for delete procedure so this can be saved in database + // (a few users said that procedures 'disappeared' but this could not be reproduced) + public partial class dlgDelProcReason : Form + { + vlnTreeView VTreeView; + public dlgDelProcReason(vlnTreeView tv) + { + InitializeComponent(); + this.Text = "Verify Delete By " + Volian.Base.Library.VlnSettings.UserID; + VTreeView = tv; + tbDelProcReason.Focus(); + } + + private void btnOk_Click(object sender, EventArgs e) + { + VTreeView.DelProcReason = tbDelProcReason.Text; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + VTreeView.DelProcReason = null; + } + + private void tbDelProcReason_TextChanged(object sender, EventArgs e) + { + btnYes.Enabled = (tbDelProcReason.Text != null && tbDelProcReason.Text.Length > 0) ; + } + } +} \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/dlgDelProcReason.designer.cs b/PROMS/Volian.Controls.Library/dlgDelProcReason.designer.cs new file mode 100644 index 00000000..0085bb3f --- /dev/null +++ b/PROMS/Volian.Controls.Library/dlgDelProcReason.designer.cs @@ -0,0 +1,115 @@ +namespace Volian.Controls.Library +{ + partial class dlgDelProcReason + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.tbDelProcReason = new System.Windows.Forms.TextBox(); + this.btnYes = new System.Windows.Forms.Button(); + this.btnNo = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(23, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(379, 34); + this.label1.TabIndex = 0; + this.label1.Text = "Are you sure you want to delete this procedure?\r\n A reason must be entered befor" + + "e the delete can be done."; + // + // tbDelProcAnnot + // + this.tbDelProcReason.Location = new System.Drawing.Point(33, 58); + this.tbDelProcReason.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tbDelProcReason.Name = "tbDelProcAnnot"; + this.tbDelProcReason.Size = new System.Drawing.Size(319, 22); + this.tbDelProcReason.TabIndex = 1; + this.tbDelProcReason.TextChanged += new System.EventHandler(this.tbDelProcReason_TextChanged); + // + // btnYes + // + this.btnYes.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnYes.Enabled = false; + this.btnYes.Location = new System.Drawing.Point(191, 88); + this.btnYes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnYes.Name = "btnYes"; + this.btnYes.Size = new System.Drawing.Size(61, 30); + this.btnYes.TabIndex = 2; + this.btnYes.Text = "Yes"; + this.btnYes.UseVisualStyleBackColor = true; + this.btnYes.Click += new System.EventHandler(this.btnOk_Click); + // + // btnNo + // + this.btnNo.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnNo.Location = new System.Drawing.Point(287, 88); + this.btnNo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnNo.Name = "btnNo"; + this.btnNo.Size = new System.Drawing.Size(65, 30); + this.btnNo.TabIndex = 3; + this.btnNo.Text = "No"; + this.btnNo.UseVisualStyleBackColor = true; + this.btnNo.Click += new System.EventHandler(this.btnCancel_Click); + // + // dlgDelProcAnnot + // + this.AcceptButton = this.btnYes; + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnNo; + this.ClientSize = new System.Drawing.Size(405, 129); + this.ControlBox = false; + this.Controls.Add(this.btnNo); + this.Controls.Add(this.btnYes); + this.Controls.Add(this.tbDelProcReason); + this.Controls.Add(this.label1); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(423, 176); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(423, 176); + this.Name = "dlgDelProcAnnot"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Verify Delete"; + this.TopMost = true; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tbDelProcReason; + private System.Windows.Forms.Button btnYes; + private System.Windows.Forms.Button btnNo; + } +} \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/dlgDelProcReason.resx b/PROMS/Volian.Controls.Library/dlgDelProcReason.resx new file mode 100644 index 00000000..d58980a3 --- /dev/null +++ b/PROMS/Volian.Controls.Library/dlgDelProcReason.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 33ac7570..84047f42 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -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 enhIds = new List(); - 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 enhIds = new List(); + // 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) {