hasokeric
3/23/2015 - 6:57 PM

Epicor KeyField Tab or Enter Action

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();
           }
	     }
	  }
	}