MES Button Customization

Hello all.

I have added a customized button to my MES screen to call a Dashboard. That part works well.

Right now I can either make the button inactive all the time or active all the time. What I’d like to do is have the button inactive when MES starts (just like all the other MES buttons) and then become active once someone logs in. Anyone know how to do this?

Charlie Payne
Hendrick Screen Company
Owensboro, KY

use the wizard to create an event on EpiViewNotification.

enter the code below… change to your button name

private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			EnableDisableCustomControls(true);
		}
        else
        {
			EnableDisableCustomControls(false);                             
        }
	}
}

private void EnableDisableCustomControls(bool iFlag)
{
	<yourcontrol>.Enabled = iFlag;
}

hth…

The way I did it was to use the state of another button that
activated/deactivated with the same desired permissions.

//First I got a ref to the button I want to mimic, and set an event on property change (in InitializeCustomCode)
Mtlbtn = (EpiButton)csm.GetNativeControlReference("c06b3700-995a-4f9b-b975-68af8d2acd6d");
Mtlbtn.PropertyChanged += new Infragistics.Win.PropertyChangedEventHandler(PropChange);

private void PropChange(object sender ,Infragistics.Win.PropertyChangedEventArgs args)
{
//Here on prop change, I stole it's style and applied it to my button (TestBtn)
TestBtn.StyleSetName = ((EpiButton)sender).StyleSetName;
TestBtn.BringToFront(); //Did this because my button sits on top of old existing button
}



//Don't Forget to add:
using Infragistics.Win;  //at top
Mtlbtn.PropertyChanged -= new Infragistics.Win.PropertyChangedEventHandler(PropChange);  //OnDestroyCustom code
2 Likes

@Chris_Conn

That was a hell of a workaround!

3 Likes

Well, it works. lol

2 Likes

I am just teasing you :slight_smile:

2 Likes

I getting emotionally scarred in the Epicor environment. -1 beer from the truck load I owe you.

1 Like

1 Like

:smile:

2 Likes

4 Likes
// This is the way MES does it - use this snippet to determine your flag
public bool isLogged
{
    get
    {
        if (this.oTrans.LaborHedView.HasRow && this.oTrans.EmpBasicView.dataView.Count > 0)
            return true;
        else
            return false;
    }
}

Also if you want to create the Button the same way MES does - throw something like this, but refactored inside your InitializeCustomCode()

this.oTrans.MESControlView.dataView.Table.Columns.Add("UD_MassIssue", typeof(bool));
this.oTrans.MESControlView.dataView.Table.Columns["UD_MassIssue"].ExtendedProperties.Add("MenuID", "XISSUTST");
this.oTrans.MESControlView.dataView.Table.Columns["UD_MassIssue"].ExtendedProperties.Add("MESTab", "XISSUTST");
this.oTrans.MESControlView.dataView[0]["UD_MassIssue"] = false;

RowRule UD_MassIssue = new RowRule("UD_MassIssue", RuleCondition.Equals, false);
UD_MassIssue.AddAction(RuleAction.AddControlSettings(this.oTrans, "MESControl.UD_MassIssue", SettingStyle.ReadOnly));
this.oTrans.MESControlView.AddRowRule(UD_MassIssue);

The button will automatically then fire up the specified MenuID - MES will handle it behind the scenes. You will also be able to EpiBind your Button to example UD_MassIssue - and let the EpiBinding drive the state by managing true/false.

6 Likes

Can you provide any additional help on this? I have gotten everything to work except that it won’t enable the button no matter if I log into MES or not. I used the section for this.oTrans.MESControlView.