winfrom 在业务层实现事务控制的小例子
更新时间:2020年6月25日 11:42 点击:2109
复制代码 代码如下:
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);
}
相关文章
- winfrom 在业务层实现事务控制的小例子,需要的朋友可以参考一下...2020-06-25
- 这篇文章主要介绍了spring基于注解配置实现事务控制操作,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-09-07