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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-18 我要评论
想了解winfrom 在业务层实现事务控制的小例子的相关内容吗,在本文为您仔细讲解winfrom 在业务层实现事务控制的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:业务层,事务控制,下面大家一起来学习吧。

复制代码 代码如下:

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们