Created
September 29, 2015 18:04
-
-
Save hasokeric/86ba68a25ac71a38b4d3 to your computer and use it in GitHub Desktop.
Epicor UD Entry KeyField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ************************************************** | |
| // Custom code for UD100Form | |
| // Created: 2/11/2014 10:24:37 AM | |
| // ************************************************** | |
| using System; | |
| using System.Drawing; | |
| using System.ComponentModel; | |
| using System.Data; | |
| using System.Diagnostics; | |
| using System.Windows.Forms; | |
| using Epicor.Mfg.BO; | |
| using Epicor.Mfg.UI; | |
| using Epicor.Mfg.UI.Adapters; | |
| using Epicor.Mfg.UI.Customization; | |
| using Epicor.Mfg.UI.ExtendedProps; | |
| using Epicor.Mfg.UI.FormFunctions; | |
| using Epicor.Mfg.UI.FrameWork; | |
| using Epicor.Mfg.UI.Searches; | |
| public class Script | |
| { | |
| // ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! ** | |
| // Begin Wizard Added Module Level Variables ** | |
| // End Wizard Added Module Level Variables ** | |
| // Add Custom Module Level Variables Here ** | |
| EpiTextBox txtKeyField; | |
| public void InitializeCustomCode() | |
| { | |
| // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines ** | |
| // Begin Wizard Added Variable Initialization | |
| // End Wizard Added Variable Initialization | |
| // Begin Wizard Added Custom Method Calls | |
| this.txtKeyField = ((EpiTextBox)csm.GetNativeControlReference("46567b2e-6bc0-4967-be35-a0ec6843838f")); // Get KeyField GUID | |
| this.txtKeyField.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtKeyField_KeyDown); | |
| // End Wizard Added Custom Method Calls | |
| } | |
| public void DestroyCustomCode() | |
| { | |
| // ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines ** | |
| // Begin Wizard Added Object Disposal | |
| // End Wizard Added Object Disposal | |
| // Begin Custom Code Disposal | |
| this.txtKeyField.KeyDown -= new System.Windows.Forms.KeyEventHandler(this.txtKeyField_KeyDown); | |
| // End Custom Code Disposal | |
| } | |
| /** | |
| * Get Epicor Data View Helper | |
| * | |
| * @var tableName EpiBinding Table Name | |
| * @type Custom Function | |
| * @return EpiDataView | |
| */ | |
| private EpiDataView GetDataView(string tableName) | |
| { | |
| return (EpiDataView)oTrans.EpiDataViews[ tableName ]; | |
| } | |
| 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); | |
| if (!result) | |
| { | |
| DialogResult dialogResult = EpiMessageBox.Show("Record does not exist, would you like to create a new one?", "New Record?", MessageBoxButtons.YesNo); | |
| if ((dialogResult == DialogResult.Yes)) | |
| { | |
| if (this.oTrans.GetNew()) | |
| { | |
| //this.txtKeyField.Text = key1; | |
| EpiDataView myDataView = GetDataView("UD100"); // !! MAKE SURE TO CHANGE UD100 to your UD Table Name | |
| myDataView.dataView[myDataView.Row]["Key1"] = key1; | |
| this.oTrans.Update(); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment