软件编程
位置:首页>> 软件编程>> C#编程>> winfrom 在业务层实现事务控制的小例子

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

  发布时间:2021-11-16 14:19:50 

标签:业务层,事务控制


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


0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com