So I figured out how to turn off custom buttons until someone clocks into MES, (an after adapter method of empAdapter for GetRows)
However, I can’t figure out how to gray them back out when someone logs out. (not closing out of the MES window, just logging out so the next person can use it).
I tried running a trace on log out and it just comes up blank. Does anyone know what event to tie in to to set the read only property back to true?
Do I need to tie it into the button click on log out? I’m not sure how I would do that…
Never done it, but I would imagine just attaching to the click even of the log out button would suffice.
Open the main form ustomization
Get the button GUID
EpiButton logOutBtn = (EpiButton)csm.GetNativeControlReference(“the guid here”) //this will be a global
In init or form load:
logOutBtn.Click += (o,e) =>
{
//do stuff
};
As long as you don’t need specific security functionality to be different by user, I generally just see if there is an employee record and then set the controls’ enabled property.
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))
{
EnableCustomControls(true);
}
else
{
EnableCustomControls(false);
}
}
}
private void EnableCustomControls(bool Flag_bol)
{
// Set the Enabled property of each custom button
ShiftStartActivity_btn.Enabled = Flag_bol;
}
So I added the code in. However, it won’t seem to fire. What else to I need to do besides copy the code into the customization? It compiles fine, but nothing happens on login/logout.
Edit: just an FYI, it gave me an error saying that .Enabled was obsolete and to use ReadOnly. So I switch those (the the corresponding true/false values). But I don’t think that would have any affect on whether it works or not.
You can go through the FormEvent wizard to add the statements into the Initialize and Destroy sections
This is in the Initialize:
this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews[“EmpBasic”]));
this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
That made more sense. I went through the wizard to add the code. I didn’t see the event type “EpiViewNotification” before. Thanks for the tip on that! All I had to do then was change:
EpiTransaction.NotifyType.AddRow to EpiTransaction.NotifyType.Initialize
Then I added my read only statements and it works great now.
I’m not sure what you mean by this. You use the wizard to make an event for DataViewNotification. Then you add in the code in the block that is readied for you. What is it you are having problems with?