If
you got a request to assign the same security groups of user A to user B, you
will check the security groups for user A and then add them one by one to the
user B and this will consume your time and the human error happens especially
if you have a big list of groups .
- Add EpiUltraCombo in group tab.
- Use sample search to fill this drop down list.
- Use custom dialog serach to get the groups list of the selected user.
- Using the save tool in the toolbar to assign the group list to the current user.
- Clear the text of the EpiUltraCombo when a user clicks on clear tool.
Here
it’s the code:
The code has been tested in Epicor 9.05.604 version.
using
System;
using
System.Data;
using
System.Diagnostics;
using
System.Windows.Forms;
using
System.ComponentModel;
using
Epicor.Mfg.UI;
using
Epicor.Mfg.UI.FrameWork;
using
Epicor.Mfg.UI.ExtendedProps;
using
Epicor.Mfg.UI.FormFunctions;
using
Epicor.Mfg.UI.Customization;
using
Epicor.Mfg.UI.Adapters;
using
Epicor.Mfg.UI.Searches;
using
Epicor.Mfg.BO;
public static class
Script
{
public
static void
InitializeCustomCode()
{
baseToolbarsManager.ToolClick += new
Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(baseToolbarsManager_ToolClick);
}
public
static void
DestroyCustomCode()
{
baseToolbarsManager.ToolClick -= new
Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(baseToolbarsManager_ToolClick);
}
private
static void
SearchOnUserFileAdapterFillDropDown()
{
bool recSelected;
string whereClause = String.Empty;
System.Data.DataSet dsUserFileAdapter =
Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "UserFileAdapter", out recSelected, false,
whereClause);
if (recSelected)
{
// Set EpiUltraCombo Properties
UCUser.ValueMember
= "DcdUserID";
UCUser.DataSource =
dsUserFileAdapter;
UCUser.DisplayMember = "Name";
string[] fields = new
string[] {
"Name"};
UCUser.SetColumnFilter(fields);
}
}
private
static void
UserAccountForm_Load(object sender, EventArgs args)
{
// Add Event Handler Code
SearchOnUserFileAdapterFillDropDown();
UCUser.DropDownStyle =
Infragistics.Win.UltraWinGrid.UltraComboStyle.DropDownList;
}
private
static string
SearchOnUserFileAdapterShowDialog(string
sameAsUser)
{
// Wizard Generated Search Method
// You will need to call this method from another method in custom code
// For example, [Form]_Load or [Button]_Click
string
grpList = string.Empty;
bool recSelected;
string whereClause = " DcdUserID
= '" + sameAsUser + "'";
System.Data.DataSet dsUserFileAdapter =
Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans, "UserFileAdapter", out recSelected, false,
whereClause);
if (recSelected)
{
// Map Search Fields to Application Fields
grpList = (string)dsUserFileAdapter.Tables[0].Rows[0]["GroupList"];
}
return grpList;
}
private
static void
baseToolbarsManager_ToolClick(object sender,
Infragistics.Win.UltraWinToolbars.ToolClickEventArgs
args)
{
if ((UCUser.Value != null)
&& (UCUser.Value.ToString() != ""))
{
EpiDataView userDV
= (EpiDataView)oTrans.EpiDataViews["User"];
DataRow currRow = userDV.CurrentDataRow;
if (currRow != null)
{
if (args.Tool.Key == "SaveTool")
{
currRow["GroupList"] =
SearchOnUserFileAdapterShowDialog(UCUser.Value.ToString());
}
}
if (args.Tool.Key == "ClearTool")
UCUser.Text = "";
}
}
}
Comments
Post a Comment