代碼如下:
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);
}