源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2022-05-22 04:29 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:winfrom 在业务层实现事务控制的小例子
[u]复制代码[/u] 代码如下:
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)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部