手机
当前位置:查字典教程网 >编程开发 >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中的登录实现

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

winform调用javascript的小例子

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

c# winform多线程的小例子

winform树形菜单无限级分类实例

c#进度条 progressBar 使用方法的小例子

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

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

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

精品推荐
分类导航