当前位置: 移动技术网 > IT编程>开发语言>c# > winfrom 在业务层实现事务控制的小例子

winfrom 在业务层实现事务控制的小例子

2019年07月18日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:try    { using (transactionscope tr = new transactionsco

复制代码 代码如下:

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);
    }

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网