Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Created March 23, 2015 18:57
Show Gist options
  • Save hasokeric/8354599db30eb84e0631 to your computer and use it in GitHub Desktop.
Save hasokeric/8354599db30eb84e0631 to your computer and use it in GitHub Desktop.
Epicor KeyField Tab or Enter Action
/**
* Add Support for the KeyField to trigger something
* when the keyboard is triggered. (Does not come out of the box)
*
* @type Custom Function
* @return void
*/
private void txtKeyField_KeyDown(object sender, System.Windows.Forms.KeyEventArgs args)
{
if (args.KeyCode == Keys.Tab | args.KeyCode == Keys.Enter)
{
string key1 = String.Empty;
string key2 = String.Empty;
string key3 = String.Empty;
string key4 = String.Empty;
string key5 = String.Empty;
key1 = this.txtKeyField.Text;
// Call Adapter method
bool result = this.oTrans.GetByID(key1, key2, key3, key4, key5);
// Check if the User already has clicked the New Button
// if he did then we dont want to do another GetNew()
EpiDataView edvLBL = GetDataView("UD08");
if (edvLBL.Row != -1) {
return;
}
if (!result)
{
if (this.oTrans.GetNew())
{
//this.txtKeyField.Text = key1;
edvLBL.dataView[edvLBL.Row].BeginEdit();
edvLBL.dataView[edvLBL.Row]["Key1"] = key1;
edvLBL.dataView[edvLBL.Row].EndEdit();
bool success = this.oTrans.Update();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment