0
我有一个GridView
,显示我的客户试图购买的所有产品。我想用一个DELIVER ALL按钮从我的库存中扣除所有产品。什么是最好的方式来做到这一点?C# - 用一个按钮更新多个库存
gvOrderDetails(样表)
Order # || Product ID || Product Name || Quantity || DELIVER Buttons
1 || 1 || Sample Item 1 || 10 || DELIVER
1 || 2 || Sample Item 2 || 20 || DELIVER
1 || 3 || Sample Item 3 || 30 || DELIVER
下面是对GridView
void DeductFromInventory()
{
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "UPDATE Products SET Quantity = Quantity - " + gvOrderDetails.SelectedRow.Cells[3].Text + " WHERE [email protected]";
cmd.Parameters.AddWithValue("@ProductID", gvOrderDetails.SelectedRow.Cells[1].Text);
cmd.ExecuteNonQuery();
con.Close();
}
protected void gvOrderDetails_SelectedIndexChanged(object sender, EventArgs e)
{
DeductFromInventory();
}
每当用户选择不同的行时,您是从库存中扣除的? – msitt