当前位置: 编程技术>.net/c#/asp.net
c# 应用事务的简单实例
来源: 互联网 发布时间:2014-10-23
本文导语: 代码如下:using (TransactionScope tr = new TransactionScope()) { int i = this.deskmanager.addOpenDesk(account_c); int j = this.deskmanager.updateDeskStatus(account_c.AccountC_desk, "有客"); if (i > 0 && j > 0) { tr.Complete(); ...
代码如下:
using (TransactionScope tr = new TransactionScope())
{
int i = this.deskmanager.addOpenDesk(account_c);
int j = this.deskmanager.updateDeskStatus(account_c.AccountC_desk, "有客");
if (i > 0 && j > 0)
{
tr.Complete();
}
else
{
MessageBox.Show("开桌未成功,与管理员联系!");
this.btnkz.Enabled = false;
this.btndc.Enabled = false;
this.btnchange.Enabled = false;
this.button3.Enabled = false;
}
tr.Dispose();
}