一、显示界面Form1.cs
1.定义一个button,一个progressbar
private void button_Click(object sender, System.EventArgs e)
{
LawSystem lawSystem = new LawSystem();
lawSystem.onSendMsg += new LawSystem.MyEventHandler(this.OnSendMsg);
bool flag = lawSystem.ImpLawType(alLawTypeID,fileName);
}

//处理 onSendMsg 事件代码
protected void OnSendMsg(int lawTypeNum, int itemCount, int itemNum)
{
this.progressBar1.Value = lawTypeNum;
}

二、界面封装类BusinessFacade.LawSystem.cs
//定义事件
public delegate void MyEventHandler(int libNum, int itemCount, int itemNum);
public event MyEventHandler onSendMsg;

//导入
public bool ImpLawType(IList alLawTypeID,string fileName)
{
LawType lawType = new LawType();
lawType.onSendMsg += new LawType.MyEventHandler(this.OnSendMsg);
return lawType.ImpLawType(alLawTypeID,fileName);
}
//处理 onSendMsg 事件代码
protected void OnSendMsg(int lawTypeNum, int itemCount, int itemNum)
{
//输出调试信息
onSendMsg(lawTypeNum, itemCount, itemNum);
}

三、业务逻辑类BusinessRules.LawType.cs
//定义事件
public delegate void MyEventHandler(int libNum, int itemCount, int itemNum);
public event MyEventHandler onSendMsg;
执行并赋值
onSendMsg(++lawTypeNum,0,0);

相关文章:

  • 2021-11-22
  • 2021-06-30
  • 2022-01-21
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2021-11-27
  • 2022-01-14
  • 2022-12-23
  • 2021-12-23
  • 2019-10-01
  • 2021-07-26
相关资源
相似解决方案