From b83ec3520b9258470e154878ffd3b39b95eb1609 Mon Sep 17 00:00:00 2001 From: Chris Glavan Date: Mon, 2 Oct 2023 09:03:15 -0400 Subject: [PATCH 1/6] C2023-017: Added logic to filter the format list when selecting a format to be applied to a section --- .../frmProcedureProperties.cs | 1572 +++++++++-------- .../Generated/FormatInfo.cs | 11 + 2 files changed, 822 insertions(+), 761 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs index e547945f..f373df6d 100644 --- a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs +++ b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs @@ -11,74 +11,77 @@ using DescriptiveEnum; using DevComponents.DotNetBar; using DevComponents.DotNetBar.Controls; using Volian.Controls.Library; +using System.Xml; +using Csla; namespace VEPROMS { - public partial class frmProcedureProperties : DevComponents.DotNetBar.Office2007Form - { - private bool _Initializing = false; - private string _DefaultFormatName = null; - //private string _DefaultPagination = null; - private string _DefaultWatermark = null; - private string _DefaultChgBarType = null; - private string _DefaultChgBarLoc = null; - private string _DefaultChgBarText = null; - private string _DefaultChgBarUsrMsg1 = null; - private string _DefaultChgBarUsrMsg2 = null; - private string _DefaultFormatColumns = null; - private bool _DefaultDisableDuplex = false; - private ProcedureConfig _ProcedureConfig; - private StepTabRibbon _MyStepTabRibbon; + public partial class frmProcedureProperties : DevComponents.DotNetBar.Office2007Form + { + private readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private bool _Initializing = false; + private string _DefaultFormatName = null; + //private string _DefaultPagination = null; + private string _DefaultWatermark = null; + private string _DefaultChgBarType = null; + private string _DefaultChgBarLoc = null; + private string _DefaultChgBarText = null; + private string _DefaultChgBarUsrMsg1 = null; + private string _DefaultChgBarUsrMsg2 = null; + private string _DefaultFormatColumns = null; + private bool _DefaultDisableDuplex = false; + private ProcedureConfig _ProcedureConfig; + private StepTabRibbon _MyStepTabRibbon; - public frmProcedureProperties(ProcedureConfig procedureConfig) - { - _ProcedureConfig = procedureConfig; - _Initializing = true; - InitializeComponent(); - btnGeneral.PerformClick(); // always start with General tab or button - _Initializing = false; - // build the title bar caption - //this.Text = string.Format("{0} {1} Properties", procedureConfig.Number, procedureConfig.Title); - ItemInfo itmInfo = ItemInfo.Get(_ProcedureConfig.MyProcedure.ItemID); - this.Text = string.Format("{0} {1} Properties", itmInfo.DisplayNumber, itmInfo.DisplayText); - ppProcTitleStpRTB.Font = ppProcTitleStpRTB.FormatFont = new System.Drawing.Font("Microsoft Sans Serif", 10F); - ppProcTitleStpRTB.FieldToEdit = E_FieldToEdit.Text; - ppProcTitleStpRTB.BorderStyle = BorderStyle.Fixed3D; - ppProcTitleStpRTB.MyItemInfo = itmInfo; - ppProcTitleStpRTB.RefreshDisplay(true); - ppProcNumStpRTB.Font = ppProcNumStpRTB.FormatFont = new System.Drawing.Font("Microsoft Sans Serif", 10F); - ppProcNumStpRTB.FieldToEdit = E_FieldToEdit.Number; - ppProcNumStpRTB.BorderStyle = BorderStyle.Fixed3D; - ppProcNumStpRTB.MyItemInfo = itmInfo; - ppProcNumStpRTB.RefreshDisplay(true); + public frmProcedureProperties(ProcedureConfig procedureConfig) + { + _ProcedureConfig = procedureConfig; + _Initializing = true; + InitializeComponent(); + btnGeneral.PerformClick(); // always start with General tab or button + _Initializing = false; + // build the title bar caption + //this.Text = string.Format("{0} {1} Properties", procedureConfig.Number, procedureConfig.Title); + ItemInfo itmInfo = ItemInfo.Get(_ProcedureConfig.MyProcedure.ItemID); + this.Text = string.Format("{0} {1} Properties", itmInfo.DisplayNumber, itmInfo.DisplayText); + ppProcTitleStpRTB.Font = ppProcTitleStpRTB.FormatFont = new System.Drawing.Font("Microsoft Sans Serif", 10F); + ppProcTitleStpRTB.FieldToEdit = E_FieldToEdit.Text; + ppProcTitleStpRTB.BorderStyle = BorderStyle.Fixed3D; + ppProcTitleStpRTB.MyItemInfo = itmInfo; + ppProcTitleStpRTB.RefreshDisplay(true); + ppProcNumStpRTB.Font = ppProcNumStpRTB.FormatFont = new System.Drawing.Font("Microsoft Sans Serif", 10F); + ppProcNumStpRTB.FieldToEdit = E_FieldToEdit.Number; + ppProcNumStpRTB.BorderStyle = BorderStyle.Fixed3D; + ppProcNumStpRTB.MyItemInfo = itmInfo; + ppProcNumStpRTB.RefreshDisplay(true); - _MyStepTabRibbon = new StepTabRibbon(); - //_MyStepTabRibbon.Dock = System.Windows.Forms.DockStyle.Top; - //_MyStepTabRibbon.Location = new System.Drawing.Point(0, 0); - _MyStepTabRibbon.Name = "displayTabRibbon1"; - _MyStepTabRibbon.Visible = false; - //defaultSettingsVisiblity(); - } + _MyStepTabRibbon = new StepTabRibbon(); + //_MyStepTabRibbon.Dock = System.Windows.Forms.DockStyle.Top; + //_MyStepTabRibbon.Location = new System.Drawing.Point(0, 0); + _MyStepTabRibbon.Name = "displayTabRibbon1"; + _MyStepTabRibbon.Visible = false; + //defaultSettingsVisiblity(); + } - private void ppBtnOK_Click(object sender, EventArgs e) - { - procedureConfigBindingSource.EndEdit(); - // Save Default settings for User - // - // Save whether we should display the default values on this property page - Settings.Default.ShowDefaultProcedureProp = ppCbShwDefSettings.Checked; - Settings.Default.Save(); - _ProcedureConfig.Print_NotInMergeAll = cbNotIncludeInMerged.Checked; - _ProcedureConfig.MyProcedure.Save().Dispose(); - SaveText(ppProcTitleStpRTB); - SaveText(ppProcNumStpRTB); - _ProcedureConfig.MyProcedure.MyProcedureInfo.CreateEnhanced = cbEnhanced.Checked; + private void ppBtnOK_Click(object sender, EventArgs e) + { + procedureConfigBindingSource.EndEdit(); + // Save Default settings for User + // + // Save whether we should display the default values on this property page + Settings.Default.ShowDefaultProcedureProp = ppCbShwDefSettings.Checked; + Settings.Default.Save(); + _ProcedureConfig.Print_NotInMergeAll = cbNotIncludeInMerged.Checked; + _ProcedureConfig.MyProcedure.Save().Dispose(); + SaveText(ppProcTitleStpRTB); + SaveText(ppProcNumStpRTB); + _ProcedureConfig.MyProcedure.MyProcedureInfo.CreateEnhanced = cbEnhanced.Checked; // if there is a change to the format, clean up any overridden formats that point to the selected item before saving the format change: // To determine a change to the format, first see if selection changed in list and then see if the format selected does not match // what was set on procedure, if necessary resolve for an inherited format. - if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null && + if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null && _ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat.FormatID != _cmbxformatOriginal) { // clean up & then refresh the configs @@ -96,728 +99,775 @@ namespace VEPROMS } } } - DialogResult = DialogResult.OK; - this.Close(); - } - public void SaveText(StepRTB myStepRTB) - { - if (myStepRTB.ReadOnly) return; - if (!myStepRTB.ActiveMode) return; - if (!myStepRTB.IsDirty && myStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; - bool success = myStepRTB.OrigDisplayText.Save((RichTextBox)myStepRTB); - if (success) - { - myStepRTB.FindAllLinks(); - myStepRTB.OrigRTF = myStepRTB.Rtf; - myStepRTB.ClearUndo(); - } - } - private void ppBtnCancel_Click(object sender, EventArgs e) - { - procedureConfigBindingSource.CancelEdit(); - _ProcedureConfig.MyProcedure.MyProcedureInfo.CreateEnhanced = false; - this.DialogResult = DialogResult.Cancel; - this.Close(); - } + DialogResult = DialogResult.OK; + this.Close(); + } + public void SaveText(StepRTB myStepRTB) + { + if (myStepRTB.ReadOnly) return; + if (!myStepRTB.ActiveMode) return; + if (!myStepRTB.IsDirty && myStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; + bool success = myStepRTB.OrigDisplayText.Save((RichTextBox)myStepRTB); + if (success) + { + myStepRTB.FindAllLinks(); + myStepRTB.OrigRTF = myStepRTB.Rtf; + myStepRTB.ClearUndo(); + } + } + private void ppBtnCancel_Click(object sender, EventArgs e) + { + procedureConfigBindingSource.CancelEdit(); + _ProcedureConfig.MyProcedure.MyProcedureInfo.CreateEnhanced = false; + this.DialogResult = DialogResult.Cancel; + this.Close(); + } - /// - /// Use the ParentLookup to grab the default values - /// - set the watermark property (where applicable) of the control with that value - /// - set the default setting labels with that value - /// ** the default setting labels appear when the Show Default Values checkbox is checked by the user. - /// - private void FindDefaultValues() - { - _ProcedureConfig.ParentLookup = true; - // Get the default format name - _DefaultFormatName = _ProcedureConfig.DefaultFormatSelection; - SetupDefault(_DefaultFormatName, ppLblFormatDefault, ppCmbxFormat); - // Get the default Change Bar Type - _DefaultChgBarType = _ProcedureConfig.Print_ChangeBar.ToString(); - SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBar), ppLblChangeBarTypeDefault, ppCmbxChangeBarType); + /// + /// Use the ParentLookup to grab the default values + /// - set the watermark property (where applicable) of the control with that value + /// - set the default setting labels with that value + /// ** the default setting labels appear when the Show Default Values checkbox is checked by the user. + /// + private void FindDefaultValues() + { + _ProcedureConfig.ParentLookup = true; + // Get the default format name + _DefaultFormatName = _ProcedureConfig.DefaultFormatSelection; + SetupDefault(_DefaultFormatName, ppLblFormatDefault, ppCmbxFormat); + // Get the default Change Bar Type + _DefaultChgBarType = _ProcedureConfig.Print_ChangeBar.ToString(); + SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBar), ppLblChangeBarTypeDefault, ppCmbxChangeBarType); - // Get the default Change Bar Location - _DefaultChgBarLoc = _ProcedureConfig.Print_ChangeBarLoc.ToString(); - SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBarLoc), ppLblChgBarPosDefault, ppCmbxChgBarPos); + // Get the default Change Bar Location + _DefaultChgBarLoc = _ProcedureConfig.Print_ChangeBarLoc.ToString(); + SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBarLoc), ppLblChgBarPosDefault, ppCmbxChgBarPos); - // Get the default Change Bar text - _DefaultChgBarText = _ProcedureConfig.Print_ChangeBarText.ToString(); - SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBarText), ppLblChgBarTxtTypeDefault, ppCmbxChgBarTxtType); + // Get the default Change Bar text + _DefaultChgBarText = _ProcedureConfig.Print_ChangeBarText.ToString(); + SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_ChangeBarText), ppLblChgBarTxtTypeDefault, ppCmbxChgBarTxtType); - // Get the default User Change Bar Message 1 - _DefaultChgBarUsrMsg1 = _ProcedureConfig.Print_UserCBMess1; - if (!(_DefaultChgBarUsrMsg1.Equals(""))) - ppLblChgBarUserMsgOneDefault.Text = string.Format("({0})", _DefaultChgBarUsrMsg1); + // Get the default User Change Bar Message 1 + _DefaultChgBarUsrMsg1 = _ProcedureConfig.Print_UserCBMess1; + if (!(_DefaultChgBarUsrMsg1.Equals(""))) + ppLblChgBarUserMsgOneDefault.Text = string.Format("({0})", _DefaultChgBarUsrMsg1); - // Get the default User Change Bar Message 2 - _DefaultChgBarUsrMsg2 = _ProcedureConfig.Print_UserCBMess2; - if (!(_DefaultChgBarUsrMsg2.Equals(""))) - ppLblChgBarUserMsgTwoDefault.Text = string.Format("({0})", _DefaultChgBarUsrMsg2); + // Get the default User Change Bar Message 2 + _DefaultChgBarUsrMsg2 = _ProcedureConfig.Print_UserCBMess2; + if (!(_DefaultChgBarUsrMsg2.Equals(""))) + ppLblChgBarUserMsgTwoDefault.Text = string.Format("({0})", _DefaultChgBarUsrMsg2); - // Get the default Print Pagination - //_DefaultPagination = _ProcedureConfig.Print_Pagination.ToString(); - //SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_Pagination), ppLblPaginationDefault, ppCmbxPagination); + // Get the default Print Pagination + //_DefaultPagination = _ProcedureConfig.Print_Pagination.ToString(); + //SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_Pagination), ppLblPaginationDefault, ppCmbxPagination); - // Get the default Watermark - _DefaultWatermark = _ProcedureConfig.Print_Watermark.ToString(); - SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_Watermark), ppLblWatermarkDefault, ppCmbxWatermark); + // Get the default Watermark + _DefaultWatermark = _ProcedureConfig.Print_Watermark.ToString(); + SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Print_Watermark), ppLblWatermarkDefault, ppCmbxWatermark); - // Get the default Format Columns - _DefaultFormatColumns = _ProcedureConfig.Format_Columns.ToString(); - SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Format_Columns), ppLblStpEditorColsDefault, ppCmbxStpEditorCols); + // Get the default Format Columns + _DefaultFormatColumns = _ProcedureConfig.Format_Columns.ToString(); + SetupDefault(EnumDescConverter.GetEnumDescription(_ProcedureConfig.Format_Columns), ppLblStpEditorColsDefault, ppCmbxStpEditorCols); - // Get the default Disable Duplex - _DefaultDisableDuplex = _ProcedureConfig.Print_DisableDuplex; - ppLblAutoDuplexDefault.Text = string.Format("(Duplex {0})", (_DefaultDisableDuplex) ? "OFF" : "ON"); + // Get the default Disable Duplex + _DefaultDisableDuplex = _ProcedureConfig.Print_DisableDuplex; + ppLblAutoDuplexDefault.Text = string.Format("(Duplex {0})", (_DefaultDisableDuplex) ? "OFF" : "ON"); - _ProcedureConfig.ParentLookup = false; - } + _ProcedureConfig.ParentLookup = false; + } private int? _cmbxformatOriginal = null; - private void frmProcedureProperties_Load(object sender, EventArgs e) - { - _Initializing = true; - procedureConfigBindingSource.DataSource = _ProcedureConfig; + private void frmProcedureProperties_Load(object sender, EventArgs e) + { + _Initializing = true; + procedureConfigBindingSource.DataSource = _ProcedureConfig; - //formatInfoListBindingSource.DataSource = FormatInfoList.Get(); + //formatInfoListBindingSource.DataSource = FormatInfoList.Get(); - ppCmbxFormat.DataSource = null; - ppCmbxFormat.DisplayMember = "FullName"; - ppCmbxFormat.ValueMember = "FullName"; - ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList; + ppCmbxFormat.DataSource = null; + ppCmbxFormat.DisplayMember = "FullName"; + ppCmbxFormat.ValueMember = "FullName"; + + //C2023-017: Retrieves a filtered list of formats for the current plant + ppCmbxFormat.DataSource = PopulateFormatList(FormatInfoList.SortedFormatInfoList); if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null) _cmbxformatOriginal = _ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat.FormatID; if (_ProcedureConfig.FormatSelection != null) ppCmbxFormat.SelectedValue = _ProcedureConfig.FormatSelection; else ppCmbxFormat.SelectedIndex = -1; - // Get the saved settings for this user - // - // This setting tells us if we should display the default values on this property page - ppCbShwDefSettings.Checked = (Settings.Default["ShowDefaultProcedureProp"] != null) ? Settings.Default.ShowDefaultProcedureProp : false; - - // Get the User's property page style "PropPageStyle" (this is a system wide user setting) - // 1 - Button Dialog (default) - // 2 - Tab Dialog - if ((int)Settings.Default["PropPageStyle"] == (int)PropPgStyle.Tab) - { - tcProcProp.TabsVisible = true; - panProcBtns.Visible = false; - this.Width -= panProcBtns.Width; - } - - // Get the default values for the property page information - FindDefaultValues(); - - // if we are creating a new procedure, initially set the format to the default format - if (_ProcedureConfig.CreatingNew)// .FormatSelection == null) - ppCmbxFormat.SelectedValue = _ProcedureConfig.DefaultFormatSelection; - - // Assign the data sources to the combo boxes - ppCmbxChgBarPos.DataSource = EnumDetail.Details(); - ppCmbxChgBarPos.DisplayMember = "Description"; - ppCmbxChgBarPos.ValueMember = "EValue"; - ppCmbxChgBarPos.SelectedIndex = -1; - - ppCmbxChgBarTxtType.DataSource = EnumDetail.Details(); - ppCmbxChgBarTxtType.DisplayMember = "Description"; - ppCmbxChgBarTxtType.ValueMember = "EValue"; - ppCmbxChgBarTxtType.SelectedIndex = -1; - - ppCmbxChangeBarType.DataSource = EnumDetail.Details(); - ppCmbxChangeBarType.DisplayMember = "Description"; - ppCmbxChangeBarType.ValueMember = "EValue"; - ppCmbxChangeBarType.SelectedIndex = -1; - - //ppCmbxPagination.DataSource = EnumDetail.Details(); - //ppCmbxPagination.DisplayMember = "Description"; - //ppCmbxPagination.ValueMember = "EValue"; - //ppCmbxPagination.SelectedIndex = -1; - - ppCmbxWatermark.DataSource = EnumDetail.Details(); - ppCmbxWatermark.DisplayMember = "Description"; - ppCmbxWatermark.ValueMember = "EValue"; - ppCmbxWatermark.SelectedIndex = -1; - - ppCmbxStpEditorCols.DataSource = EnumDetail.Details(); - ppCmbxStpEditorCols.DisplayMember = "Description"; - ppCmbxStpEditorCols.ValueMember = "EValue"; - ppCmbxStpEditorCols.SelectedIndex = -1; - - // the only time the create enhanced checkbox is visisble is if this is a 'New' procedure in a set that is the 'Source'. - cbEnhanced.Visible = false; - DocVersionConfig dvc = _ProcedureConfig.MyProcedure.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig; - if (_ProcedureConfig.CreatingNew && dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0 && dvc.MyEnhancedDocuments[0].Type != 0) - cbEnhanced.Visible = true; - cbNotIncludeInMerged.Checked = _ProcedureConfig.Print_NotInMergeAll; - _Initializing = false; - - } - - #region General tab - - /// - /// This is the General button used on the button interface design - /// - /// object - /// EventArgs - private void btnGeneral_Click(object sender, EventArgs e) - { - ProcessButtonClick(tiGeneral, btnGeneral); - } - - /// - /// Selection in Default Column Mode combo box changed. - /// - /// object - /// EventArgs - private void ppCmbxStpEditorCols_SelectedValueChanged(object sender, EventArgs e) - { - if (!_Initializing) - { - FormatColumns fc = (FormatColumns)Enum.Parse(typeof(FormatColumns), _DefaultFormatColumns); - ProcessCmbxSelectionEnumChanged(ppCmbxStpEditorCols, fc, ppBtnDefEdCols, ppLblStpEditorColsDefault); - //if ((ppCmbxStpEditorCols.SelectedIndex != -1) && ppCmbxStpEditorCols.SelectedValue.Equals(fc)) - //{ - // ppBtnDefEdCols.Focus(); - // ppBtnDefEdCols.PerformClick(); - //} - //ppBtnDefEdCols.Visible = ppCmbxStpEditorCols.SelectedValue != null; - //ppLblStpEditorColsDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefEdCols.Visible; - //tcpGeneral.Focus(); - } - } - #endregion - - #region Format Settings tab - - /// - /// This is the Format Settings button used on the button interface design - /// - /// object - /// EventArgs - private void btnFmtStngs_Click(object sender, EventArgs e) - { - ProcessButtonClick(tiFmtStngs, btnFmtStngs); - // added for code change C2017-004 - select default format in dropdown list - if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section is set to the default format) - } - - private void ppBtnDefaultFmt_Click(object sender, EventArgs e) - { - ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting - //tcpFormatSettings.Focus(); - } - - // Commented out as part of code change C2017-004. this also makes it consistent with section properties - /// - /// Selection in Format combo box changed. - /// - /// object - /// EventArgs - //private void ppCmbxFormat_SelectedValueChanged(object sender, EventArgs e) - //{ - // ProcessCmbxSelectedValueChange(ppCmbxFormat, _DefaultFormatName, ppBtnDefaultFmt, ppLblFormatDefault); - //} - - /// - /// Enable or disable the user specified change bar options base on the type - /// of change bar selected. - /// - private void setEnabledUserSpecifiedChgBarCombos(PrintChangeBar pcb) - { - //ppGpbxUserSpecCB.Enabled = - //ppCmbxChgBarPos.Enabled = - //ppCmbxChgBarTxtType.Enabled = - //ppBtnDefaultCbPos.Enabled = - //ppBtnDefCbTxtTyp.Enabled = (ppCmbxChangeBarType.SelectedValue != null && - // ppCmbxChangeBarType.SelectedValue.Equals(ProcedureConfig.PrintChangeBar.WithUserSpecified)) || - // (ppCmbxChangeBarType.SelectedValue == null && pcb.Equals(DocVersionConfig.PrintChangeBar.WithUserSpecified)); - - ppGpbxUserSpecCB.Enabled = (ppCmbxChangeBarType.SelectedValue != null && - ppCmbxChangeBarType.SelectedValue.Equals(PrintChangeBar.WithUserSpecified)) || - (ppCmbxChangeBarType.SelectedValue == null && pcb.Equals(PrintChangeBar.WithUserSpecified)); - } - - /// - /// Selection in Change Bar combo box changed. - /// - /// object - /// EventArgs - private void ppCmbxChangeBarType_SelectedValueChanged(object sender, EventArgs e) - { - //Console.WriteLine("### SelectedValueChanged"); - if (!_Initializing) - { - PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType); - ProcessCmbxSelectionEnumChanged(ppCmbxChangeBarType, pcb, ppBtnDefaultChgBar, ppLblChangeBarTypeDefault); - setEnabledUserSpecifiedChgBarCombos(pcb); - //tcpFormatSettings.Focus(); - } - } - - /// - /// Reset to the parent setting. - /// Find the parent setting and assign it to _ProcedureConfig.PrintChangeBar. - /// This will force the database to be updated. - /// - /// - /// - private void ppBtnDefaultChgBar_Click(object sender, EventArgs e) - { - // Get the parent setting - PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType); - // Compare parent setting with current setting - //_Initializing = true; - if (pcb != _ProcedureConfig.Print_ChangeBar) - _ProcedureConfig.Print_ChangeBar = pcb; // this will force a database update (write) - ppCmbxChangeBarType.SelectedIndex = -1; //reset to the default Change Bar setting - //_Initializing = false; - //tcpFormatSettings.Focus(); - } - - /// - /// Selection in Change Bar Position combo box changed. - /// - /// object - /// EventArgs - private void ppCmbxChgBarPos_SelectedValueChanged(object sender, EventArgs e) - { - if (!_Initializing) - { - PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc); - ProcessCmbxSelectionEnumChanged(ppCmbxChgBarPos, cbl, ppBtnDefaultCbPos, ppLblChgBarPosDefault); - //tcpFormatSettings.Focus(); - } - } - - /// - /// Reset to the parent setting. - /// Find the parent setting and assign it to _ProcedureConfig.Print_ChangeBarLoc. - /// This will force the database to be updated. - /// - /// - /// - private void ppBtnDefaultCbPos_Click(object sender, EventArgs e) - { - // Get the parent setting - PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc); - // Compare parent setting with current setting - if (cbl != _ProcedureConfig.Print_ChangeBarLoc) - _ProcedureConfig.Print_ChangeBarLoc = cbl; // this will force a database update (write) - ppCmbxChgBarPos.SelectedIndex = -1; //reset to the default Change Bar Position setting - //tcpFormatSettings.Focus(); - } - - /// - /// Selection in Change Bar Text Type combo box changed. - /// - /// object - /// EventArgs - private void ppCmbxChgBarTxtType_SelectedValueChanged(object sender, EventArgs e) - { - if (!_Initializing) - { - PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText); - ProcessCmbxSelectionEnumChanged(ppCmbxChgBarTxtType, cbt, ppBtnDefCbTxtTyp, ppLblChgBarTxtTypeDefault); - setEnabledUserSpecifiedChgBarText(); - //tcpFormatSettings.Focus(); - } - } - - /// - /// Reset to the parent setting. - /// Find the parent setting and assign it to _ProcedureConfig.Print_ChangeBarText. - /// This will force the database to be updated. - /// - /// - /// - private void ppBtnDefCbTxtTyp_Click(object sender, EventArgs e) - { - // Get the parent setting - PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText); - // Compare parent setting with current setting - if (cbt != _ProcedureConfig.Print_ChangeBarText) - _ProcedureConfig.Print_ChangeBarText = cbt; // this will force a database update (write) - ppCmbxChgBarTxtType.SelectedIndex = -1; //reset to the default Change Bar Text Type setting - //tcpFormatSettings.Focus(); - } - - /// - /// Enable or disable the user specified change bar text based on the selected - /// change bar text type (selected in the user specific change bar grouping) - /// - private void setEnabledUserSpecifiedChgBarText() - { - //ppGpbxUserSpecTxt.Enabled = - //ppTxbxChangeBarUserMsgOne.Enabled = - //ppTxbxChgBarUserMsgTwo.Enabled = - //ppBtnDefCbTxt1.Enabled = - //ppBtnDefCbTxt2.Enabled = (ppCmbxChgBarTxtType.SelectedValue != null && - //ppCmbxChgBarTxtType.SelectedValue.Equals(ProcedureConfig.PrintChangeBarText.UserDef)); - - // This string is used to check against our default setting to see if User Defined Changebar Text is active - string decUserDef = PrintChangeBarText.UserDef.ToString(); - - ppGpbxUserSpecTxt.Enabled = (ppCmbxChgBarTxtType.SelectedValue != null && - ppCmbxChgBarTxtType.SelectedValue.Equals(PrintChangeBarText.UserDef)) || - (ppCmbxChgBarTxtType.SelectedIndex == -1 && _DefaultChgBarText.Equals(decUserDef)); - - } - - #endregion - - #region Output Settings tab - - /// - /// This is the Output Settings button used on the button interface design - /// - /// object - /// EventArgs - private void btnOutputStngs_Click(object sender, EventArgs e) - { - ProcessButtonClick(tiOutputStngs, btnOutputStngs); - } - - /// - /// Selection in Pagination combo box changed. - /// - /// object - /// EventArgs - //private void ppCmbxPagination_SelectedValueChanged(object sender, EventArgs e) - //{ - // if (!_Initializing) - // { - // PrintPagination pgtn = (PrintPagination)Enum.Parse(typeof(PrintPagination), _DefaultPagination); - // ProcessCmbxSelectionEnumChanged(ppCmbxPagination, pgtn, ppBtnDefPagination, ppLblPaginationDefault); - // //tcpOutputSettings.Focus(); - // } - //} - - /// - /// Reset to the parent setting. - /// Find the parent setting and assign it to _ProcedureConfig.Print_Pagination. - /// This will force the database to be updated. - /// - /// - /// - //private void ppBtnDefPagination_Click(object sender, EventArgs e) - //{ - // // Get the parent setting - // PrintPagination pgtn = (PrintPagination)Enum.Parse(typeof(PrintPagination), _DefaultPagination); - // // Compare parent setting with current setting - // if (pgtn != _ProcedureConfig.Print_Pagination) - // _ProcedureConfig.Print_Pagination = pgtn; // this will force a database update (write) - // ppCmbxPagination.SelectedIndex = -1; //reset to the default Pagination setting - // //tcpOutputSettings.Focus(); - //} - - /// - /// Selection in Watermark combo box changed. - /// - /// object - /// EventArgs - private void ppCmbxWatermark_SelectedValueChanged(object sender, EventArgs e) - { - if (!_Initializing) - { - PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); - ProcessCmbxSelectionEnumChanged(ppCmbxWatermark, wtr, ppBtnDefWatermark, ppLblWatermarkDefault); - //tcpOutputSettings.Focus(); - } - } - - /// - /// Reset to the parent setting. - /// Find the parent setting and assign it to _ProcedureConfig.Print_Watermark. - /// This will force the database to be updated. - /// - /// - /// - private void ppBtnDefWatermark_Click(object sender, EventArgs e) - { - // Get the parent setting - PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); - // Compare parent setting with current setting - if (wtr != _ProcedureConfig.Print_Watermark) - _ProcedureConfig.Print_Watermark = wtr; // this will force a database update (write) - ppCmbxWatermark.SelectedIndex = -1; //reset to the default Watermark setting - } - - #endregion - - #region View Settings tab - - ///// - ///// This is the View Settings button used on the button interface design - ///// - ///// object - ///// EventArgs - //private void btnVwStngs_Click(object sender, EventArgs e) - //{ - // ProcessButtonClick(tiViewStngs, btnVwStngs); - //} - #endregion - - #region Generic functions used on this property page - - /// - /// Determines what labels (showing default values) are visable on the property pages - /// - private void defaultSettingsVisiblity() - { - ppLblDefSettingsInfo.Visible = ppCbShwDefSettings.Checked; - - ppLblWatermarkDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefWatermark.Visible; - //ppLblPaginationDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefPagination.Visible; - ppLblStpEditorColsDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefEdCols.Visible; - ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; - ppLblChangeBarTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultChgBar.Visible; - ppLblChgBarPosDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultCbPos.Visible; - ppLblChgBarTxtTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxtTyp.Visible; - ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible; - ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible; - ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible; - } - - /// - /// Select the corresponding tab and set the button's state to checked - /// - /// Property Page Tab - /// Corresponding Property Page Button - private void ProcessButtonClick(TabItem tab, ButtonX button) - { - ClearAllCheckedButtons(); - tcProcProp.SelectedTab = tab; - button.Checked = true; - } - - /// - /// For the Button Interface property page style, when a button is selected (pressed), - /// it will remain in the checked state even when a different button is selected. Thus - /// we must clear the checked state of the buttons when a button is selected, then set - /// the newly selected button's state to checked. - /// - private void ClearAllCheckedButtons() - { - btnGeneral.Checked = false; - btnFmtStngs.Checked = false; - btnOutputStngs.Checked = false; - //btnVwStngs.Checked = false; - } - - /// - /// This is a generic Enter Event function for use with all of the property page tabs. - /// Found that the visiblity value of buttons is not recorded until the property page in which it resides is diplayed. - /// Thus we need to call defaultSettingVisiblity() to check and set visiblity states. - /// - /// type object - /// type EventArgs - private void tabpage_Enter(object sender, EventArgs e) - { - // Show or hide the labels containing the default values - //if (!_Initializing) - defaultSettingsVisiblity(); - } - - /// - /// Set the watermark and default label - /// - /// The default text - /// Label that displays the current default when view defaults is set - /// Combo box with a watermark property - private static void SetupDefault(string defaultText, Label lbl, ComboBoxEx cmbo) - { - if (defaultText != null && !(defaultText.Equals(""))) - { - string deftext = string.Format("{0}", defaultText); - lbl.Text = deftext; - cmbo.WatermarkText = deftext; - } - } - - /// - /// Process a change in the enum combo box selection - /// - /// Combo Box Name - /// the default enum value - /// button to reset to default value - /// label containing the default - private void ProcessCmbxSelectionEnumChanged(ComboBoxEx cmbx, object enumval, ButtonX button, Label deflabel) - { - if ((cmbx.SelectedIndex != -1) && - cmbx.SelectedValue.Equals(enumval)) - { - _Initializing = true; - button.Visible = true; - button.Focus(); - button.PerformClick(); - cmbx.SelectedIndex = -1; // This will hide the Default button - _Initializing = false; - } - button.Visible = (cmbx.SelectedValue != null); - deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible; - } - // Commented out as part of code change C2017-004 - select default format on dropdown - ///// - ///// Process a change in the combo box selection - ///// - ///// Combo Box Name - ///// string containing default text - ///// button to reset to default value - ///// label containing the default - //private void ProcessCmbxSelectedValueChange(ComboBoxEx cmbx, string defstr, ButtonX button, Label deflabel) - //{ - // if ((cmbx.SelectedIndex != -1) && defstr != null && defstr.Equals(cmbx.SelectedValue)) - // { - // button.Visible = true; - // button.Focus(); - // button.PerformClick(); - // } - // button.Visible = cmbx.SelectedValue != null; - // deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible; - //} - #endregion - - private void ppProcTitleStpRTB_Enter(object sender, EventArgs e) - { - _MyStepTabRibbon.MyStepRTB = ppProcTitleStpRTB; - } - - private void ppProcNumStpRTB_Enter(object sender, EventArgs e) - { - _MyStepTabRibbon.MyStepRTB = ppProcNumStpRTB; - } - - private void ppBtnDefCbTxt1_Click(object sender, EventArgs e) - { - // Compare default setting with current setting - // Reset with the default and hide the default button and label - if (_DefaultChgBarUsrMsg1 != _ProcedureConfig.Print_UserCBMess1) - { - _ProcedureConfig.Print_UserCBMess1 = _DefaultChgBarUsrMsg1; - ppLblChgBarUserMsgOneDefault.Visible = false; - ppBtnDefCbTxt1.Visible = false; - //tcpFormatSettings.Focus(); - } - - } - - private void ppBtnDefCbTxt2_Click(object sender, EventArgs e) - { - // Compare default setting with current setting - // Reset with the default and hide the default button and label - if (_DefaultChgBarUsrMsg2 != _ProcedureConfig.Print_UserCBMess2) - { - _ProcedureConfig.Print_UserCBMess2 = _DefaultChgBarUsrMsg2; - ppLblChgBarUserMsgTwoDefault.Visible = false; - ppBtnDefCbTxt2.Visible = false; - //tcpFormatSettings.Focus(); - } - } - - private void ppBtnDefEdCols_Click(object sender, EventArgs e) - { - // Get the parent setting - FormatColumns fc = (FormatColumns)Enum.Parse(typeof(FormatColumns), _DefaultFormatColumns); - if (fc != _ProcedureConfig.Format_Columns) - _ProcedureConfig.Format_Columns = fc; // this will force a database update (write) - ppCmbxStpEditorCols.SelectedIndex = -1; //reset to the default - //tcpGeneral.Focus(); - } - - private void ppBtnDefWatermark_Click_1(object sender, EventArgs e) - { - // Get the parent setting - PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); - // Compare parent setting with current setting - if (wtr != _ProcedureConfig.Print_Watermark) - _ProcedureConfig.Print_Watermark = wtr; // this will force a database update (write) - ppCmbxWatermark.SelectedIndex = -1; - //tcpOutputSettings.Focus(); - } - - private void ppBtnDeftDisAutoDuplx_Click(object sender, EventArgs e) - { - ppChbxDisAutoDuplex.Checked = _DefaultDisableDuplex; - _ProcedureConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked; - ppBtnDeftDisAutoDuplx.Visible = false; - ppLblAutoDuplexDefault.Visible = false; - //tcpOutputSettings.Focus(); - } - - private void ppTxbxChangeBarUserMsgOne_TextChanged(object sender, EventArgs e) - { - ppBtnDefCbTxt1.Visible = ((ppTxbxChangeBarUserMsgOne.Text != null) && !ppTxbxChangeBarUserMsgOne.Text.Equals(_DefaultChgBarUsrMsg1)); - ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible; - //tcpOutputSettings.Focus(); - } - - private void ppTxbxChgBarUserMsgTwo_TextChanged(object sender, EventArgs e) - { - ppBtnDefCbTxt2.Visible = ((ppTxbxChgBarUserMsgTwo.Text != null) && !ppTxbxChgBarUserMsgTwo.Text.Equals(_DefaultChgBarUsrMsg2)); - ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible; - //tcpOutputSettings.Focus(); - } - - private void ppChbxDisAutoDuplex_CheckedChanged(object sender, EventArgs e) - { - - if (!_Initializing) - { - _ProcedureConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked; - ppBtnDeftDisAutoDuplx.Visible = _DefaultDisableDuplex != ppChbxDisAutoDuplex.Checked; - ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible; - //tcpOutputSettings.Focus(); - } - } - - private void frmProcedureProperties_Shown(object sender, EventArgs e) - { - ppProcNumStpRTB.Focus(); - - } - - private void ppCmbxFormat_DropDown(object sender, EventArgs e) - { - _Initializing = true; - // C2017-004 - if using the default format, position the dropdown to the default format - if (ppCmbxFormat.SelectedIndex == -1) - ppCmbxFormat.SelectedValue = _DefaultFormatName; - _Initializing = false; - } - - private void ppCmbxFormat_DropDownClosed(object sender, EventArgs e) - { - // upon exit of the dropdown if the default format is selected - click the Default button - if ((string)(ppCmbxFormat.SelectedValue) == _DefaultFormatName) - { - ppBtnDefaultFmt.PerformClick(); - btnFmtStngs.Focus(); - } - } - - // added as part of code change C2017-004. this also makes it consistent with section properties - int _InitialIndex = -2; - private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e) - { - if (_Initializing) - { - // determine if the default button and the default description text should visable - ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1); - ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; - return; - } - if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section format is not the default section) - if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue)) - { - ppBtnDefaultFmt.Focus(); - ppBtnDefaultFmt.PerformClick(); - } - // determine if the default button and the default description text should visable - ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1); - ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; - } - - } + // Get the saved settings for this user + // + // This setting tells us if we should display the default values on this property page + ppCbShwDefSettings.Checked = (Settings.Default["ShowDefaultProcedureProp"] != null) ? Settings.Default.ShowDefaultProcedureProp : false; + + // Get the User's property page style "PropPageStyle" (this is a system wide user setting) + // 1 - Button Dialog (default) + // 2 - Tab Dialog + if ((int)Settings.Default["PropPageStyle"] == (int)PropPgStyle.Tab) + { + tcProcProp.TabsVisible = true; + panProcBtns.Visible = false; + this.Width -= panProcBtns.Width; + } + + // Get the default values for the property page information + FindDefaultValues(); + + // if we are creating a new procedure, initially set the format to the default format + if (_ProcedureConfig.CreatingNew)// .FormatSelection == null) + ppCmbxFormat.SelectedValue = _ProcedureConfig.DefaultFormatSelection; + + // Assign the data sources to the combo boxes + ppCmbxChgBarPos.DataSource = EnumDetail.Details(); + ppCmbxChgBarPos.DisplayMember = "Description"; + ppCmbxChgBarPos.ValueMember = "EValue"; + ppCmbxChgBarPos.SelectedIndex = -1; + + ppCmbxChgBarTxtType.DataSource = EnumDetail.Details(); + ppCmbxChgBarTxtType.DisplayMember = "Description"; + ppCmbxChgBarTxtType.ValueMember = "EValue"; + ppCmbxChgBarTxtType.SelectedIndex = -1; + + ppCmbxChangeBarType.DataSource = EnumDetail.Details(); + ppCmbxChangeBarType.DisplayMember = "Description"; + ppCmbxChangeBarType.ValueMember = "EValue"; + ppCmbxChangeBarType.SelectedIndex = -1; + + //ppCmbxPagination.DataSource = EnumDetail.Details(); + //ppCmbxPagination.DisplayMember = "Description"; + //ppCmbxPagination.ValueMember = "EValue"; + //ppCmbxPagination.SelectedIndex = -1; + + ppCmbxWatermark.DataSource = EnumDetail.Details(); + ppCmbxWatermark.DisplayMember = "Description"; + ppCmbxWatermark.ValueMember = "EValue"; + ppCmbxWatermark.SelectedIndex = -1; + + ppCmbxStpEditorCols.DataSource = EnumDetail.Details(); + ppCmbxStpEditorCols.DisplayMember = "Description"; + ppCmbxStpEditorCols.ValueMember = "EValue"; + ppCmbxStpEditorCols.SelectedIndex = -1; + + // the only time the create enhanced checkbox is visisble is if this is a 'New' procedure in a set that is the 'Source'. + cbEnhanced.Visible = false; + DocVersionConfig dvc = _ProcedureConfig.MyProcedure.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig; + if (_ProcedureConfig.CreatingNew && dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0 && dvc.MyEnhancedDocuments[0].Type != 0) + cbEnhanced.Visible = true; + cbNotIncludeInMerged.Checked = _ProcedureConfig.Print_NotInMergeAll; + _Initializing = false; + + } + + //C2023-017: Remove any formats that are not applicable to the current plant + private IList PopulateFormatList(SortedBindingList RawList) + { + List result = new List(); + + try + { + //Get the top folder configuration XML of the PROMS treeview and load + //the Formats node to retrieve the available formats for this plant + FolderInfo fi = FolderInfo.GetTop(); + System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); + xDoc.LoadXml(fi.Config); + XmlNodeList fList = xDoc.GetElementsByTagName("Formats"); + + //We need to check to see if the current database has been updated with the necessary changes + //to the folder configuration value. If so then build the list of available to be returned + //to the calling code + if (fList == null) + { + _MyLog.InfoFormat("Filtered format list not available: Database update needed for config value of top folder record"); + return RawList; + } + else + { + //Create a string array that we can use to filter the raw list and add the format to the return value + string[] availableFormats = fList[0].Attributes["Active"].Value.Split(','); + foreach (FormatInfo item in RawList) + { + if (Array.IndexOf(availableFormats, item.ApplicablePlant.ToString()) > -1) + { + result.Add(item); + } + } + } + } + catch (Exception ex) + { + //On any exception simply return the original list that was passed in + _MyLog.ErrorFormat("Error loading filtered format list - PopulateFormatList(): {0}", ex.Message); + return RawList; + } + + return result; + } + + #region General tab + + /// + /// This is the General button used on the button interface design + /// + /// object + /// EventArgs + private void btnGeneral_Click(object sender, EventArgs e) + { + ProcessButtonClick(tiGeneral, btnGeneral); + } + + /// + /// Selection in Default Column Mode combo box changed. + /// + /// object + /// EventArgs + private void ppCmbxStpEditorCols_SelectedValueChanged(object sender, EventArgs e) + { + if (!_Initializing) + { + FormatColumns fc = (FormatColumns)Enum.Parse(typeof(FormatColumns), _DefaultFormatColumns); + ProcessCmbxSelectionEnumChanged(ppCmbxStpEditorCols, fc, ppBtnDefEdCols, ppLblStpEditorColsDefault); + //if ((ppCmbxStpEditorCols.SelectedIndex != -1) && ppCmbxStpEditorCols.SelectedValue.Equals(fc)) + //{ + // ppBtnDefEdCols.Focus(); + // ppBtnDefEdCols.PerformClick(); + //} + //ppBtnDefEdCols.Visible = ppCmbxStpEditorCols.SelectedValue != null; + //ppLblStpEditorColsDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefEdCols.Visible; + //tcpGeneral.Focus(); + } + } + #endregion + + #region Format Settings tab + + /// + /// This is the Format Settings button used on the button interface design + /// + /// object + /// EventArgs + private void btnFmtStngs_Click(object sender, EventArgs e) + { + ProcessButtonClick(tiFmtStngs, btnFmtStngs); + // added for code change C2017-004 - select default format in dropdown list + if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section is set to the default format) + } + + private void ppBtnDefaultFmt_Click(object sender, EventArgs e) + { + ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting + //tcpFormatSettings.Focus(); + } + + // Commented out as part of code change C2017-004. this also makes it consistent with section properties + /// + /// Selection in Format combo box changed. + /// + /// object + /// EventArgs + //private void ppCmbxFormat_SelectedValueChanged(object sender, EventArgs e) + //{ + // ProcessCmbxSelectedValueChange(ppCmbxFormat, _DefaultFormatName, ppBtnDefaultFmt, ppLblFormatDefault); + //} + + /// + /// Enable or disable the user specified change bar options base on the type + /// of change bar selected. + /// + private void setEnabledUserSpecifiedChgBarCombos(PrintChangeBar pcb) + { + //ppGpbxUserSpecCB.Enabled = + //ppCmbxChgBarPos.Enabled = + //ppCmbxChgBarTxtType.Enabled = + //ppBtnDefaultCbPos.Enabled = + //ppBtnDefCbTxtTyp.Enabled = (ppCmbxChangeBarType.SelectedValue != null && + // ppCmbxChangeBarType.SelectedValue.Equals(ProcedureConfig.PrintChangeBar.WithUserSpecified)) || + // (ppCmbxChangeBarType.SelectedValue == null && pcb.Equals(DocVersionConfig.PrintChangeBar.WithUserSpecified)); + + ppGpbxUserSpecCB.Enabled = (ppCmbxChangeBarType.SelectedValue != null && + ppCmbxChangeBarType.SelectedValue.Equals(PrintChangeBar.WithUserSpecified)) || + (ppCmbxChangeBarType.SelectedValue == null && pcb.Equals(PrintChangeBar.WithUserSpecified)); + } + + /// + /// Selection in Change Bar combo box changed. + /// + /// object + /// EventArgs + private void ppCmbxChangeBarType_SelectedValueChanged(object sender, EventArgs e) + { + //Console.WriteLine("### SelectedValueChanged"); + if (!_Initializing) + { + PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType); + ProcessCmbxSelectionEnumChanged(ppCmbxChangeBarType, pcb, ppBtnDefaultChgBar, ppLblChangeBarTypeDefault); + setEnabledUserSpecifiedChgBarCombos(pcb); + //tcpFormatSettings.Focus(); + } + } + + /// + /// Reset to the parent setting. + /// Find the parent setting and assign it to _ProcedureConfig.PrintChangeBar. + /// This will force the database to be updated. + /// + /// + /// + private void ppBtnDefaultChgBar_Click(object sender, EventArgs e) + { + // Get the parent setting + PrintChangeBar pcb = (PrintChangeBar)Enum.Parse(typeof(PrintChangeBar), _DefaultChgBarType); + // Compare parent setting with current setting + //_Initializing = true; + if (pcb != _ProcedureConfig.Print_ChangeBar) + _ProcedureConfig.Print_ChangeBar = pcb; // this will force a database update (write) + ppCmbxChangeBarType.SelectedIndex = -1; //reset to the default Change Bar setting + //_Initializing = false; + //tcpFormatSettings.Focus(); + } + + /// + /// Selection in Change Bar Position combo box changed. + /// + /// object + /// EventArgs + private void ppCmbxChgBarPos_SelectedValueChanged(object sender, EventArgs e) + { + if (!_Initializing) + { + PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc); + ProcessCmbxSelectionEnumChanged(ppCmbxChgBarPos, cbl, ppBtnDefaultCbPos, ppLblChgBarPosDefault); + //tcpFormatSettings.Focus(); + } + } + + /// + /// Reset to the parent setting. + /// Find the parent setting and assign it to _ProcedureConfig.Print_ChangeBarLoc. + /// This will force the database to be updated. + /// + /// + /// + private void ppBtnDefaultCbPos_Click(object sender, EventArgs e) + { + // Get the parent setting + PrintChangeBarLoc cbl = (PrintChangeBarLoc)Enum.Parse(typeof(PrintChangeBarLoc), _DefaultChgBarLoc); + // Compare parent setting with current setting + if (cbl != _ProcedureConfig.Print_ChangeBarLoc) + _ProcedureConfig.Print_ChangeBarLoc = cbl; // this will force a database update (write) + ppCmbxChgBarPos.SelectedIndex = -1; //reset to the default Change Bar Position setting + //tcpFormatSettings.Focus(); + } + + /// + /// Selection in Change Bar Text Type combo box changed. + /// + /// object + /// EventArgs + private void ppCmbxChgBarTxtType_SelectedValueChanged(object sender, EventArgs e) + { + if (!_Initializing) + { + PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText); + ProcessCmbxSelectionEnumChanged(ppCmbxChgBarTxtType, cbt, ppBtnDefCbTxtTyp, ppLblChgBarTxtTypeDefault); + setEnabledUserSpecifiedChgBarText(); + //tcpFormatSettings.Focus(); + } + } + + /// + /// Reset to the parent setting. + /// Find the parent setting and assign it to _ProcedureConfig.Print_ChangeBarText. + /// This will force the database to be updated. + /// + /// + /// + private void ppBtnDefCbTxtTyp_Click(object sender, EventArgs e) + { + // Get the parent setting + PrintChangeBarText cbt = (PrintChangeBarText)Enum.Parse(typeof(PrintChangeBarText), _DefaultChgBarText); + // Compare parent setting with current setting + if (cbt != _ProcedureConfig.Print_ChangeBarText) + _ProcedureConfig.Print_ChangeBarText = cbt; // this will force a database update (write) + ppCmbxChgBarTxtType.SelectedIndex = -1; //reset to the default Change Bar Text Type setting + //tcpFormatSettings.Focus(); + } + + /// + /// Enable or disable the user specified change bar text based on the selected + /// change bar text type (selected in the user specific change bar grouping) + /// + private void setEnabledUserSpecifiedChgBarText() + { + //ppGpbxUserSpecTxt.Enabled = + //ppTxbxChangeBarUserMsgOne.Enabled = + //ppTxbxChgBarUserMsgTwo.Enabled = + //ppBtnDefCbTxt1.Enabled = + //ppBtnDefCbTxt2.Enabled = (ppCmbxChgBarTxtType.SelectedValue != null && + //ppCmbxChgBarTxtType.SelectedValue.Equals(ProcedureConfig.PrintChangeBarText.UserDef)); + + // This string is used to check against our default setting to see if User Defined Changebar Text is active + string decUserDef = PrintChangeBarText.UserDef.ToString(); + + ppGpbxUserSpecTxt.Enabled = (ppCmbxChgBarTxtType.SelectedValue != null && + ppCmbxChgBarTxtType.SelectedValue.Equals(PrintChangeBarText.UserDef)) || + (ppCmbxChgBarTxtType.SelectedIndex == -1 && _DefaultChgBarText.Equals(decUserDef)); + + } + + #endregion + + #region Output Settings tab + + /// + /// This is the Output Settings button used on the button interface design + /// + /// object + /// EventArgs + private void btnOutputStngs_Click(object sender, EventArgs e) + { + ProcessButtonClick(tiOutputStngs, btnOutputStngs); + } + + /// + /// Selection in Pagination combo box changed. + /// + /// object + /// EventArgs + //private void ppCmbxPagination_SelectedValueChanged(object sender, EventArgs e) + //{ + // if (!_Initializing) + // { + // PrintPagination pgtn = (PrintPagination)Enum.Parse(typeof(PrintPagination), _DefaultPagination); + // ProcessCmbxSelectionEnumChanged(ppCmbxPagination, pgtn, ppBtnDefPagination, ppLblPaginationDefault); + // //tcpOutputSettings.Focus(); + // } + //} + + /// + /// Reset to the parent setting. + /// Find the parent setting and assign it to _ProcedureConfig.Print_Pagination. + /// This will force the database to be updated. + /// + /// + /// + //private void ppBtnDefPagination_Click(object sender, EventArgs e) + //{ + // // Get the parent setting + // PrintPagination pgtn = (PrintPagination)Enum.Parse(typeof(PrintPagination), _DefaultPagination); + // // Compare parent setting with current setting + // if (pgtn != _ProcedureConfig.Print_Pagination) + // _ProcedureConfig.Print_Pagination = pgtn; // this will force a database update (write) + // ppCmbxPagination.SelectedIndex = -1; //reset to the default Pagination setting + // //tcpOutputSettings.Focus(); + //} + + /// + /// Selection in Watermark combo box changed. + /// + /// object + /// EventArgs + private void ppCmbxWatermark_SelectedValueChanged(object sender, EventArgs e) + { + if (!_Initializing) + { + PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); + ProcessCmbxSelectionEnumChanged(ppCmbxWatermark, wtr, ppBtnDefWatermark, ppLblWatermarkDefault); + //tcpOutputSettings.Focus(); + } + } + + /// + /// Reset to the parent setting. + /// Find the parent setting and assign it to _ProcedureConfig.Print_Watermark. + /// This will force the database to be updated. + /// + /// + /// + private void ppBtnDefWatermark_Click(object sender, EventArgs e) + { + // Get the parent setting + PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); + // Compare parent setting with current setting + if (wtr != _ProcedureConfig.Print_Watermark) + _ProcedureConfig.Print_Watermark = wtr; // this will force a database update (write) + ppCmbxWatermark.SelectedIndex = -1; //reset to the default Watermark setting + } + + #endregion + + #region View Settings tab + + ///// + ///// This is the View Settings button used on the button interface design + ///// + ///// object + ///// EventArgs + //private void btnVwStngs_Click(object sender, EventArgs e) + //{ + // ProcessButtonClick(tiViewStngs, btnVwStngs); + //} + #endregion + + #region Generic functions used on this property page + + /// + /// Determines what labels (showing default values) are visable on the property pages + /// + private void defaultSettingsVisiblity() + { + ppLblDefSettingsInfo.Visible = ppCbShwDefSettings.Checked; + + ppLblWatermarkDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefWatermark.Visible; + //ppLblPaginationDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefPagination.Visible; + ppLblStpEditorColsDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefEdCols.Visible; + ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; + ppLblChangeBarTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultChgBar.Visible; + ppLblChgBarPosDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultCbPos.Visible; + ppLblChgBarTxtTypeDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxtTyp.Visible; + ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible; + ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible; + ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible; + } + + /// + /// Select the corresponding tab and set the button's state to checked + /// + /// Property Page Tab + /// Corresponding Property Page Button + private void ProcessButtonClick(TabItem tab, ButtonX button) + { + ClearAllCheckedButtons(); + tcProcProp.SelectedTab = tab; + button.Checked = true; + } + + /// + /// For the Button Interface property page style, when a button is selected (pressed), + /// it will remain in the checked state even when a different button is selected. Thus + /// we must clear the checked state of the buttons when a button is selected, then set + /// the newly selected button's state to checked. + /// + private void ClearAllCheckedButtons() + { + btnGeneral.Checked = false; + btnFmtStngs.Checked = false; + btnOutputStngs.Checked = false; + //btnVwStngs.Checked = false; + } + + /// + /// This is a generic Enter Event function for use with all of the property page tabs. + /// Found that the visiblity value of buttons is not recorded until the property page in which it resides is diplayed. + /// Thus we need to call defaultSettingVisiblity() to check and set visiblity states. + /// + /// type object + /// type EventArgs + private void tabpage_Enter(object sender, EventArgs e) + { + // Show or hide the labels containing the default values + //if (!_Initializing) + defaultSettingsVisiblity(); + } + + /// + /// Set the watermark and default label + /// + /// The default text + /// Label that displays the current default when view defaults is set + /// Combo box with a watermark property + private static void SetupDefault(string defaultText, Label lbl, ComboBoxEx cmbo) + { + if (defaultText != null && !(defaultText.Equals(""))) + { + string deftext = string.Format("{0}", defaultText); + lbl.Text = deftext; + cmbo.WatermarkText = deftext; + } + } + + /// + /// Process a change in the enum combo box selection + /// + /// Combo Box Name + /// the default enum value + /// button to reset to default value + /// label containing the default + private void ProcessCmbxSelectionEnumChanged(ComboBoxEx cmbx, object enumval, ButtonX button, Label deflabel) + { + if ((cmbx.SelectedIndex != -1) && + cmbx.SelectedValue.Equals(enumval)) + { + _Initializing = true; + button.Visible = true; + button.Focus(); + button.PerformClick(); + cmbx.SelectedIndex = -1; // This will hide the Default button + _Initializing = false; + } + button.Visible = (cmbx.SelectedValue != null); + deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible; + } + // Commented out as part of code change C2017-004 - select default format on dropdown + ///// + ///// Process a change in the combo box selection + ///// + ///// Combo Box Name + ///// string containing default text + ///// button to reset to default value + ///// label containing the default + //private void ProcessCmbxSelectedValueChange(ComboBoxEx cmbx, string defstr, ButtonX button, Label deflabel) + //{ + // if ((cmbx.SelectedIndex != -1) && defstr != null && defstr.Equals(cmbx.SelectedValue)) + // { + // button.Visible = true; + // button.Focus(); + // button.PerformClick(); + // } + // button.Visible = cmbx.SelectedValue != null; + // deflabel.Visible = ppCbShwDefSettings.Checked && button.Visible; + //} + #endregion + + private void ppProcTitleStpRTB_Enter(object sender, EventArgs e) + { + _MyStepTabRibbon.MyStepRTB = ppProcTitleStpRTB; + } + + private void ppProcNumStpRTB_Enter(object sender, EventArgs e) + { + _MyStepTabRibbon.MyStepRTB = ppProcNumStpRTB; + } + + private void ppBtnDefCbTxt1_Click(object sender, EventArgs e) + { + // Compare default setting with current setting + // Reset with the default and hide the default button and label + if (_DefaultChgBarUsrMsg1 != _ProcedureConfig.Print_UserCBMess1) + { + _ProcedureConfig.Print_UserCBMess1 = _DefaultChgBarUsrMsg1; + ppLblChgBarUserMsgOneDefault.Visible = false; + ppBtnDefCbTxt1.Visible = false; + //tcpFormatSettings.Focus(); + } + + } + + private void ppBtnDefCbTxt2_Click(object sender, EventArgs e) + { + // Compare default setting with current setting + // Reset with the default and hide the default button and label + if (_DefaultChgBarUsrMsg2 != _ProcedureConfig.Print_UserCBMess2) + { + _ProcedureConfig.Print_UserCBMess2 = _DefaultChgBarUsrMsg2; + ppLblChgBarUserMsgTwoDefault.Visible = false; + ppBtnDefCbTxt2.Visible = false; + //tcpFormatSettings.Focus(); + } + } + + private void ppBtnDefEdCols_Click(object sender, EventArgs e) + { + // Get the parent setting + FormatColumns fc = (FormatColumns)Enum.Parse(typeof(FormatColumns), _DefaultFormatColumns); + if (fc != _ProcedureConfig.Format_Columns) + _ProcedureConfig.Format_Columns = fc; // this will force a database update (write) + ppCmbxStpEditorCols.SelectedIndex = -1; //reset to the default + //tcpGeneral.Focus(); + } + + private void ppBtnDefWatermark_Click_1(object sender, EventArgs e) + { + // Get the parent setting + PrintWatermark wtr = (PrintWatermark)Enum.Parse(typeof(PrintWatermark), _DefaultWatermark); + // Compare parent setting with current setting + if (wtr != _ProcedureConfig.Print_Watermark) + _ProcedureConfig.Print_Watermark = wtr; // this will force a database update (write) + ppCmbxWatermark.SelectedIndex = -1; + //tcpOutputSettings.Focus(); + } + + private void ppBtnDeftDisAutoDuplx_Click(object sender, EventArgs e) + { + ppChbxDisAutoDuplex.Checked = _DefaultDisableDuplex; + _ProcedureConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked; + ppBtnDeftDisAutoDuplx.Visible = false; + ppLblAutoDuplexDefault.Visible = false; + //tcpOutputSettings.Focus(); + } + + private void ppTxbxChangeBarUserMsgOne_TextChanged(object sender, EventArgs e) + { + ppBtnDefCbTxt1.Visible = ((ppTxbxChangeBarUserMsgOne.Text != null) && !ppTxbxChangeBarUserMsgOne.Text.Equals(_DefaultChgBarUsrMsg1)); + ppLblChgBarUserMsgOneDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt1.Visible; + //tcpOutputSettings.Focus(); + } + + private void ppTxbxChgBarUserMsgTwo_TextChanged(object sender, EventArgs e) + { + ppBtnDefCbTxt2.Visible = ((ppTxbxChgBarUserMsgTwo.Text != null) && !ppTxbxChgBarUserMsgTwo.Text.Equals(_DefaultChgBarUsrMsg2)); + ppLblChgBarUserMsgTwoDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefCbTxt2.Visible; + //tcpOutputSettings.Focus(); + } + + private void ppChbxDisAutoDuplex_CheckedChanged(object sender, EventArgs e) + { + + if (!_Initializing) + { + _ProcedureConfig.Print_DisableDuplex = ppChbxDisAutoDuplex.Checked; + ppBtnDeftDisAutoDuplx.Visible = _DefaultDisableDuplex != ppChbxDisAutoDuplex.Checked; + ppLblAutoDuplexDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDeftDisAutoDuplx.Visible; + //tcpOutputSettings.Focus(); + } + } + + private void frmProcedureProperties_Shown(object sender, EventArgs e) + { + ppProcNumStpRTB.Focus(); + + } + + private void ppCmbxFormat_DropDown(object sender, EventArgs e) + { + _Initializing = true; + // C2017-004 - if using the default format, position the dropdown to the default format + if (ppCmbxFormat.SelectedIndex == -1) + ppCmbxFormat.SelectedValue = _DefaultFormatName; + _Initializing = false; + } + + private void ppCmbxFormat_DropDownClosed(object sender, EventArgs e) + { + // upon exit of the dropdown if the default format is selected - click the Default button + if ((string)(ppCmbxFormat.SelectedValue) == _DefaultFormatName) + { + ppBtnDefaultFmt.PerformClick(); + btnFmtStngs.Focus(); + } + } + + // added as part of code change C2017-004. this also makes it consistent with section properties + int _InitialIndex = -2; + private void ppCmbxFormat_SelectedIndexChanged(object sender, EventArgs e) + { + if (_Initializing) + { + // determine if the default button and the default description text should visable + ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1); + ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; + return; + } + if (_InitialIndex < -1) _InitialIndex = ppCmbxFormat.SelectedIndex; // save the current format selection (happens here when current section format is not the default section) + if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName != null && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue)) + { + ppBtnDefaultFmt.Focus(); + ppBtnDefaultFmt.PerformClick(); + } + // determine if the default button and the default description text should visable + ppBtnDefaultFmt.Visible = !(ppCmbxFormat.SelectedValue == null || ppCmbxFormat.SelectedIndex == -1); + ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; + } + + } } \ No newline at end of file diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs index 94c3bd43..e1f73bc0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs @@ -192,6 +192,16 @@ namespace VEPROMS.CSLA.Library return _UserID; } } + private int _ApplicablePlant = 0; + public int ApplicablePlant + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("ApplicablePlant", true); + return _ApplicablePlant; + } + } private int _FormatContentCount = 0; /// /// Count of FormatContents for this Format @@ -518,6 +528,7 @@ namespace VEPROMS.CSLA.Library _FormatDocVersionCount = dr.GetInt32("DocVersionCount"); _FormatFolderCount = dr.GetInt32("FolderCount"); _ChildFormatCount = dr.GetInt32("ChildCount"); + _ApplicablePlant = dr.GetInt32("ApplicablePlant"); } catch (Exception ex) { -- 2.47.2 From 55a78eb84534a920ea6a7f06b224c6a94a1b1056 Mon Sep 17 00:00:00 2001 From: Chris Glavan Date: Tue, 3 Oct 2023 09:03:06 -0400 Subject: [PATCH 2/6] C2023-017: ~Moved original code for populating the filtered list to a separate static class named FormatUtility in Volian.Controls.Library ~Renamed method to GetFilteredFormatList ~Updated code to reference new static class and method ~Added logic to other applicable forms --- .../frmFolderProperties.cs | 5 +- .../frmProcedureProperties.cs | 48 +-------------- .../frmSectionProperties.cs | 2 +- .../frmVersionsProperties.cs | 2 +- .../Volian.Controls.Library/FormatUtility.cs | 61 +++++++++++++++++++ .../Volian.Controls.Library.csproj | 1 + 6 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 PROMS/Volian.Controls.Library/FormatUtility.cs diff --git a/PROMS/VEPROMS User Interface/frmFolderProperties.cs b/PROMS/VEPROMS User Interface/frmFolderProperties.cs index 0f5729a7..7c55c5dc 100644 --- a/PROMS/VEPROMS User Interface/frmFolderProperties.cs +++ b/PROMS/VEPROMS User Interface/frmFolderProperties.cs @@ -13,6 +13,7 @@ using DevComponents.DotNetBar.Controls; using System.Drawing.Imaging; using VEPROMS.Properties; using DescriptiveEnum; +using Volian.Controls.Library; namespace VEPROMS { @@ -150,8 +151,8 @@ namespace VEPROMS ppCmbxFormat.DataSource = null; ppCmbxFormat.DisplayMember = "FullName"; ppCmbxFormat.ValueMember = "FullName"; - ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList; - if (_FolderConfig != null && _FolderConfig.MyFolder != null) _cmbxformatOriginal = _FolderConfig.MyFolder.FormatID; + ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList); + if (_FolderConfig != null && _FolderConfig.MyFolder != null) _cmbxformatOriginal = _FolderConfig.MyFolder.FormatID; if (_FolderConfig.FormatSelection != null) { ppCmbxFormat.SelectedValue = _FolderConfig.FormatSelection; diff --git a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs index f373df6d..4f90856c 100644 --- a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs +++ b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs @@ -18,7 +18,6 @@ namespace VEPROMS { public partial class frmProcedureProperties : DevComponents.DotNetBar.Office2007Form { - private readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private bool _Initializing = false; private string _DefaultFormatName = null; //private string _DefaultPagination = null; @@ -189,7 +188,7 @@ namespace VEPROMS ppCmbxFormat.ValueMember = "FullName"; //C2023-017: Retrieves a filtered list of formats for the current plant - ppCmbxFormat.DataSource = PopulateFormatList(FormatInfoList.SortedFormatInfoList); + ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList); if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null) _cmbxformatOriginal = _ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat.FormatID; if (_ProcedureConfig.FormatSelection != null) ppCmbxFormat.SelectedValue = _ProcedureConfig.FormatSelection; @@ -259,51 +258,6 @@ namespace VEPROMS } - //C2023-017: Remove any formats that are not applicable to the current plant - private IList PopulateFormatList(SortedBindingList RawList) - { - List result = new List(); - - try - { - //Get the top folder configuration XML of the PROMS treeview and load - //the Formats node to retrieve the available formats for this plant - FolderInfo fi = FolderInfo.GetTop(); - System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); - xDoc.LoadXml(fi.Config); - XmlNodeList fList = xDoc.GetElementsByTagName("Formats"); - - //We need to check to see if the current database has been updated with the necessary changes - //to the folder configuration value. If so then build the list of available to be returned - //to the calling code - if (fList == null) - { - _MyLog.InfoFormat("Filtered format list not available: Database update needed for config value of top folder record"); - return RawList; - } - else - { - //Create a string array that we can use to filter the raw list and add the format to the return value - string[] availableFormats = fList[0].Attributes["Active"].Value.Split(','); - foreach (FormatInfo item in RawList) - { - if (Array.IndexOf(availableFormats, item.ApplicablePlant.ToString()) > -1) - { - result.Add(item); - } - } - } - } - catch (Exception ex) - { - //On any exception simply return the original list that was passed in - _MyLog.ErrorFormat("Error loading filtered format list - PopulateFormatList(): {0}", ex.Message); - return RawList; - } - - return result; - } - #region General tab /// diff --git a/PROMS/VEPROMS User Interface/frmSectionProperties.cs b/PROMS/VEPROMS User Interface/frmSectionProperties.cs index c5027764..f3346895 100644 --- a/PROMS/VEPROMS User Interface/frmSectionProperties.cs +++ b/PROMS/VEPROMS User Interface/frmSectionProperties.cs @@ -364,7 +364,7 @@ namespace VEPROMS ppCmbxFormat.DataSource = null; ppCmbxFormat.DisplayMember = "FullName"; ppCmbxFormat.ValueMember = "FullName"; - ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList; + ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList); if (_SectionConfig.MySection.MySectionInfo.ActiveFormat != null) _cmbxformatOriginal = (int)_SectionConfig.MySection.MySectionInfo.ActiveFormat.FormatID; if (_SectionConfig.FormatSelection != null) ppCmbxFormat.SelectedValue = _SectionConfig.FormatSelection; diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs index 196b5239..b3e88c6f 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs @@ -168,7 +168,7 @@ namespace VEPROMS ppCmbxFormat.DataSource = null; ppCmbxFormat.DisplayMember = "FullName"; ppCmbxFormat.ValueMember = "FullName"; - ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList; + ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList); _cmbxformatOriginal = _DocVersionConfig.MyDocVersion.FormatID; if (_DocVersionConfig.FormatSelection != null) diff --git a/PROMS/Volian.Controls.Library/FormatUtility.cs b/PROMS/Volian.Controls.Library/FormatUtility.cs new file mode 100644 index 00000000..d66e4a17 --- /dev/null +++ b/PROMS/Volian.Controls.Library/FormatUtility.cs @@ -0,0 +1,61 @@ +using Csla; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using VEPROMS.CSLA.Library; + +namespace Volian.Controls.Library +{ + public static class FormatUtility + { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + //C2023-017: Remove any formats that are not applicable to the current plant + public static IList GetFilteredFormatList(SortedBindingList RawList) + { + List result = new List(); + + try + { + //Get the top folder configuration XML of the PROMS treeview and load + //the Formats node to retrieve the available formats for this plant + FolderInfo fi = FolderInfo.GetTop(); + System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); + xDoc.LoadXml(fi.Config); + XmlNodeList fList = xDoc.GetElementsByTagName("Formats"); + + //We need to check to see if the current database has been updated with the necessary changes + //to the folder configuration value. If so then build the list of available to be returned + //to the calling code + if (fList == null) + { + _MyLog.InfoFormat("Filtered format list not available: Database update needed for config value of top folder record"); + return RawList; + } + else + { + //Create a string array that we can use to filter the raw list and add the format to the return value + string[] availableFormats = fList[0].Attributes["Active"].Value.Split(','); + foreach (FormatInfo item in RawList) + { + if (Array.IndexOf(availableFormats, item.ApplicablePlant.ToString()) > -1) + { + result.Add(item); + } + } + } + } + catch (Exception ex) + { + //On any exception simply return the original list that was passed in + _MyLog.ErrorFormat("Error loading filtered format list - PopulateFormatList(): {0}", ex.Message); + return RawList; + } + + return result; + } + } +} diff --git a/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj b/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj index 9226433f..9c76fbf7 100644 --- a/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj +++ b/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj @@ -240,6 +240,7 @@ FindReplace.cs + Form -- 2.47.2 From 4be7cdc6c7631353b0cf783134c52b6eeeaa840f Mon Sep 17 00:00:00 2001 From: Chris Glavan Date: Tue, 3 Oct 2023 09:18:53 -0400 Subject: [PATCH 3/6] ~Added database changes to PROMSFixes.sql --- PROMS/VEPROMS User Interface/PROMSFixes.Sql | 206 ++++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index dc4a33b0..244ee6cb 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -21995,3 +21995,209 @@ ELSE PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Error on Creation' go Exec vesp_GetSQLCodeRevision; + + + +/****** Add the ApplicablePlant field to the Formats table ******/ +ALTER TABLE Formats ADD ApplicablePlant int NULL; +GO + +/****** Update the Formats table with the appropriate ApplicablePlant value ******/ + +--This update statement corrects a typo in the name of one of the format records +UPDATE Formats SET [Description] = REPLACE([Description], 'Robimson', 'Robinson') WHERE [Description] LIKE '%Robimson%'; + +UPDATE Formats SET ApplicablePlant = 1 WHERE [Description] LIKE '%DC Cook%' OR [Name] LIKE 'AEP%'; +UPDATE Formats SET ApplicablePlant = 2 WHERE [Description] LIKE '%Calvert%' OR [Name] LIKE 'BGE%'; +UPDATE Formats SET ApplicablePlant = 3 WHERE [Description] LIKE '%BNPP%' OR [Name] LIKE 'BNPP%'; +UPDATE Formats SET ApplicablePlant = 4 WHERE [Description] LIKE '%Beaver Valley%' OR [Name] LIKE 'BVPS%'; +UPDATE Formats SET ApplicablePlant = 5 WHERE [Description] LIKE '%Byr-Bwd%' OR ([Name] LIKE 'EXC%' OR [Name] LIKE 'EXEB%' OR [Name] LIKE 'CWE%'); +UPDATE Formats SET ApplicablePlant = 6 WHERE [Description] LIKE '%Callaway%' OR [Name] LIKE 'CAL%'; +UPDATE Formats SET ApplicablePlant = 7 WHERE [Description] LIKE '%Catawba%' OR [Name] LIKE 'CAT%'; +UPDATE Formats SET ApplicablePlant = 8 WHERE [Description] LIKE '%Comanche%' OR ([Name] LIKE 'CAT%' OR [Name] LIKE 'ComPeak%' OR [Name] LIKE 'CPD%' OR [Name] LIKE 'CPF%' OR [Name] LIKE 'CPS%' OR [Name] LIKE 'TUEC%'); +UPDATE Formats SET ApplicablePlant = 9 WHERE [Description] LIKE '%Robinson%' OR [Name] LIKE 'AEP%' OR [Name] LIKE 'RNP%'; +UPDATE Formats SET ApplicablePlant = 10 WHERE [Description] LIKE '%Harris%' OR ([Name] LIKE 'CPLS%' OR [Name] LIKE 'SHE%'); +UPDATE Formats SET ApplicablePlant = 11 WHERE [Description] LIKE '%IP%' OR [Name] LIKE 'IP%'; +UPDATE Formats SET ApplicablePlant = 12 WHERE [Description] LIKE '%Farley%' OR [Name] LIKE 'FNP%'; +UPDATE Formats SET ApplicablePlant = 13 WHERE [Description] LIKE '%Turkey%' OR [Name] LIKE 'FPL%' OR [Name] LIKE 'TP%'; +UPDATE Formats SET ApplicablePlant = 14 WHERE [Description] LIKE '%Ginna%' OR [Name] LIKE 'Ginna%' OR [Name] LIKE 'RGE%'; +UPDATE Formats SET ApplicablePlant = 15 WHERE [Description] LIKE '%Vogtle%' OR [Name] LIKE 'GPC%' OR [Name] LIKE 'VEGP%'; +UPDATE Formats SET ApplicablePlant = 16 WHERE [Description] LIKE '%South Texas%' OR [Name] LIKE 'HLP%' OR [Name] LIKE 'OHLP%'; +UPDATE Formats SET ApplicablePlant = 17 WHERE [Description] LIKE '%McGuire%' OR [Name] LIKE 'MCG%'; +UPDATE Formats SET ApplicablePlant = 18 WHERE [Description] LIKE '%PI%' OR [Name] LIKE 'NSP%'; +UPDATE Formats SET ApplicablePlant = 19 WHERE [Description] LIKE '%Southern Nuclear%' OR [Name] LIKE 'STHN%'; +UPDATE Formats SET ApplicablePlant = 20 WHERE [Description] LIKE '%VC Summer%' OR [Name] LIKE 'SUM%' OR [Name] LIKE 'VCB%' OR [Name] LIKE 'VCS%'; +UPDATE Formats SET ApplicablePlant = 21 WHERE [Description] LIKE '%TVA%' OR [Name] LIKE 'TVA%'; +UPDATE Formats SET ApplicablePlant = 22 WHERE [Description] LIKE '%Wolf%' OR [Name] LIKE 'WCN%'; +UPDATE Formats SET ApplicablePlant = 23 WHERE [Description] LIKE '%Westinghouse%' OR [Name] LIKE 'WST%'; +UPDATE Formats SET ApplicablePlant = 1000 WHERE [Description] LIKE '%Proms%' OR [Description] LIKE '%Generic%' OR [Name] LIKE 'EXP%' OR [Name] LIKE 'Proms%' OR [Name] LIKE 'base%'; + + +/****** Object: StoredProcedure [dbo].[getFormats] Script Date: 9/28/2023 8:42:56 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2018 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +ALTER PROCEDURE [dbo].[getFormats] + +WITH EXECUTE AS OWNER +AS +BEGIN + with formatz([FormatID], [ParentID],[Name],[Description],[Data],[Config],[GenMac],[DTS],[UserID],[LastChanged],[ApplicablePlant]) as + (select [FormatID], [ParentID],[Name],[Description],[Data],[Config],[GenMac],[DTS],[UserID],[LastChanged],[ApplicablePlant] + FROM [dbo].[Formats] fs where DATALENGTH(fs.Data) > 5 + union all -- Child formats + select fs.[FormatID], fs.[ParentID], fs.[Name], fs.[Description], fz.[Data], fs.[Config], fz.[GenMac], fs.[DTS], fs.[UserID], fs.[LastChanged], fs.[ApplicablePlant] + from formats fs + join formatz fz on fz.FormatID = fs.ParentID + where DATALENGTH(fs.Data) = 5) -- the DATALENGTH(fs.Data) = 5 is how to check for empty xml (Data's type is xml) + select * from ( + select *, + (SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formatz].[FormatID]) [ContentCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formatz].[FormatID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formatz].[FormatID]) [FolderCount], + (SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formatz].[FormatID]) [ChildCount] from Formatz) t1 + where Description not like '%(Unused)%' or (ContentCount + DocVersionCount + FolderCount + ChildCount > 0) +END +RETURN + +/****** Object: StoredProcedure [dbo].[getAllFormats] Script Date: 9/28/2023 8:32:15 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2018 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +ALTER PROCEDURE [dbo].[getAllFormats] + +WITH EXECUTE AS OWNER +AS + SELECT * From (SELECT + [FormatID], + [ParentID], + [Name], + [Description], + [Data], + [Config], + [GenMac], + [DTS], + [UserID], + [LastChanged], + [ApplicablePlant], + (SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formats].[FormatID]) [ContentCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formats].[FormatID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formats].[FormatID]) [FolderCount], + (SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formats].[FormatID]) [ChildCount] + FROM [Formats] ) T1 + RETURN + + +/****** Object: StoredProcedure [dbo].[getFormatByName] Script Date: 9/29/2023 12:16:48 PM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +ALTER PROCEDURE [dbo].[getFormatByName] +( + @Name varchar(255) +) +WITH EXECUTE AS OWNER +AS + DECLARE @FormatID INT + Set @FormatID = (select FormatID from Formats where Name = @Name) + BEGIN + with formatz([FormatID], [ParentID],[Name],[Description],[Data],[Config],[GenMac],[DTS],[UserID],[LastChanged],[ApplicablePlant]) as + (select [FormatID], [ParentID],[Name],[Description],[Data],[Config],[GenMac],[DTS],[UserID],[LastChanged],[ApplicablePlant] + FROM [dbo].[Formats] fs where DATALENGTH(fs.Data) > 5 + union all -- Child formats + select fs.[FormatID], fs.[ParentID], fs.[Name], fs.[Description], fz.[Data], fs.[Config], fz.[GenMac], fs.[DTS], fs.[UserID], fs.[LastChanged], fs.[ApplicablePlant] + from formats fs + join formatz fz on fz.FormatID = fs.ParentID + where DATALENGTH(fs.Data) = 5) -- the DATALENGTH(fs.Data) = 5 is how to check for empty xml (Data's type is xml) + select *, + (SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formatz].[FormatID]) [ContentCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formatz].[FormatID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formatz].[FormatID]) [FolderCount], + (SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formatz].[FormatID]) [ChildCount] from Formatz + WHERE [FormatID]=@FormatID + END + + SELECT + [Contents].[ContentID], + [Contents].[Number], + [Contents].[Text], + [Contents].[Type], + [Contents].[FormatID], + [Contents].[Config], + [Contents].[DTS], + [Contents].[UserID], + [Contents].[LastChanged] + FROM [Contents] + WHERE + [Contents].[FormatID]=@FormatID + + + SELECT + [DocVersions].[VersionID], + [DocVersions].[FolderID], + [DocVersions].[VersionType], + [DocVersions].[Name], + [DocVersions].[Title], + [DocVersions].[ItemID], + [DocVersions].[FormatID], + [DocVersions].[Config], + [DocVersions].[DTS], + [DocVersions].[UserID], + [DocVersions].[LastChanged], + [Folders].[ParentID] [Folder_ParentID], + [Folders].[DBID] [Folder_DBID], + [Folders].[Name] [Folder_Name], + [Folders].[Title] [Folder_Title], + [Folders].[ShortName] [Folder_ShortName], + [Folders].[FormatID] [Folder_FormatID], + [Folders].[ManualOrder] [Folder_ManualOrder], + [Folders].[Config] [Folder_Config], + [Folders].[DTS] [Folder_DTS], + [Folders].[UsrID] [Folder_UsrID] + FROM [DocVersions] + JOIN [Folders] ON + [Folders].[FolderID]=[DocVersions].[FolderID] + WHERE + [DocVersions].[FormatID]=@FormatID + + + SELECT + [Folders].[FolderID], + [Folders].[ParentID], + [Folders].[DBID], + [Folders].[Name], + [Folders].[Title], + [Folders].[ShortName], + [Folders].[FormatID], + [Folders].[ManualOrder], + [Folders].[Config], + [Folders].[DTS], + [Folders].[UsrID], + [Folders].[LastChanged], + [Connections].[Name] [Connection_Name], + [Connections].[Title] [Connection_Title], + [Connections].[ConnectionString] [Connection_ConnectionString], + [Connections].[ServerType] [Connection_ServerType], + [Connections].[Config] [Connection_Config], + [Connections].[DTS] [Connection_DTS], + [Connections].[UsrID] [Connection_UsrID] + FROM [Folders] + JOIN [Connections] ON + [Connections].[DBID]=[Folders].[DBID] + WHERE + [Folders].[FormatID]=@FormatID + + RETURN \ No newline at end of file -- 2.47.2 From cbcf7c845d3da41078ef164818e4c068c0ebeda2 Mon Sep 17 00:00:00 2001 From: Chris Glavan Date: Tue, 3 Oct 2023 11:09:47 -0400 Subject: [PATCH 4/6] ~Restructured PROMSFixes.sql to add updates above section that lists RevDate and RevDescription --- PROMS/VEPROMS User Interface/PROMSFixes.Sql | 117 ++++++++++---------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index 244ee6cb..16a1d026 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -21941,63 +21941,6 @@ GO ========================================================================================================== */ - ------------------------------------------------------------------------------ -/* - --------------------------------------------------------------------------- - | ADD New Code Before this Block | - | Change Date and Description | - --------------------------------------------------------------------------- -*/ ------------------------------------------------------------------------------ --- Rebuild / Reorganize All Indexes -exec [dbo].[vesp_UtilityCheckIndexes]; - -IF (@@Error = 0) PRINT 'Running vesp_UtilityCheckIndexes Succeeded' -ELSE PRINT 'Running vesp_UtilityCheckIndexes Failed to Execute' -GO - - -IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetSQLCodeRevision]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) - DROP PROCEDURE [vesp_GetSQLCodeRevision]; -GO - -/***************************************************************************** - Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE - Copyright 2022 - Volian Enterprises, Inc. All rights reserved. -*****************************************************************************/ -CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision] -WITH EXECUTE AS OWNER -AS -BEGIN TRY -- Try Block - BEGIN TRANSACTION - -- Change information in the next line when you are done - set nocount on - DECLARE @RevDate varchar(255) - DECLARE @RevDescription varchar(255) - - set @RevDate = '10/03/2022 2:00 PM' - set @RevDescription = 'B2022-124: [JPR] Blank RO Values (All Spaces) printing as ?' - - Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription - PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription - IF( @@TRANCOUNT > 0 ) COMMIT -END TRY -BEGIN CATCH -- Catch Block - IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level - ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback - EXEC vlnErrorHandler -END CATCH -GO --- Display the status of Proc creation -IF (@@Error = 0) PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Succeeded' -ELSE PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Error on Creation' -go - -Exec vesp_GetSQLCodeRevision; - - - /****** Add the ApplicablePlant field to the Formats table ******/ ALTER TABLE Formats ADD ApplicablePlant int NULL; GO @@ -22200,4 +22143,62 @@ AS WHERE [Folders].[FormatID]=@FormatID - RETURN \ No newline at end of file + RETURN + + +----------------------------------------------------------------------------- +/* + --------------------------------------------------------------------------- + | ADD New Code Before this Block | + | Change Date and Description | + --------------------------------------------------------------------------- +*/ +----------------------------------------------------------------------------- +-- Rebuild / Reorganize All Indexes +exec [dbo].[vesp_UtilityCheckIndexes]; + +IF (@@Error = 0) PRINT 'Running vesp_UtilityCheckIndexes Succeeded' +ELSE PRINT 'Running vesp_UtilityCheckIndexes Failed to Execute' +GO + + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetSQLCodeRevision]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_GetSQLCodeRevision]; +GO + +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2022 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision] +WITH EXECUTE AS OWNER +AS +BEGIN TRY -- Try Block + BEGIN TRANSACTION + -- Change information in the next line when you are done + set nocount on + DECLARE @RevDate varchar(255) + DECLARE @RevDescription varchar(255) + + set @RevDate = '10/03/2023 11:00 AM' + set @RevDescription = 'C2023-017: Added logic to filter the format list when selecting a format to be applied to a section' + + Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription + PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription + IF( @@TRANCOUNT > 0 ) COMMIT +END TRY +BEGIN CATCH -- Catch Block + IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level + ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback + EXEC vlnErrorHandler +END CATCH +GO +-- Display the status of Proc creation +IF (@@Error = 0) PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Succeeded' +ELSE PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Error on Creation' +go + +Exec vesp_GetSQLCodeRevision; + + + -- 2.47.2 From f37872e2092f09d2f42b571178ae32ebba2e30ac Mon Sep 17 00:00:00 2001 From: John Jenko Date: Wed, 4 Oct 2023 11:38:00 -0400 Subject: [PATCH 5/6] =?UTF-8?q?C2023-016=20=E2=80=93=20Expanded=20Find/Rep?= =?UTF-8?q?lace=20to=20search=20through=20all=20of=20the=20step=20editor?= =?UTF-8?q?=20sections=20in=20the=20same=20procedure.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DisplayTabControl.cs | 7 +- .../FindReplace.Designer.cs | 4 +- PROMS/Volian.Controls.Library/FindReplace.cs | 164 +++++++++--------- 3 files changed, 90 insertions(+), 85 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index c995e33d..eb9fe50c 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -570,7 +570,9 @@ namespace Volian.Controls.Library /// /// /// - public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus) + // C2023-016 Added doingFindReplace where if true Word section will not be opened - used only when doing Find/Replace + // We are not opening and searching inside Word sections, instead we just stop on the section title in the procedure editor (if a match is found in the title) + public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus, bool doingFindReplace=false) { ItemInfo myItemInfo = myItemInfo2; @@ -649,7 +651,8 @@ namespace Volian.Controls.Library _MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item. - if (myItemInfo.MyContent.MyEntry == null) // If it is not a Word document open in step editor + // C2023-016 if a Word section and doing Find/Replace don't open Word section, position to section title in step editor instead + if (myItemInfo.MyContent.MyEntry == null || doingFindReplace) // If it is not a Word document open in step editor { return OpenStepTabPage(myItemInfo, setFocus); } diff --git a/PROMS/Volian.Controls.Library/FindReplace.Designer.cs b/PROMS/Volian.Controls.Library/FindReplace.Designer.cs index b33046f0..57fcdad4 100644 --- a/PROMS/Volian.Controls.Library/FindReplace.Designer.cs +++ b/PROMS/Volian.Controls.Library/FindReplace.Designer.cs @@ -183,7 +183,6 @@ namespace Volian.Controls.Library this.cmboFindText.WatermarkFont = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmboFindText.WatermarkText = "Enter text to find"; this.cmboFindText.TextChanged += new System.EventHandler(this.cmboFindText_TextChanged); - this.cmboFindText.Leave += new System.EventHandler(this.cmboFindText_Leave); // // labelX3 // @@ -349,6 +348,7 @@ namespace Volian.Controls.Library this.cbxReverse.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.cbxReverse.TabIndex = 5; this.cbxReverse.Text = "Reverse Find"; + this.cbxReverse.CheckedChanged += new System.EventHandler(this.cbxReverse_CheckedChanged); // // cbxWholeWord // @@ -363,6 +363,7 @@ namespace Volian.Controls.Library this.cbxWholeWord.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.cbxWholeWord.TabIndex = 4; this.cbxWholeWord.Text = "Whole Word"; + this.cbxWholeWord.CheckedChanged += new System.EventHandler(this.cbxWholeWord_CheckedChanged); // // cbxCaseSensitive // @@ -377,6 +378,7 @@ namespace Volian.Controls.Library this.cbxCaseSensitive.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.cbxCaseSensitive.TabIndex = 3; this.cbxCaseSensitive.Text = "Case Sensitive"; + this.cbxCaseSensitive.CheckedChanged += new System.EventHandler(this.cbxCaseSensitive_CheckedChanged); // // cmbScope // diff --git a/PROMS/Volian.Controls.Library/FindReplace.cs b/PROMS/Volian.Controls.Library/FindReplace.cs index efec8fc0..8a03c091 100644 --- a/PROMS/Volian.Controls.Library/FindReplace.cs +++ b/PROMS/Volian.Controls.Library/FindReplace.cs @@ -11,11 +11,13 @@ using JR.Utils.GUI.Forms; namespace Volian.Controls.Library { + // C2023-016 - Upgrade - have Find/Replace spin through all of the Step Editor sections within the current procedure public partial class FindReplace : DevComponents.DotNetBar.Office2007Form { private bool doingfind = false; private bool findingbookmarks = false; private bool _FoundIt = false; + private ItemInfo _StartingItemInfo = null;// C2023-016 used to remember where we started doing the Find/Replace public bool FoundIt { get { return _FoundIt; } @@ -25,7 +27,7 @@ namespace Volian.Controls.Library { get { - // B2022-067 get display text version to convert 8209 dash to nornal (keyboard) dash + // B2022-067 get display text version to convert 8209 dash to normal (keyboard) dash string selStr = ItemInfo.ConvertToDisplayText(MyEditItem.MyStepRTB.SelectedText); if (!cbxCaseSensitive.Checked) return selStr.ToUpper() == cmboFindText.Text.ToUpper(); @@ -33,7 +35,6 @@ namespace Volian.Controls.Library return selStr == cmboFindText.Text; } } - //private bool _offsetStartPos = false; private EditItem _MyEditItem; public EditItem MyEditItem { @@ -44,25 +45,13 @@ namespace Volian.Controls.Library if (_MyEditItem == null) return; _MyDocVersion = _MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; SetupContextMenu(); - //_offsetStartPos = false; // in a different rtf box, don't offset find position first time around } } private DocVersionInfo _MyDocVersion; public DocVersionInfo Mydocversion { get { return _MyDocVersion; } - set - { - _MyDocVersion = value; - //if (_MyDocVersion != null) - //{ - // if (_MyDocVersion.DocVersionAssociationCount > 0) - // { - // MyROFSTLookup = _MyDocVersion.DocVersionAssociations[0].MyROFst.ROFSTLookup; - // _MyRODbID = _MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID; - // } - //} - } + set {_MyDocVersion = value; } } private DisplayBookMarks _myDisplayBookMarks; @@ -83,17 +72,12 @@ namespace Volian.Controls.Library { InitializeComponent(); LoadFindReplaceTextListBox(); - //if (dvi != null && dvi.VersionType > 127) - // InApproved = false; // in approved cmbScope.SelectedIndex = 0; btnBookMrkAll.Enabled = false; btnFindNext.Enabled = false; btnReplace.Enabled = false; btnRplAll.Enabled = false; - //if (MyRTBItem.MyStepRTB.SelectionLength > 0) - // cmboFindText.Text = MyRTBItem.MyStepRTB.SelectedText; cmboFindText.Focus(); - //SetupContextMenu(); } private void LoadFindReplaceTextListBox() { @@ -113,51 +97,34 @@ namespace Volian.Controls.Library } } - //public FindReplace(RTBItem stpitm) - //{ - // MyRTBItem = stpitm; - // DocVersionInfo dvi = MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; - // InitializeComponent(); - // if (dvi != null && dvi.VersionType > 127) - // InApproved = false; // in approved - // cmbScope.SelectedIndex = 0; - // btnBookMrkAll.Enabled = false; - // btnFindNext.Enabled = false; - // btnReplace.Enabled = false; - // btnRplAll.Enabled = false; - // if (MyRTBItem.MyStepRTB.SelectionLength > 0) - // cmboFindText.Text = MyRTBItem.MyStepRTB.SelectedText; - // cmboFindText.Focus(); - //} - // bug fix: B2016-107, when Find/Replace is initially opened, set the cursor focus to the Find Text box (called from frmVEPROMS.cs) public void SetFocusToTextBox() { cmboFindText.Focus(); } + private bool DoingClick = false; // Don't allow a button to be clicked until processing is complete for the last button + private void btnReplace_Click(object sender, EventArgs e) { if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button - DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = true;// We started processing a click DoReplace(); - DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = false;// we're done processing the click } private void DoReplace() { if (!IsFound) DoFindNext(); else - { MyEditItem.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, false, null); - } } private void btnRplAll_Click(object sender, EventArgs e) { if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button - DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = true; // We started processing a click DoRplAll(); - DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = false; // we're done processing the click } private void DoRplAll() { @@ -172,9 +139,9 @@ namespace Volian.Controls.Library private void btnBookMrkAll_Click(object sender, EventArgs e) { if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button - DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = true; // We started processing a click DoBookMrkAll(); - DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = false; // we're done processing the click } private void DoBookMrkAll() { @@ -193,7 +160,6 @@ namespace Volian.Controls.Library } private void btnFndRplDone_Click(object sender, EventArgs e) { - //this.Close(); doingfind = false; this.Visible = false; } @@ -229,10 +195,48 @@ namespace Volian.Controls.Library private void btnFindNext_Click(object sender, EventArgs e) { if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button - DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = true;// We started processing a click DoFindNext(); - DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button + DoingClick = false;// we're done processing the click } + + // C2023-016 Find the next element, but stay in the same procedure + private ItemInfo FindNextStepElement(ItemInfo curStepElem, string fndStr) + { + ItemInfo nxtStepElem = curStepElem; + if (_StartingItemInfo == null) + _StartingItemInfo = MyEditItem.MyItemInfo; + if (cbxReverse.Checked) + { + if (curStepElem.IsProcedure) + nxtStepElem = curStepElem.MyProcedure.SearchBottom; // at the top of the procedure, so next step would be the last step of the last section (or the section title if the last section is a Word section) + else + nxtStepElem = curStepElem.SearchPrev; + } + else if (curStepElem.SearchNext.IsProcedure) // searching(finding) forward but next is the next procedure, so jump to the top of the procedure (the procedure title in the step editor) + nxtStepElem = curStepElem.MyProcedure; + else + nxtStepElem = curStepElem.SearchNext; + // B2015-131 Find was not finding series of words when one or more of the words were bolded or underlined (ex finding "Any SG" where Any was bolded) + while (nxtStepElem != null && nxtStepElem.ItemID != _StartingItemInfo.ItemID) + { + if (nxtStepElem.MyContent != null && ContainsFndStr(RtfTools.RTFConvertedSymbolsToUnicode(nxtStepElem.MyContent.Text).ToUpper(), fndStr.ToUpper())) + break; + if (cbxReverse.Checked) + { + if (nxtStepElem.IsProcedure) + nxtStepElem = nxtStepElem.MyProcedure.SearchBottom;// at the top of the procedure, so next step would be the last step of the last section (or the section title if the last section is a Word section) + else + nxtStepElem = nxtStepElem.SearchPrev; + } + else if (nxtStepElem.SearchNext.IsProcedure) + nxtStepElem = nxtStepElem.MyProcedure;// searching(finding) forward but next is the next procedure, so jump to the top of the procedure(the procedure title in the step editor) + else + nxtStepElem = nxtStepElem.SearchNext; + } + return nxtStepElem; + } + private void DoFindNext() { AddToComboLists(); @@ -240,32 +244,21 @@ namespace Volian.Controls.Library string fndStr = FixSymbol(cmboFindText.Text.Replace(@"\", @"\u9586?").Replace("-", @"\u8209?").Replace("\xa0", @"\u160?")); while (!MyEditItem.FindText(cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked)) { - ItemInfo next = (cbxReverse.Checked) ? MyEditItem.MyItemInfo.SearchPrev : MyEditItem.MyItemInfo.SearchNext; + ItemInfo next = FindNextStepElement(MyEditItem.MyItemInfo, fndStr); - // B2015-131 Find was not finding series of words when one or more of the words were bolded or underlined (ex finding "Any SG" where Any was bolded) - while ((next != null) && !next.IsSection && !ContainsFndStr(RtfTools.RTFConvertedSymbolsToUnicode(next.MyContent.Text).ToUpper(), fndStr.ToUpper())) - { - next = (cbxReverse.Checked) ? next.SearchPrev : next.SearchNext; - } - //if (next != null) Console.WriteLine("next {0} {1}", next.ItemID, next.MyContent.Text); - if ((next == null) || next.IsSection) - { - if (!findingbookmarks) - { - // C2020-015: Improve dialog messaging - if (cbxReverse.Checked) - FlexibleMessageBox.Show(this, "Nothing found here to beginning of this section", "End of Find/Replace"); - else - FlexibleMessageBox.Show(this, "Nothing found here to end of this section", "End of Find/Replace"); - } - FoundIt = false; - return; - } - - MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next); + MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(next,true,true);// C2023-016 open item (next), set focus (true), doing Find/Replace so don't open Word section (true) if (cbxReverse.Checked) MyEditItem.PositionToEnd(); if (next.IsTable && !cbxReverse.Checked) MyEditItem.PositionToStart(); + //C2023-016 if we spun through all of the step editor sections, stop and display a message + if (MyEditItem.MyItemInfo.ItemID == _StartingItemInfo.ItemID) + { + FoundIt = false; + string msg = string.Format("Back to the starting point of the Find/Replace.{0}",(findingbookmarks)?"\n\n The Tools Panel will display showing the locations.":""); + FlexibleMessageBox.Show(this, msg, "Find/Replace Completed"); + _StartingItemInfo = null; + return; + } } if (MyEditItem.MyStepRTB != null && !MyEditItem.MyStepRTB.Visible) { @@ -286,7 +279,7 @@ namespace Volian.Controls.Library { if (cmboFindText.Items.Count >= 10) cmboFindText.Items.RemoveAt(9); - cmboFindText.Items.Insert(0, cmboFindText.Text);//.Add(cmboFindText.Text); + cmboFindText.Items.Insert(0, cmboFindText.Text); } hastext = this.cmboReplaceText.Text.Length > 0; if (hastext && btnReplace.Enabled && !cmboReplaceText.Items.Contains(cmboReplaceText.Text)) @@ -302,11 +295,13 @@ namespace Volian.Controls.Library btnFindNext.Enabled = hastext; btnBookMrkAll.Enabled = hastext; btnReplace.Enabled = btnRplAll.Enabled = hastext && !InApproved; + _StartingItemInfo = null; //C2023-016 reset the starting position } private void cmboReplaceText_TextChanged(object sender, EventArgs e) { btnReplace.Enabled = btnRplAll.Enabled = !InApproved && cmboFindText.Text.Length > 0; + _StartingItemInfo = null;//C2023-016 reset the starting position } public void PerformFindNext() @@ -336,17 +331,6 @@ namespace Volian.Controls.Library e.Cancel = true; // cancel the form close event - the Done_Click() will hide it instead } - private void cmboFindText_Leave(object sender, EventArgs e) - { - //bool hastext = this.cmboFindText.Text.Length > 0; - //if (hastext && !cmboFindText.Items.Contains(cmboFindText.Text)) - //{ - // if (cmboFindText.Items.Count >= 10) - // cmboFindText.Items.RemoveAt(9); - // cmboFindText.Items.Insert(0, cmboFindText.Text);//.Add(cmboFindText.Text); - //} - } - private void btnCmCut_Click(object sender, EventArgs e) { Clipboard.Clear(); @@ -456,6 +440,22 @@ namespace Volian.Controls.Library tabReplace.Visible = true; Text = "Find and Replace";//C2021-021 change the dialog title } + _StartingItemInfo = null;//C2023-016 reset the starting position + } + + private void cbxCaseSensitive_CheckedChanged(object sender, EventArgs e) + { + _StartingItemInfo = null;//C2023-016 reset the starting position + } + + private void cbxWholeWord_CheckedChanged(object sender, EventArgs e) + { + _StartingItemInfo = null;//C2023-016 reset the starting position + } + + private void cbxReverse_CheckedChanged(object sender, EventArgs e) + { + _StartingItemInfo = null;//C2023-016 reset the starting position } } } \ No newline at end of file -- 2.47.2 From 8f17b49287d3d2146793f3948b5a12e0c5b3c9d8 Mon Sep 17 00:00:00 2001 From: Chris Glavan Date: Thu, 5 Oct 2023 15:29:50 -0400 Subject: [PATCH 6/6] ~Modified PROMSFixes.sql to update ApplicablePlant formats that are Generic before updating plant-specific due to potential for a plant-specific format description to have the word generic in it. --- PROMS/VEPROMS User Interface/PROMSFixes.Sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PROMS/VEPROMS User Interface/PROMSFixes.Sql b/PROMS/VEPROMS User Interface/PROMSFixes.Sql index 16a1d026..fddfb39c 100644 --- a/PROMS/VEPROMS User Interface/PROMSFixes.Sql +++ b/PROMS/VEPROMS User Interface/PROMSFixes.Sql @@ -21950,6 +21950,7 @@ GO --This update statement corrects a typo in the name of one of the format records UPDATE Formats SET [Description] = REPLACE([Description], 'Robimson', 'Robinson') WHERE [Description] LIKE '%Robimson%'; +UPDATE Formats SET ApplicablePlant = 1000 WHERE [Description] LIKE '%Proms%' OR [Description] LIKE '%Generic%' OR [Name] LIKE 'EXP%' OR [Name] LIKE 'Proms%' OR [Name] LIKE 'base%'; UPDATE Formats SET ApplicablePlant = 1 WHERE [Description] LIKE '%DC Cook%' OR [Name] LIKE 'AEP%'; UPDATE Formats SET ApplicablePlant = 2 WHERE [Description] LIKE '%Calvert%' OR [Name] LIKE 'BGE%'; UPDATE Formats SET ApplicablePlant = 3 WHERE [Description] LIKE '%BNPP%' OR [Name] LIKE 'BNPP%'; @@ -21973,7 +21974,6 @@ UPDATE Formats SET ApplicablePlant = 20 WHERE [Description] LIKE '%VC Summer%' O UPDATE Formats SET ApplicablePlant = 21 WHERE [Description] LIKE '%TVA%' OR [Name] LIKE 'TVA%'; UPDATE Formats SET ApplicablePlant = 22 WHERE [Description] LIKE '%Wolf%' OR [Name] LIKE 'WCN%'; UPDATE Formats SET ApplicablePlant = 23 WHERE [Description] LIKE '%Westinghouse%' OR [Name] LIKE 'WST%'; -UPDATE Formats SET ApplicablePlant = 1000 WHERE [Description] LIKE '%Proms%' OR [Description] LIKE '%Generic%' OR [Name] LIKE 'EXP%' OR [Name] LIKE 'Proms%' OR [Name] LIKE 'base%'; /****** Object: StoredProcedure [dbo].[getFormats] Script Date: 9/28/2023 8:42:56 AM ******/ -- 2.47.2