手机
当前位置:查字典教程网 >编程开发 >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 在业务层实现事务控制的小例子】相关文章:

c# 应用事务的简单实例

c# 开机启动项的小例子

c# winform取消右上角关闭按钮的实现方法

C# WinForm中Panel实现用鼠标操作滚动条的实例方法

C# Bitmap 复制的小例子

c# winform多线程的小例子

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

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

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

C# 实现简单打印的实例代码

精品推荐
分类导航