手机
当前位置:查字典教程网 >编程开发 >C#教程 >winfrom 在业务层实现事务控制的小例子
winfrom 在业务层实现事务控制的小例子
摘要:复制代码代码如下:try{using(TransactionScopetr=newTransactionScope()){inti=this...

复制代码 代码如下:

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 在业务层实现事务控制的小例子】相关文章:

winform中写app.config文件时调试情况下没有改变的原因

C#定位txt指定行的方法小例子

服务器端C#实现的CSS解析器

计算字符串和文件MD5值的小例子

C#实现的几种委托方式介绍

C#实现类似qq的屏幕截图程序

C# 合并GriewView相同列的小例子

C#之IP地址和整数互转的小例子

C#操作txt文件,进行清空添加操作的小例子

C#实现协同过滤算法的实例代码

精品推荐
分类导航