csharp Epicor UD Entry KeyField

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp Epicor UD Entry KeyField相关的知识,希望对你有一定的参考价值。

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


}

以上是关于csharp Epicor UD Entry KeyField的主要内容,如果未能解决你的问题,请参考以下文章

csharp Epicor 10.1 - 获得价值或0

csharp 的Epicor-WCF-j.cs

csharp 创建Epicor BO Instace WCF

csharp Epicor 10.1从代码调用BAQ

csharp Epicor:从午夜到实际时间转换秒数

csharp Epicor - 在订单输入中检查零件详细信息