winfrom 在业务层实现事务控制的小例子
更新时间:2013年03月30日 13:41:19 作者:
winfrom 在业务层实现事务控制的小例子,需要的朋友可以参考一下
复制代码 代码如下:
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);
}
相关文章
c#入门之枚举和结构体使用详解(控制台接收字符串以相反的方向输出)
这篇文章主要介绍了c#入门之枚举和结构体使用详解,最后提供了编写控制台应用程序接收字符串并做相应处理的小示例,需要的朋友可以参考下2014-04-04


最新评论