C2026-009 Reset Change Bars to Date of Last Approval

This commit is contained in:
2026-02-11 16:07:33 -05:00
parent 53360a03af
commit 15979203ce
9 changed files with 370 additions and 165 deletions

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();
}
}
}
}
}