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);
}
标签:业务层,事务控制
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#函数式编程中的惰性求值详解
2022-01-27 03:07:29
![](https://img.aspxhome.com/file/2023/8/102198_0s.png)
解析C#彩色图像灰度化算法的实现代码详解
2022-01-26 07:34:55
Springboot整合Freemarker的实现详细过程
2023-01-23 22:09:57
![](https://img.aspxhome.com/file/2023/4/84164_0s.jpg)
java中String.intern()方法功能介绍
2023-11-25 23:49:21
SpringBoot核心@SpringBootApplication使用介绍
2023-11-25 08:33:59
![](https://img.aspxhome.com/file/2023/2/59202_0s.png)
C#利用原图和水印图的重叠简单实现水印的方法
2023-04-21 01:41:24
java读写二进制文件的解决方法
2022-08-03 14:45:55
c# 快速排序算法
2021-10-18 07:33:20
![](https://img.aspxhome.com/file/2023/6/84476_0s.png)
20个非常实用的Java程序代码片段
2022-02-08 10:35:44
聊一聊jdk1.8中的ArrayList 底层数组是如何扩容的
2023-11-16 08:55:50
C# WinForm创建Excel文件的实例
2023-08-06 19:47:06
java修改JFrame默认字体方式
2022-11-16 14:02:50
深入探究Java线程的创建与构造方法
2023-05-29 22:02:45
![](https://img.aspxhome.com/file/2023/5/72315_0s.png)
list集合去除重复对象的实现
2022-10-16 23:02:42
Android 二维码 生成和识别二维码 附源码下载
2023-05-01 12:45:01
![](https://img.aspxhome.com/file/2023/8/87298_0s.jpg)
解析C#中@符号的几种使用方法详解
2022-11-09 03:26:03
android开发之为activity增加左右手势识别示例
2021-09-30 12:41:50
Java入门绊脚石之Override和Overload的区别详解
2022-05-04 15:24:51
![](https://img.aspxhome.com/file/2023/5/63445_0s.png)
Spring中IOC和AOP的深入讲解
2023-11-19 10:20:59
![](https://img.aspxhome.com/file/2023/9/59529_0s.jpg)
使用AOP的@Around后无返回值的解决
2023-11-24 13:04:09