我有一个ASP.NET结帐页面,它调用Page_Load方法中的方法
private static void DecreaseStockCount(int itemID, int stockToBePurchased)
{
//get current stock count
int stock = 0;
using (OleDbConnection conn = new OleDbConnection(@"Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=xe)));
User Id=sys1;Password=admin;"))
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = conn;
cmd.CommandText = string.Format("select stockcount from item_stock_mstr where itemid = '{0}'", itemID);
conn.Open();
using (OleDbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
stock = Convert.ToInt32(reader.GetValue(0).ToString());
}
}
//if stockCount !=0, perform update to decrease stock count
if ((stock != 0) && (stock > stockToBePurchased))
{
stock = stock - stockToBePurchased;
cmd.CommandText = string.Format("update item_stock_mstr set stockcount = {0} where itemid = '{1}'", stock, itemID);
cmd.ExecuteNonQuery();
}
conn.Close();
}
}
该方法的作用是在结束结账前减少我的物品的库存数量。
我的问题是,当用户退出结帐页面而未完成结帐时,我无法将其回滚到上一个号码/重新更新。
我被困住了,请帮帮忙。