日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Epicor客制化 - 在VS中进行开发

發布時間:2023/12/16 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Epicor客制化 - 在VS中进行开发 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

  • 1.搭建Visual Studio二次開發Epicor10的環境
  • 2.在Epicor中設計好UI界面
  • 3.在Visual Studio中進行代碼編寫
  • 4.在Epicor調用寫好的類庫
  • 5.在Visual Studio中調試Epicor客制
  • 6.后記(將代碼全部整合到Epicor客制中)

1.搭建Visual Studio二次開發Epicor10的環境

首先需要新建一個類庫項目,并引用開發所需要的DLL文件,
我這里使用UD01Form來二次開發,所以添加了UD01Form的窗體dll文件Ice.UI.UD01Entry,
如下圖所示,是當前Demo中二次開發需要的DLL文件.

2.在Epicor中設計好UI界面

在這個Demo中,我在UD01原界面中添加了一個New按鈕,
功能是新增一行數據,并自動生成Key1的值,
另外還需要實現隱藏左邊的Panel的功能.

3.在Visual Studio中進行代碼編寫

在項目中新建一個類文件,
類中為New按鈕添加了事件,并且隱藏了左邊的Panel,
其中Initialize,Destroy,FormLoad三個方法將會在Epicor客制中調用,代碼如下:

using Ice.Lib.Framework; using Infragistics.Win.UltraWinToolbars; using System; using System.Windows.Forms;namespace Epicor.Demo {public class UD01Entry{Ice.Lib.Customization.CustomScriptManager csm;UltraToolbarsManager baseToolbarsManager;Ice.UI.App.UD01Entry.Transaction oTrans;Ice.Core.Session session;EpiDataView edvUD01;Ice.UI.App.UD01Entry.UD01Form TForm;UltraToolbar standardTools;EpiButton epiBtNew;/// <summary>初始化數據(InitializeCustomCode中調用該方法)</summary>/// <param name="csm1">接受從Epicor中傳過來的CustomScriptManager對象</param>public void Initialize(Ice.Lib.Customization.CustomScriptManager csm1){csm = csm1;oTrans = ((Ice.UI.App.UD01Entry.Transaction)(csm.GetGlobalInstance("oTrans")));session = (Ice.Core.Session)(oTrans.Session);edvUD01= ((EpiDataView)(oTrans.EpiDataViews["UD01"]));baseToolbarsManager = ((UltraToolbarsManager)(csm.GetGlobalInstance("baseToolbarsManager")));standardTools = baseToolbarsManager.Toolbars["Standard Tools"];TForm = ((Ice.UI.App.UD01Entry.UD01Form)(this.csm.GetGlobalInstance("UD01Form")));epiBtNew = GetControlByName<EpiButton>(TForm, "epiBtNew");//獲取UI界面的控件epiBtNew.Click += EpiBtNew_Click;}/// <summary>釋放數據(DestroyCustomCode中調用該方法)</summary>public void Destroy(){epiBtNew.Click -= EpiBtNew_Click;}/// <summary>窗體加載(UD01Form_Load中調用該方法)</summary>public void FormLoad(){HiddenLeftTree();}/// <summary>New按鈕事件</summary>private void EpiBtNew_Click(object sender, EventArgs e){oTrans.GetNew();edvUD01.CurrentDataRow.BeginEdit();edvUD01.CurrentDataRow["Key1"] = "K" + System.DateTime.Now.ToString("yyyyMMddHHmmssfff");edvUD01.CurrentDataRow.EndEdit();}/// <summary>隱藏左邊面板</summary>public void HiddenLeftTree(){Infragistics.Win.UltraWinDock.WindowDockingArea windowDockingArea1 = (Infragistics.Win.UltraWinDock.WindowDockingArea)(TForm.Controls["windowDockingArea1"]);windowDockingArea1.Visible = false;}/// <summary>按Name獲取Epicor控件</summary>public static T GetControlByName<T>(Control control, string name){Control[] controls = control.Controls.Find(name, true);if (controls.Length > 0) return (T)((Object)(controls[0]));return default(T);}} }

4.在Epicor調用寫好的類庫

首先要將前面寫的代碼,編譯成DLL文件,并將文件復制到Epicor客戶端Client目錄下.
然后在客制中引用DLL文件(注意選擇DLL文件時,右下角選擇"All files")



在Epicor中添加代碼調用類庫

// ************************************************** // Custom code for UD01Form // Created: 2019/1/28 15:10:36 // ************************************************** using System; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Windows.Forms; using Ice.BO; using Ice.UI; using Ice.Lib; using Ice.Adapters; using Ice.Lib.Customization; using Ice.Lib.ExtendedProps; using Ice.Lib.Framework; using Ice.Lib.Searches; using Ice.UI.FormFunctions; using Epicor.Demo;//引用類庫命名空間 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 **UD01Entry obj=new UD01Entry();//實例化類public void InitializeCustomCode(){// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **// Begin Wizard Added Variable Initializationobj.Initialize(csm);//調用Initialize方法,傳入csm對象// End Wizard Added Variable Initialization// Begin Wizard Added Custom Method Calls// 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 Disposalobj.Destroy();// End Wizard Added Object Disposal// Begin Custom Code Disposal// End Custom Code Disposal}private void UD01Form_Load(object sender, EventArgs args){obj.FormLoad();} }

5.在Visual Studio中調試Epicor客制

運行Epicor程序之后,在VS中選擇"調試->附加到進程",找到Epicor的進程,點"附加"按鈕,
附加之后,我們就可以自由調試VS中的代碼了.



當點擊"New"按鈕時,進入到之前設置好的調試斷點處.

代碼運行成功,左邊的Panel隱藏了,點擊"New"按鈕新增了一行數據,并生成了Key1的值.

6.后記(將代碼全部整合到Epicor客制中)

如果公司正式環境中不方便使用自己開發的類庫,可以直接復制VS中的代碼到Epicor客制中,
然后添加對應的DLL文件和命名空間,即可運行.
Epicor客制中代碼如下:

// ************************************************** // Custom code for UD01Form // Created: 2019/1/28 15:10:36 // ************************************************** using System; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Windows.Forms; using Ice.BO; using Ice.UI; using Ice.Lib; using Ice.Adapters; using Ice.Lib.Customization; using Ice.Lib.ExtendedProps; using Ice.Lib.Framework; using Ice.Lib.Searches; using Ice.UI.FormFunctions; using Ice.Lib.Framework; using Infragistics.Win.UltraWinToolbars; using System; using System.Windows.Forms;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 **UD01Entry obj=new UD01Entry();public void InitializeCustomCode(){// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **// Begin Wizard Added Variable Initializationobj.Initialize(csm);// End Wizard Added Variable Initialization// Begin Wizard Added Custom Method Calls// 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 Disposalobj.Destroy();// End Wizard Added Object Disposal// Begin Custom Code Disposal// End Custom Code Disposal}private void UD01Form_Load(object sender, EventArgs args){obj.FormLoad();}public class UD01Entry{Ice.Lib.Customization.CustomScriptManager csm;UltraToolbarsManager baseToolbarsManager;Ice.UI.App.UD01Entry.Transaction oTrans;Ice.Core.Session session;EpiDataView edvUD01;Ice.UI.App.UD01Entry.UD01Form TForm;UltraToolbar standardTools;EpiButton epiBtNew;/// <summary>初始化數據(InitializeCustomCode中調用該方法)</summary>/// <param name="csm1">接受從Epicor中傳過來的CustomScriptManager對象</param>public void Initialize(Ice.Lib.Customization.CustomScriptManager csm1){csm = csm1;oTrans = ((Ice.UI.App.UD01Entry.Transaction)(csm.GetGlobalInstance("oTrans")));session = (Ice.Core.Session)(oTrans.Session);edvUD01= ((EpiDataView)(oTrans.EpiDataViews["UD01"]));baseToolbarsManager = ((UltraToolbarsManager)(csm.GetGlobalInstance("baseToolbarsManager")));standardTools = baseToolbarsManager.Toolbars["Standard Tools"];TForm = ((Ice.UI.App.UD01Entry.UD01Form)(this.csm.GetGlobalInstance("UD01Form")));epiBtNew = GetControlByName<EpiButton>(TForm, "epiBtNew");//獲取UI界面的控件epiBtNew.Click += EpiBtNew_Click;}/// <summary>釋放數據(DestroyCustomCode中調用該方法)</summary>public void Destroy(){epiBtNew.Click -= EpiBtNew_Click;}/// <summary>窗體加載(UD01Form_Load中調用該方法)</summary>public void FormLoad(){HiddenLeftTree();}/// <summary>New按鈕事件</summary>private void EpiBtNew_Click(object sender, EventArgs e){oTrans.GetNew();edvUD01.CurrentDataRow.BeginEdit();edvUD01.CurrentDataRow["Key1"] = "K" + System.DateTime.Now.ToString("yyyyMMddHHmmssfff");edvUD01.CurrentDataRow.EndEdit();}/// <summary>隱藏左邊面板</summary>public void HiddenLeftTree(){Infragistics.Win.UltraWinDock.WindowDockingArea windowDockingArea1 = (Infragistics.Win.UltraWinDock.WindowDockingArea)(TForm.Controls["windowDockingArea1"]);windowDockingArea1.Visible = false;}/// <summary>按Name獲取Epicor控件</summary>public static T GetControlByName<T>(Control control, string name){Control[] controls = control.Controls.Find(name, true);if (controls.Length > 0) return (T)((Object)(controls[0]));return default(T);}} }

總結

以上是生活随笔為你收集整理的Epicor客制化 - 在VS中进行开发的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。