Code on Part Load show/hide controls. Is there a better way?

We have a lot of code that is called on form load for Part. The gist of the code is to hide/show fields and labels based on which menu the Part Entry form was called from. We are going through an upgrade. (10.2.200 -> 10.2.600), and thought it would be a good time to remove the code. Blame the upgrade. lol

Question. Is this a good idea? Is there a better way of managing the controls on the screen? Just trying to clean up code where we can so that if we ever want to get to the Kinetic Framework we are maybe closer? Plus this has been a pain to maintain, as Part Entry is in multiple menu spots. So folks that have access to multiple menu items have to remember which to perform certain functions.

Ignore the name of controls, we have been cleaning those up as well.

	private void SetControlProperties( string process )
	{   try
		{

// Order Management OR Quality Assurance OR Inventory Management

			if ( ( process == "OMMT1112" ) || ( process == "QAMN0150" ) || ( process == "IMMT1102" ) || ( process == "PHMN1040" ) )
			{
			txt_SourcingComments.ReadOnly = true;

#region Upper tabs

			dockmanager_AccountingTab.Visible = true;
			dockmanager_ReportingTab.Visible = true;
			dockmanager_IntegrationsTab.Visible = true;
			dockmanager_AlternatesTab.Visible = true;
			dockmanager_UOMsTab.Visible = true;
			dockmanager_LotsTab.Visible = true;
			dockmanager_PlantsTab.Visible = true;

			LCM.Visible = true;
			PartClassDetails.Visible = true;

			PartDisposition.Visible = true;
			PartDisposition.EpiTabbingEnabled = true;

#endregion Upper tabs

#region Detail tab

			groupbox_Weight.Visible = true;
			groupbox_Lock.Visible = true;
			groupbox_Hold.Visible = true;
			groupbox_Tracking.Visible = true;
			groupbox_DefaultParam.Visible = true;

			lblInspectionClass.Visible = true;  //Inspection Class
			epiUltraComboC3.Visible = true; //Inspection Class

			lbl_Type.Visible = true;    //Type
			combo_Type.Visible = true;  //Type

			lbl_UOMClass.Visible = true;    //UOM Class
			uomclasscombo_UOMClass.Visible = true;  //UOM Class

			lbl_Inventory.Visible = true;   //Inventory
			uomcombo_Inventory.Visible = true;  //Inventory

			lbl_Sales.Visible = true;   //Sales
			uomcombo_Sales.Visible = true;  //Sales

			lbl_Purchasing.Visible = true;  //Purchasing
			uomcombo_Purchasing.Visible = true; //Purchasing

			lbl_PrimaryUOMs.Visible = true; //Primary UOMs

			lbl_SalesUnitPrice.Visible = true;  //Sales Unit Price
			numeric_SalesUnitPrice.Visible = true;  //Sales Unit Price
			combo_PricePerCode.Visible = true;
			txt_SalesPriceUM.Visible = true;

			lbl_Group.Visible = true;   //Group
			prodgrupcombo_ProductGroup.Visible = true;  //Group

			lbl_Class.Visible = true;   //Class
			partclasscombo_Class.Visible = true;    //Class

			epiLabelC23.Visible = true; //Customer Warranty
			epiUltraComboC2.Visible = true; //Customer Warranty

			lblCustomer.Visible = true; //Customer
			combo_Customers.Visible = true; //Customers

			lbl_TaxCategory.Visible = true;
			taxcatcombo_TaxCategory.Visible = true;

			button_CommodityCode.Visible = true;

			txt_CommodityCode.Visible = true;   //Commodity Code
			txt_CommodityCodeDesc.Visible = true;   //Commodity Code Description

			lbl_PrimaryCountry.Visible = true;  //Primary Country
			countrycombo_CountryOfOrigin.Visible = true;    //Primary Country

			epiLabelC25.Visible = true; //Customer Lead Time
			epiNumericEditorC2.Visible = true;  //Customer Lead Time

#endregion Detail tab

#region Revisions tab

			epiLabelC27.Visible = true; //Build Instruction Revision
			epiTextBoxC32.Visible = true;   //Build Instruction Revision

			lblFirmPackRev.Visible = true;  //Firmware Package Revision
			txtFirmPackRef.Visible = true;  //Firmware Package Revision

			//'epiLabelC26.Visible = true; //Use Method for Forecasting
			//'epiCheckBoxC7.Visible = true;   //Use Method for Forecasting

			lblFinTestRev.Visible = true;   //Final Test Revision
			txtFinTestRev.Visible = true;   //Final Test Revision

			lbl_Concurrency.Visible = true; //Concurrency
			combo_Concurrency.Visible = true;   //Concurrency

			lblImageID.Visible = true;  //Image ID
			txtImageID.Visible = true;  //Image ID

			lblRevStatus.Visible = true;    //Rev Status
			cboRevStatus.Visible = true;    //Rev Status

			lbl_Deviations.Visible = true;  //Deviation( s )
			txt_Deviations.Visible = true;  //Deviation( s )

#endregion Revisions tab

#region Disposition tab

			lbl_PreviousDisposition.Visible = true;
			lbl_PreviousDispositionDate.Visible = true;
			lbl_PreviousAction.Visible = true;
			lbl_DispositionNotes.Visible = true;
			lbl_CurrentDisposition.Visible = true;
			lbl_CurrentDispositionDate.Visible = true;
			lbl_CurrentAction.Visible = true;

			txt_PreviousDisposition.Visible = true;
			txt_PreviousAction.Visible = true;
			txt_DispositionNotes.Visible = true;
			txt_CurrentDisposition.Visible = true;
			txt_CurrentAction.Visible = true;

			datetime_PreviousDispositionDate.Visible = true;
			datetime_CurrentDispositionDate.Visible = true;

#endregion Disposition tab

			} //   end if ( ( process == "OMMT1112" ) || ( process == "QAMN0150" ) || ( process == "IMMT1102" ) || ( process == "PHMN1040" ) )

// Purchase Management OR Job Management

			else if ( ( process == "PMMT1002" ) || ( process == "JCMT1020" ) )
			{
				txt_SourcingComments.ReadOnly = false;

#region Upper tabs

				dockmanager_AccountingTab.Visible = true;
				dockmanager_ReportingTab.Visible = true;
				dockmanager_IntegrationsTab.Visible = true;
				dockmanager_AlternatesTab.Visible = true;
				dockmanager_UOMsTab.Visible = true;
				dockmanager_LotsTab.Visible = true;
				dockmanager_PlantsTab.Visible = true;

				LCM.Visible = true;
				PartClassDetails.Visible = true;
				PartDisposition.Visible = true;

#endregion Upper tabs

#region Detail tab

				groupbox_Weight.Visible = true;
				groupbox_Lock.Visible = true;
				groupbox_Hold.Visible = true;
				groupbox_Tracking.Visible = true;
				groupbox_DefaultParam.Visible = true;

				lblInspectionClass.Visible = true;  //Inspection Class
				epiUltraComboC3.Visible = true; //Inspection Class

				lbl_Type.Visible = true;    //Type
				combo_Type.Visible = true;  //Type

				lbl_UOMClass.Visible = true;    //UOM Class
				uomclasscombo_UOMClass.Visible = true;  //UOM Class

				lbl_Inventory.Visible = true;   //Inventory
				uomcombo_Inventory.Visible = true;  //Inventory

				lbl_Sales.Visible = true;   //Sales
				uomcombo_Sales.Visible = true;  //Sales

				lbl_Purchasing.Visible = true;  //Purchasing
				uomcombo_Purchasing.Visible = true; //Purchasing

				lbl_PrimaryUOMs.Visible = true; //Primary UOMs

				lbl_SalesUnitPrice.Visible = true;  //Sales Unit Price
				numeric_SalesUnitPrice.Visible = true;  //Sales Unit Price
				combo_PricePerCode.Visible = true;
				txt_SalesPriceUM.Visible = true;

				lbl_Group.Visible = true;   //Group
				prodgrupcombo_ProductGroup.Visible = true;  //Group

				lbl_Class.Visible = true;   //Class
				partclasscombo_Class.Visible = true;    //Class

				epiLabelC23.Visible = true; //Customer Warranty
				epiUltraComboC2.Visible = true; //Customer Warranty

				lblCustomer.Visible = true; //Customer
				combo_Customers.Visible = true; //Customers

				lbl_TaxCategory.Visible = true;
				taxcatcombo_TaxCategory.Visible = true;

				button_CommodityCode.Visible = true;

				txt_CommodityCode.Visible = true;   //Commodity Code
				txt_CommodityCodeDesc.Visible = true;   //Commodity Code Description

				lbl_PrimaryCountry.Visible = true;  //Primary Country
				countrycombo_CountryOfOrigin.Visible = true;    //Primary Country

				epiLabelC25.Visible = true; //Customer Lead Time
				epiNumericEditorC2.Visible = true;  //Customer Lead Time

#endregion Detail tab

#region Revisions tab

				epiLabelC27.Visible = true; //Build Instruction Revision
				epiTextBoxC32.Visible = true;   //Build Instruction Revision

				lblFirmPackRev.Visible = true;  //Firmware Package Revision
				txtFirmPackRef.Visible = true;  //Firmware Package Revision

				//'epiLabelC26.Visible = true; //Use Method for Forecasting
				//'epiCheckBoxC7.Visible = true;   //Use Method for Forecasting

				lblFinTestRev.Visible = true;   //Final Test Revision
				txtFinTestRev.Visible = true;   //Final Test Revision

				lbl_Concurrency.Visible = true; //Concurrency
				combo_Concurrency.Visible = true;   //Concurrency

				lblImageID.Visible = true;  //Image ID
				txtImageID.Visible = true;  //Image ID

				lblRevStatus.Visible = true;    //Rev Status
				cboRevStatus.Visible = true;    //Rev Status

				lbl_Deviations.Visible = true;  //Deviation( s )
				txt_Deviations.Visible = true;  //Deviation( s )

#endregion Revisions tab

#region Disposition tab

				lbl_PreviousDisposition.Visible = true;
				lbl_PreviousDispositionDate.Visible = true;
				lbl_PreviousAction.Visible = true;
				lbl_DispositionNotes.Visible = true;
				lbl_CurrentDisposition.Visible = true;
				lbl_CurrentDispositionDate.Visible = true;
				lbl_CurrentAction.Visible = true;

				txt_PreviousDisposition.Visible = true;
				txt_PreviousAction.Visible = true;
				txt_DispositionNotes.Visible = true;
				txt_CurrentDisposition.Visible = true;
				txt_CurrentAction.Visible = true;

				datetime_PreviousDispositionDate.Visible = true;
				datetime_CurrentDispositionDate.Visible = true;

#endregion Disposition tab

			} //   end else if ( ( process == "PMMT1002" ) || ( process == "JCMT1020" ) )

// Case Management OR Material Requirements Planning

			else if ( ( process == "UDPart" ) || ( process == "MRMT1010" ) )
			{
				txt_SourcingComments.ReadOnly = true;

#region Upper tabs

				dockmanager_AccountingTab.Visible = false;
				dockmanager_AccountingTab.EpiTabbingEnabled = false;
				dockmanager_AccountingTab.Dispose( );

				dockmanager_ReportingTab.Visible = false;
				dockmanager_ReportingTab.EpiTabbingEnabled = false;
				dockmanager_ReportingTab.Dispose( );

				dockmanager_IntegrationsTab.Visible = false;
				dockmanager_IntegrationsTab.EpiTabbingEnabled = false;
				dockmanager_IntegrationsTab.Dispose( );

				dockmanager_AlternatesTab.Visible = false;
				dockmanager_AlternatesTab.EpiTabbingEnabled = false;
				dockmanager_AlternatesTab.Dispose( );

				dockmanager_UOMsTab.Visible = false;
				dockmanager_UOMsTab.EpiTabbingEnabled = false;
				dockmanager_UOMsTab.Dispose( );

				dockmanager_LotsTab.Visible = false;
				dockmanager_LotsTab.EpiTabbingEnabled = false;
				dockmanager_LotsTab.Dispose( );

				dockmanager_PlantsTab.Visible = false;
				dockmanager_PlantsTab.EpiTabbingEnabled = false;
				dockmanager_PlantsTab.Dispose( );

				LCM.Visible = false;
				LCM.EpiTabbingEnabled = false;
				LCM.Dispose( );

				PartClassDetails.Visible = false;
				PartClassDetails.EpiTabbingEnabled = false;
				PartClassDetails.Dispose( );

				PartDisposition.Visible = true;
				PartDisposition.EpiTabbingEnabled = true;

#endregion Upper tabs

#region Detail tab

				groupbox_Weight.Visible = false;
				groupbox_Lock.Visible = false;
				groupbox_Hold.Visible = false;
				groupbox_Tracking.Visible = false;
				groupbox_DefaultParam.Visible = false;

				lblInspectionClass.Visible = false;  //Inspection Class
				epiUltraComboC3.Visible = false; //Inspection Class

				lbl_Type.Visible = false;    //Type
				combo_Type.Visible = false;  //Type

				lbl_UOMClass.Visible = false;    //UOM Class
				uomclasscombo_UOMClass.Visible = false;  //UOM Class

				lbl_Inventory.Visible = false;   //Inventory
				uomcombo_Inventory.Visible = false;  //Inventory

				lbl_Sales.Visible = false;   //Sales
				uomcombo_Sales.Visible = false;  //Sales

				lbl_Purchasing.Visible = false;  //Purchasing
				uomcombo_Purchasing.Visible = false; //Purchasing

				lbl_PrimaryUOMs.Visible = false; //Primary UOMs

				lbl_SalesUnitPrice.Visible = false;  //Sales Unit Price
				numeric_SalesUnitPrice.Visible = false;  //Sales Unit Price
				combo_PricePerCode.Visible = false;
				txt_SalesPriceUM.Visible = false;

				lbl_Group.Visible = false;   //Group
				prodgrupcombo_ProductGroup.Visible = false;  //Group

				lbl_Class.Visible = false;   //Class
				partclasscombo_Class.Visible = false;    //Class

				epiLabelC23.Visible = false; //Customer Warranty
				epiUltraComboC2.Visible = false; //Customer Warranty

				lblCustomer.Visible = false; //Customer
				combo_Customers.Visible = false; //Customers

				lbl_TaxCategory.Visible = false;
				taxcatcombo_TaxCategory.Visible = false;

				button_CommodityCode.Visible = false;

				txt_CommodityCode.Visible = false;   //Commodity Code
				txt_CommodityCodeDesc.Visible = false;   //Commodity Code Description

				lbl_PrimaryCountry.Visible = false;  //Primary Country
				countrycombo_CountryOfOrigin.Visible = false;    //Primary Country

				epiLabelC25.Visible = false; //Customer Lead Time
				epiNumericEditorC2.Visible = false;  //Customer Lead Time

#endregion Detail tab

#region Revisions tab

				epiLabelC27.Visible = false; //Build Instruction Revision
				epiTextBoxC32.Visible = false;   //Build Instruction Revision

				lblFirmPackRev.Visible = false;  //Firmware Package Revision
				txtFirmPackRef.Visible = false;  //Firmware Package Revision

			//	'epiLabelC26.Visible = false; //Use Method for Forecasting
			//	'epiCheckBoxC7.Visible = false;   //Use Method for Forecasting

				lblFinTestRev.Visible = false;   //Final Test Revision
				txtFinTestRev.Visible = false;   //Final Test Revision

				lbl_Concurrency.Visible = false; //Concurrency
				combo_Concurrency.Visible = false;   //Concurrency

				lblImageID.Visible = false;  //Image ID
				txtImageID.Visible = false;  //Image ID

				lblRevStatus.Visible = false;    //Rev Status
				cboRevStatus.Visible = false;    //Rev Status

				lbl_Deviations.Visible = false;  //Deviation( s )
				txt_Deviations.Visible = false;  //Deviation( s )

#endregion Revisions tab

#region Disposition tab

				lbl_PreviousDisposition.Visible = true;
				lbl_PreviousDispositionDate.Visible = true;
				lbl_PreviousAction.Visible = true;
				lbl_DispositionNotes.Visible = true;
				lbl_CurrentDisposition.Visible = true;
				lbl_CurrentDispositionDate.Visible = true;
				lbl_CurrentAction.Visible = true;

				txt_PreviousDisposition.Visible = true;
				txt_PreviousAction.Visible = true;
				txt_DispositionNotes.Visible = true;
				txt_CurrentDisposition.Visible = true;
				txt_CurrentAction.Visible = true;

				datetime_PreviousDispositionDate.Visible = true;
				datetime_CurrentDispositionDate.Visible = true;

#endregion Disposition tab

			} //   end else if ( ( process == "UDPart" ) || ( process == "MRMT1010" ) )

// Engineering

			else if ( process == "SEMN1010" )
			{
				txt_SourcingComments.ReadOnly = true;

#region Upper tabs

				dockmanager_AccountingTab.Visible = false;
				dockmanager_AccountingTab.EpiTabbingEnabled = false;
//dockmanager_AccountingTab.Dispose( );

				dockmanager_ReportingTab.Visible = false;
				dockmanager_ReportingTab.EpiTabbingEnabled = false;
//dockmanager_ReportingTab.Dispose( );

				dockmanager_IntegrationsTab.Visible = false;
				dockmanager_IntegrationsTab.EpiTabbingEnabled = false;
//dockmanager_IntegrationsTab.Dispose( );

				dockmanager_AlternatesTab.Visible = false;
				dockmanager_AlternatesTab.EpiTabbingEnabled = false;
//dockmanager_AlternatesTab.Dispose( );

				dockmanager_UOMsTab.Visible = false;
				dockmanager_UOMsTab.EpiTabbingEnabled = false;
//dockmanager_UOMsTab.Dispose( );

				dockmanager_LotsTab.Visible = false;
				dockmanager_LotsTab.EpiTabbingEnabled = false;
//dockmanager_LotsTab.Dispose( );

				dockmanager_PlantsTab.Visible = false;
				dockmanager_PlantsTab.EpiTabbingEnabled = false;
//dockmanager_PlantsTab.Dispose( );

				LCM.Visible = false;
				LCM.EpiTabbingEnabled = false;
//LCM.Dispose( );

				PartClassDetails.Visible = true;

				PartDisposition.Visible = true;
				PartDisposition.EpiTabbingEnabled = true;

#endregion Upper tabs

#region Detail tab

				groupbox_Weight.Visible = false;
				groupbox_Lock.Visible = false;
				groupbox_Hold.Visible = false;
				groupbox_Tracking.Visible = false;
				groupbox_DefaultParam.Visible = false;

				lblInspectionClass.Visible = true;  //Inspection Class
				epiUltraComboC3.Visible = true; //Inspection Class

				lbl_Type.Visible = false;    //Type
				combo_Type.Visible = false;  //Type

				lbl_UOMClass.Visible = false;    //UOM Class
				uomclasscombo_UOMClass.Visible = false;  //UOM Class

				lbl_Inventory.Visible = false;   //Inventory
				uomcombo_Inventory.Visible = false;  //Inventory

				lbl_Sales.Visible = false;   //Sales
				uomcombo_Sales.Visible = false;  //Sales

				lbl_Purchasing.Visible = false;  //Purchasing
				uomcombo_Purchasing.Visible = false; //Purchasing

				lbl_PrimaryUOMs.Visible = false; //Primary UOMs

				lbl_SalesUnitPrice.Visible = false;  //Sales Unit Price
				numeric_SalesUnitPrice.Visible = false;  //Sales Unit Price
				combo_PricePerCode.Visible = false;
				txt_SalesPriceUM.Visible = false;

				lbl_Group.Visible = false;   //Group
				prodgrupcombo_ProductGroup.Visible = false;  //Group

				lbl_Class.Visible = false;   //Class
				partclasscombo_Class.Visible = false;    //Class

				epiLabelC23.Visible = false; //Customer Warranty
				epiUltraComboC2.Visible = false; //Customer Warranty

				lblCustomer.Visible = false; //Customer
				combo_Customers.Visible = false; //Customers

				lbl_TaxCategory.Visible = false;
				taxcatcombo_TaxCategory.Visible = false;

				button_CommodityCode.Visible = false;

				txt_CommodityCode.Visible = false;   //Commodity Code
				txt_CommodityCodeDesc.Visible = false;   //Commodity Code Description

				lbl_PrimaryCountry.Visible = false;  //Primary Country
				countrycombo_CountryOfOrigin.Visible = false;    //Primary Country

				epiLabelC25.Visible = false; //Customer Lead Time
				epiNumericEditorC2.Visible = false;  //Customer Lead Time

#endregion Detail tab

#region Revisions tab

				epiLabelC27.Visible = true; //Build Instruction Revision
				epiTextBoxC32.Visible = true;   //Build Instruction Revision

				lblFirmPackRev.Visible = true;  //Firmware Package Revision
				txtFirmPackRef.Visible = true;  //Firmware Package Revision

			//	'epiLabelC26.Visible = true; //Use Method for Forecasting
			//	'epiCheckBoxC7.Visible = true;   //Use Method for Forecasting

				lblFinTestRev.Visible = true;   //Final Test Revision
				txtFinTestRev.Visible = true;   //Final Test Revision

				lbl_Concurrency.Visible = true; //Concurrency
				combo_Concurrency.Visible = true;   //Concurrency

				lblImageID.Visible = true;  //Image ID
				txtImageID.Visible = true;  //Image ID

				lblRevStatus.Visible = false;    //Rev Status
				cboRevStatus.Visible = false;    //Rev Status

				lbl_Deviations.Visible = true;  //Deviation( s )
				txt_Deviations.Visible = true;  //Deviation( s )

#endregion Revisions tab

#region Disposition tab

				lbl_PreviousDisposition.Visible = false;
				lbl_PreviousDispositionDate.Visible = false;
				lbl_PreviousAction.Visible = false;
				lbl_DispositionNotes.Visible = false;
				lbl_CurrentDisposition.Visible = false;
				lbl_CurrentDispositionDate.Visible = false;
				lbl_CurrentAction.Visible = false;

				txt_PreviousDisposition.Visible = false;
				txt_PreviousAction.Visible = false;
				txt_DispositionNotes.Visible = false;
				txt_CurrentDisposition.Visible = false;
				txt_CurrentAction.Visible = false;

				datetime_PreviousDispositionDate.Visible = false;
				datetime_CurrentDispositionDate.Visible = false;

#endregion Disposition tab

			} //   end else if ( process == "SEMN1010" )
		} //   end SetControlProperties( ) try
		catch ( Exception ex ) { MessageBox.Show( "Exception thrown by SetControlProperties : " + ex.Message ); }
	} //   end SetControlProperties( )

You’ve got the proverbial problem of “put it all in one customization that handles every variation”, vs “individual customizations”.

I would say that it depends on how much of the code is common to each variant. If there’s a lot of functionality that is identical in each variation, then you’d have to maintain multiple copies of that identical functionality.

Agree. I thought there was a way to control data control access by group? Haven’t done that before, maybe it is the same amount of pain to support.

You can control field access by permission why not that? Instead of customization

Is that on the form? Or somewhere else?

In the Field Security module

1 Like

And field security would span all forms, (including uBAQs, I believe)

Use process Security to limit BO methods like: Posting, new Part in part master, etc…

2 Likes

@josecgomez - Does field security give options for hidden/masked as well as being R/O or R/W?

You cna do Read Only, Read Write and Hide.

1 Like

Leave them alone and train folks not to touch them. Using Epicor at 2 large publicly traded multi-billion dollar companies which are under the microscope of auditors always, never seemed to be a problem. SOX (Sarbanes).

Part Mtc not everyone should even be there. Engineers yes, everyone else - prob not. Customer Maintenance is another story that one is actually truly shared, that’s where field security can come in.

4 Likes

Only string variables can be masked unless something has changed in 10.2.600-700.