此查询查找库存可用性,标签打印输出如下所示..
{
string selection_price = DdPetPist.SelectedValue;
string selection_stock = DdPetPist.SelectedValue;
string petPrice = string.Empty;
string available = string.Empty;
{
MySqlCommand cd_price = new MySqlCommand(String.Format("SELECT Price FROM Animals WHERE Specie ='{1}' and Country ='{0}'", ddlcountry.SelectedItem.ToString().Trim(), selection_price), cs);
MySqlCommand cd_available = new MySqlCommand(String.Format("SELECT Stock FROM Animals WHERE Specie ='{1}' and Country ='{0}'", ddlcountry.SelectedItem.ToString().Trim(), selection_stock), cs);
cs.Open();
petPrice = Convert.ToString(cd_price.ExecuteScalar());
available = Convert.ToString(cd_available.ExecuteScalar());
cs.Close();
}
PetPrice.Text = String.Format("Minimum Donation For A {0} Is £{1}.", selection_price, petPrice);
Availble.Text = String.Format("{0}'s Avalible {1} In Your Country.", selection_stock, available);
}
如果stock
,如何弹出消息框= 到 0 吗?
更新
好的,我会解释一下我想要做什么
我有一个UPDATE
每次单击按钮时,查询都会将股票减 1。查询如下:
var myquery = string.Format("UPDATE Animals SET Stock = Stock - 1 WHERE Specie ='{1}'
and Country ='{0}' and Stock >0", ddlcountry.SelectedItem.ToString().Trim(),
selection_price);
现在我想要的是如果 stock
= = 0 会弹出一条消息或警报,提示所选产品缺货。
最佳答案
if(available == 0)
{
Messagebox.show("stock is equal to zero");
}
不确定这是否能回答您的问题
关于c# - 如果查询 = 到 0,则显示消息框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20229782/