味精盒装,无存货 [英] msg box to dipslay no stock
本文介绍了味精盒装,无存货的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用药添加表.因为其中一列在中间
形式是这样的
mid =文字框
如果我在该文本框中的中间列中未输入任何值,我必须得到一个显示无库存"的消息,请给我发送代码.我正在尝试在前端编写这样的代码
如果(textbox1.text)不在medicaladd的选择中间;
msgbox.show(无库存")
i am having medicineadd table.in that one column is mid
the form is like this
mid= text box
if i enter any one value not in mid column in that text box , i have to get one msg displaying "no stock",plz send me the code. i am trying to code like this in front end
if (textbox1.text) not in select mid from medicineadd;
msgbox.show("no stock")
推荐答案
检查列值-如果为0,则显示一个消息框.
如果不确定如何使用消息框,请参见此 [^ ]
Check for the column value - if it is 0, display a message box.
If you are not sure how to use a message box, see this[^].
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection oConn = new SqlConnection();
oConn.ConnectionString ="data source=SOLAP;database=SAMPLE;user=sa;password=admin1990";
oConn.Open();
string strSQL ="Select count(*) from stock where MID =''"+ textBox1.Text +"''";
SqlCommand oCmd = new SqlCommand(strSQL,oConn);
if (Convert.ToInt16( oCmd.ExecuteScalar())==0)
MessageBox.Show ("no stock");
else
MessageBox.Show ("yes stock");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
CREATE TABLE [dbo].[stock](
[MID] [varchar](50) NULL
) ON [PRIMARY]
GO
这篇关于味精盒装,无存货的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文