实现代码如下:

try
    {
 using (TransactionScope tr = new TransactionScope())
 {
     int i = this.customermanager.addCustomer(customer);
     int j = this.homestatusmanager.updateHomestatus(homestatus);
     if ((i * j) > 0)
     {
  MessageBox.Show("记录插入成功!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  Empty();
  tr.Complete();
     }
     else
     {
  MessageBox.Show("记录插入失败!联系管理员!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  Empty();
     }
     tr.Dispose();
 }

    }
    catch(Exception err)
    {
 MessageBox.Show("记录插入失败" +err.ToString(), "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }

以上就是【winfrom 在业务层实现事务控制的小例子】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论