Compare commits

...

1 Commits

Author SHA1 Message Date
15979203ce C2026-009 Reset Change Bars to Date of Last Approval 2026-02-11 16:07:33 -05:00
9 changed files with 370 additions and 165 deletions

View File

@@ -24533,6 +24533,51 @@ GO
PRINT 'Added IX_tblROUsagesRODbIDDeleteStatusROID Index. Speeds up RO queries'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[GetCurrentApprovedRevisions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [GetCurrentApprovedRevisions];
GO
/****** Object: StoredProcedure [dbo].[GetCurrentApprovedRevisions] Script Date: 02/05/2026 7:54:42 AM ******/
-- =============================================
-- Author: Matthew Schill
-- Create date: 02/05/2026
-- Description: Gets all current approved revisions
-- =============================================
CREATE PROCEDURE [dbo].[GetCurrentApprovedRevisions]
(
@ItemID AS bigint
)
AS
BEGIN
select max(rr.revisionid) revisionid, UnitId, UnitVal.name UnitName, max(rr.DTS) DTS
from items ii
inner join revisions rr on ii.itemid = rr.itemid
inner join versions vv on rr.revisionid = vv.revisionid
inner join stages ss on vv.stageid = ss.stageid
outer apply
(Select UnitId = r1.value('@Index','int') FROM rr.config.nodes('Config/Applicability') t1(r1)) App
left outer join
(select r1.value('@index','int') indx
,r1.value('@Name','varchar') name
from (select *,cast(config as xml) xconfig from DocVersions
where ItemID in(select itemID from vefn_AllSiblingItems(@ItemID))) SDV
cross apply
xconfig.nodes('Config/Slaves/Slave') t1(r1)) UnitVal ON UnitVal.indx = UnitId
where ss.isapproved = 1
and ii.itemid = @ItemID
group by UnitId, UnitVal.name
RETURN
END
IF (@@Error = 0) PRINT 'Procedure Creation: [GetCurrentApprovedRevisions] Succeeded'
ELSE PRINT 'Procedure Creation: [GetCurrentApprovedRevisions] Error on Creation'
GO
/*
---------------------------------------------------------------------------
| ADD New Code Before this Block |
@@ -24566,8 +24611,8 @@ BEGIN TRY -- Try Block
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '02/06/2026 1:00 PM'
set @RevDescription = 'Updated Search Tool to better handle Cautions and Notes at the same level'
set @RevDate = '02/09/2026 7:00 AM'
set @RevDescription = 'Added procedure for getting current revisions'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription

View File

@@ -34,6 +34,7 @@
this.superTooltip1 = new DevComponents.DotNetBar.SuperTooltip();
this.dateTimeInput1 = new DevComponents.Editors.DateTimeAdv.DateTimeInput();
this.btnNow = new DevComponents.DotNetBar.ButtonX();
this.btnResetToApproved = new DevComponents.DotNetBar.ButtonX();
((System.ComponentModel.ISupportInitialize)(this.dateTimeInput1)).BeginInit();
this.SuspendLayout();
//
@@ -142,11 +143,26 @@
this.btnNow.Text = "Today";
this.btnNow.Click += new System.EventHandler(this.btnNow_Click);
//
// btnResetToApproved
//
this.btnResetToApproved.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnResetToApproved.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnResetToApproved.Location = new System.Drawing.Point(30, 77);
this.btnResetToApproved.Name = "btnResetToApproved";
this.btnResetToApproved.Size = new System.Drawing.Size(201, 23);
this.btnResetToApproved.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnResetToApproved.TabIndex = 6;
this.btnResetToApproved.Text = "Reset Change Bar To Approved Date";
this.btnResetToApproved.Tooltip = "Reset Change Bar to the last approved date. If no approvals, reset to as if no ch" +
"ange bar date. After selecting this, press OK to save.";
this.btnResetToApproved.Click += new System.EventHandler(this.btnResetToApproved_Click);
//
// dlgSetChangeBarStartDate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(268, 144);
this.Controls.Add(this.btnResetToApproved);
this.Controls.Add(this.btnNow);
this.Controls.Add(this.dateTimeInput1);
this.Controls.Add(this.label1);
@@ -175,5 +191,6 @@
private DevComponents.DotNetBar.SuperTooltip superTooltip1;
private DevComponents.Editors.DateTimeAdv.DateTimeInput dateTimeInput1;
private DevComponents.DotNetBar.ButtonX btnNow;
private DevComponents.DotNetBar.ButtonX btnResetToApproved;
}
}

View File

@@ -1,31 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using VEPROMS.CSLA.Library;
using Volian.Controls.Library;
namespace VEPROMS
{
public partial class dlgSetChangeBarStartDate : DevComponents.DotNetBar.Office2007Form
{
private ProcedureConfig _MyProcConfig = null;
public ProcedureConfig MyProcConfig { get; set; } = null;
public ProcedureConfig MyProcConfig
{
get { return _MyProcConfig; }
set { _MyProcConfig = value; }
}
public ProcedureInfo MyProcInfo { get; set; } = null;
public dlgSetChangeBarStartDate(ProcedureConfig pc)
public dlgSetChangeBarStartDate(ProcedureConfig pc, ProcedureInfo pi)
{
InitializeComponent();
_MyProcConfig = pc;
MyProcConfig = pc;
MyProcInfo = pi;
}
private void dlgSetChangeBarStartDate_Load(object sender, EventArgs e)
@@ -80,5 +72,65 @@ namespace VEPROMS
dateTimeInput1.Value = DateTime.Now;
}
//C2026-009 Add Option to Reset Change Bar to Last Approved Date/Time
private void btnResetToApproved_Click(object sender, EventArgs e)
{
System.Data.DataTable dt = RevisionData.GetRevisionDataByUnit(MyProcInfo.ItemID);
if (dt.Rows.Count == 0)
{
//no records, remove
if (MessageBox.Show("There are currently no approvals set. Selecting yes will set ChangeBars to show all changes since the creation of the procedure.\r\nAre you sure you wish to reset ChangeBars?", "Reset ChangeBar Date", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
MyProcConfig.Print_ChangeBarDate = "";
DialogResult = DialogResult.OK;
Close();
}
}
else if (RevisionData.HasUnits(dt))
{
//any with units
string maxDTS = RevisionData.MaxDTS(dt).ToString("MM/dd/yyyy HH:mm:ss");
//create wording for ChangeBar changes
StringBuilder sb = new StringBuilder();
sb.Append($" The Procedure Viewer Change Bar Date will be set to ({maxDTS}).");
foreach (DataRow r in dt.Rows)
{
sb.Append($"\r\n The Change Bar Date for Unit ({r["UnitName"]}) will be set to ({Convert.ToDateTime(r["DTS"]):MM/dd/yyyy HH:mm:ss}).");
}
sb.Append("\r\n Any Change Bars for Units not listed above will use the Overall/Procedure Viewer Change Bar Date (as these Units have no approvals).");
if (CustomMessageBox.Show($"This will reset ChangeBars to show for changes newer than the last approval.\r\nThis includes the following changes:\r\n{sb.ToString()}\r\n\r\nAre you sure you wish to reset ChangeBars?", "Reset ChangeBar Date", "Yes", "No") == DialogResult.Yes)
{
//Change the overall ChangeBarDate
MyProcConfig.Print_ChangeBarDate = maxDTS;
//Change the ChangeBarDate for each unit
foreach (DataRow r in dt.Rows)
{
MyProcConfig.SelectedSlave = Convert.ToInt32(r["UnitID"]);
MyProcConfig.Print_ChangeBarDate = Convert.ToDateTime(r["DTS"]).ToString("MM / dd / yyyy HH: mm: ss");
}
MyProcConfig.SelectedSlave = 0;
DialogResult = DialogResult.OK;
Close();
}
}
else
{
//no units
string maxDTS = RevisionData.MaxDTS(dt).ToString("MM/dd/yyyy HH:mm:ss");
if (MessageBox.Show($"This will reset ChangeBars to show for changes newer than the last approval ({maxDTS}).\r\nAre you sure you wish to reset ChangeBars?", "Reset ChangeBar Date", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
MyProcConfig.Print_ChangeBarDate = maxDTS;
DialogResult = DialogResult.OK;
Close();
}
}
}
}
}

View File

@@ -617,7 +617,7 @@ namespace VEPROMS
ProcedureConfig pc = pi.MyConfig as ProcedureConfig;
if (pc == null) return;
dlgSetChangeBarStartDate cbdDlg = new dlgSetChangeBarStartDate(pc);
dlgSetChangeBarStartDate cbdDlg = new dlgSetChangeBarStartDate(pc, pi);
if (cbdDlg.ShowDialog() == DialogResult.OK)
{
using (Item itm = Item.Get(pi.ItemID))

View File

@@ -0,0 +1,53 @@
using Csla.Data;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
//CSM - C2026-009 - Minimal Class for Getting Revision Data
namespace VEPROMS.CSLA.Library
{
public static class RevisionData
{
#region Check Data
//Check if Data Has Units
public static bool HasUnits(DataTable dt) => dt.AsEnumerable().Any(x => x.Field<int?>("UnitID") > 0);
//Get Maximum Date Time Stamp
public static DateTime MaxDTS(DataTable dt) => dt.AsEnumerable().Max(x => x.Field<DateTime>("DTS"));
#endregion
#region Get Revision Data
//CSM - C2026-009 Get Current Revision Data by Unit
public static DataTable GetRevisionDataByUnit(int itemID)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "GetCurrentApprovedRevisions";
cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@ItemID", itemID);
using (SqlDataAdapter da = new SqlDataAdapter(cm))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error in GetRevisionDataByUnit: retrieving data failed", ex);
}
}
#endregion
}
}

View File

@@ -391,6 +391,7 @@
<Compile Include="Minimal\AnnotationstypeSections.cs" />
<Compile Include="Minimal\Maintenance.cs" />
<Compile Include="Minimal\GeneralReports.cs" />
<Compile Include="Minimal\RevisionData.cs" />
<Compile Include="Minimal\UserReports.cs" />
<Compile Include="Minimal\UserSettings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -31,25 +31,32 @@
this.btn1 = new System.Windows.Forms.Button();
this.btn2 = new System.Windows.Forms.Button();
this.lblMessage = new System.Windows.Forms.Label();
this.tableLP1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLP1.SuspendLayout();
this.SuspendLayout();
//
// btn1
//
this.btn1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btn1.AutoSize = true;
this.btn1.Location = new System.Drawing.Point(12, 99);
this.btn1.Location = new System.Drawing.Point(18, 102);
this.btn1.Margin = new System.Windows.Forms.Padding(10);
this.btn1.MinimumSize = new System.Drawing.Size(60, 20);
this.btn1.Name = "btn1";
this.btn1.Size = new System.Drawing.Size(75, 23);
this.btn1.Size = new System.Drawing.Size(60, 20);
this.btn1.TabIndex = 0;
this.btn1.UseVisualStyleBackColor = true;
this.btn1.Click += new System.EventHandler(this.Btn1_Click);
//
// btn2
//
this.btn2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btn2.AutoSize = true;
this.btn2.Location = new System.Drawing.Point(322, 99);
this.btn2.Location = new System.Drawing.Point(335, 102);
this.btn2.Margin = new System.Windows.Forms.Padding(10);
this.btn2.MinimumSize = new System.Drawing.Size(60, 20);
this.btn2.Name = "btn2";
this.btn2.Size = new System.Drawing.Size(75, 23);
this.btn2.Size = new System.Drawing.Size(60, 20);
this.btn2.TabIndex = 1;
this.btn2.UseVisualStyleBackColor = true;
this.btn2.Click += new System.EventHandler(this.Btn2_Click);
@@ -57,24 +64,48 @@
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Location = new System.Drawing.Point(33, 41);
this.tableLP1.SetColumnSpan(this.lblMessage, 2);
this.lblMessage.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblMessage.Location = new System.Drawing.Point(11, 8);
this.lblMessage.MaximumSize = new System.Drawing.Size(413, 0);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(0, 13);
this.lblMessage.Size = new System.Drawing.Size(391, 84);
this.lblMessage.TabIndex = 2;
this.lblMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tableLP1
//
this.tableLP1.AutoSize = true;
this.tableLP1.ColumnCount = 2;
this.tableLP1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLP1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLP1.Controls.Add(this.lblMessage, 0, 0);
this.tableLP1.Controls.Add(this.btn1);
this.tableLP1.Controls.Add(this.btn2);
this.tableLP1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLP1.Location = new System.Drawing.Point(0, 0);
this.tableLP1.MaximumSize = new System.Drawing.Size(413, 0);
this.tableLP1.MinimumSize = new System.Drawing.Size(413, 130);
this.tableLP1.Name = "tableLP1";
this.tableLP1.Padding = new System.Windows.Forms.Padding(8);
this.tableLP1.RowCount = 2;
this.tableLP1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLP1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLP1.Size = new System.Drawing.Size(413, 130);
this.tableLP1.TabIndex = 0;
//
// CustomMessageBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(419, 130);
this.Controls.Add(this.lblMessage);
this.Controls.Add(this.btn2);
this.Controls.Add(this.btn1);
this.Controls.Add(this.tableLP1);
this.Name = "CustomMessageBox";
this.ShowIcon = false;
this.Text = "CustomMessageBox";
this.tableLP1.ResumeLayout(false);
this.tableLP1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -85,5 +116,6 @@
private System.Windows.Forms.Button btn1;
private System.Windows.Forms.Button btn2;
private System.Windows.Forms.Label lblMessage;
private System.Windows.Forms.TableLayoutPanel tableLP1;
}
}

View File

@@ -27,6 +27,10 @@ namespace Volian.Controls.Library
{
btn2.Text = button2Text;
btn2.Visible = true;
//make buttons uniform
btn1.Height = btn2.Height = btn1.Height > btn2.Height ? btn1.Height : btn2.Height;
btn1.Width = btn2.Width = btn1.Width > btn2.Width ? btn1.Width : btn2.Width;
}
else
{

View File

@@ -462,6 +462,7 @@
</EmbeddedResource>
<EmbeddedResource Include="CustomMessageBox.resx">
<DependentUpon>CustomMessageBox.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DisplayBookMarks.resx">
<DependentUpon>DisplayBookMarks.cs</DependentUpon>