In the Menu Maintenance Program, when we tried to setup the
security, we found that the security groups mixed with the employees list and it’s
difficult to find a group especially if the list is very big.
I have searched in the
internet to see if anyone solve this issue and I came with a solution from ittoolbox.com and it’s an easy solution as below:
Add two leading spaces to the security group descriptions as you can see in the below video.
I got an idea from my Team Lead to use a TextBox to filter the users/groups list and I customized the Menu Maintenance and added a TextBox and i wrote some code to filter the list and its working.
Here is the code:
This code tested in Epicor 9.05.702 and its working.
//
**************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;
using System.Collections.Generic;
public class
Script
{
// ** Wizard Insert Location - Do Not Remove
'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables
**
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
private List<string> list = new
List<string>();
private EpiListBox lbSource; //source list
box
private EpiListBox lbTarget; // target list box
private EpiButton btnDeselect; //deselect button
private EpiButton btnDeselectAll; //Deselect all button
private EpiButton btnSelect; //Select Button
private EpiButton btnSelectAll; //Select ALL Buton
private EpiTextBox txtSecCode; //Security Code TextBox
public void
InitializeCustomCode()
{
// ** Wizard
Insert Location - Do not delete 'Begin/End Wizard Added Variable
Initialization' lines **
// Begin
Wizard Added Variable Initialization
txtSecCode =
(EpiTextBox)csm.GetNativeControlReference("92c679dc-3e59-463c-be33-ca4b44b938b8");
txtSecCode.TextChanged += new System.EventHandler(this.txtSecCode_TextChanged);
btnDeselect =
(EpiButton)csm.GetNativeControlReference("13c171c8-460a-4ab4-80a9-eaabe7444ae5");
btnDeselect.Click += new System.EventHandler(this.btnDeselect_Click);
btnDeselectAll =
(EpiButton)csm.GetNativeControlReference("02938527-4ee7-4ffc-b13d-d37f2e798e8e");
btnDeselectAll.Click += new System.EventHandler(this.btnDeselect_Click);
btnSelect =
(EpiButton)csm.GetNativeControlReference("98da085f-432c-47b8-b3b8-c1f91f2f59c4");
btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
btnSelectAll =
(EpiButton)csm.GetNativeControlReference("cc74f05e-c188-42b7-9013-89ed294f0ee8");
btnSelectAll.Click += new System.EventHandler(this.btnSelect_Click);
this.epiTextBoxC1.TextChanged
+= new System.EventHandler(this.epiTextBoxC1_TextChanged);
// End Wizard
Added Custom Method Calls
lbSource =
(EpiListBox)csm.GetNativeControlReference("15cbb74d-7df2-49e3-9933-a474f9b2fcae");
lbTarget =
(EpiListBox)csm.GetNativeControlReference("26bd0e42-6fc2-4895-8db6-a23b709b441e");
// End Wizard
Added Variable Initialization
// Begin
Wizard Added Custom Method Calls
// End Wizard
Added Custom Method Calls
}
public void
DestroyCustomCode()
{
// ** Wizard
Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines
**
// Begin
Wizard Added Object Disposal
btnDeselect.Click -= new System.EventHandler(this.btnDeselect_Click);
btnDeselectAll.Click -= new System.EventHandler(this.btnDeselect_Click);
btnSelect.Click -= new System.EventHandler(this.btnSelect_Click);
btnSelectAll.Click -= new System.EventHandler(this.btnSelect_Click);
txtSecCode.TextChanged -= new System.EventHandler(this.txtSecCode_TextChanged);
this.epiTextBoxC1.TextChanged
-= new System.EventHandler(this.epiTextBoxC1_TextChanged);
// End Wizard
Added Object Disposal
// Begin
Custom Code Disposal
// End Custom
Code Disposal
}
private void
btnDeselect_Click(object sender, System.EventArgs args)
{
foreach
(String str in
lbSource.Items)
{
if
(!list.Contains(str))
list.Add(str);
}
epiTextBoxC1.Text = "";
}
private void
btnSelect_Click(object sender, System.EventArgs args)
{
if
(lbTarget.Items.Count > 0)
{
string
fields = "";
foreach
(String str in
lbTarget.Items)
{
fields += str + "~";
if
(list.Contains(str))
list.Remove(str);
}
fields = fields.Substring(0,
(fields.Length - 1));
EpiDataView dataView =
(EpiDataView)oTrans.EpiDataViews["Security"];
DataRow
currRow = dataView.CurrentDataRow;
if (currRow != null)
//The
column name in DB is EntryList but it doesn't work and I got the name from
trace which is "AllowAccess"
currRow["AllowAccess"] = fields;
epiTextBoxC1.Text = "";
}
}
private void
txtSecCode_TextChanged(object sender, System.EventArgs args)
{
list.Clear();
foreach
(String str in
lbSource.Items)
{
list.Add(str);
}
if (String.IsNullOrEmpty(epiTextBoxC1.Text.Trim()) == false)
epiTextBoxC1.Text = "";
}
private void
epiTextBoxC1_TextChanged(object sender, System.EventArgs args)
{
if (String.IsNullOrEmpty(epiTextBoxC1.Text.Trim()) == false)
{
lbSource.Items.Clear();
foreach
(string str in
list)
{
if
(str.ToLower().StartsWith(epiTextBoxC1.Text.ToLower().Trim()))
{
lbSource.Items.Add(str);
}
}
}
else
{
lbSource.Items.Clear();
foreach
(string str in
list)
{
lbSource.Items.Add(str);
}
}
}
}
Comments
Post a Comment