如何使用数据库中的特定数据显示警报消息 [英] how to show alert message with specific data from database

查看:92
本文介绍了如何使用数据库中的特定数据显示警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii all,

实际上我想在其中发出包含特定数据的警报消息,例如产品1已达到其水平。

i不能这样做所以我尝试了另一种方式来显示警告信息但没有特定的pid里面



这里是我的代码

hii all,
actually i want to make an alert message with specific data inside it, for example 'product 1 has reached its level'.
i cannot do it so i tried another way to show the alert message but not with specific pid inside it

here is my code

SqlConnection connection = new SqlConnection("Data Source=aaaVAIO;Initial Catalog=System;Integrated Security=True");

        SqlCommand abc = new SqlCommand("select pid, case when (Pamount <= SafetyStock) then 'has reached its limit!' end as Alert from Product ", connection);
       
        try
            {
         
                connection.Open();

            SqlDataReader rdr = abc.ExecuteReader();
                while (rdr.Read())
                {
              
                    ListBox1.Items.Add(rdr["alert"].ToString());
                    foreach (ListItem li in ListBox1.Items)
                    {
                        if (li.Text.Equals("Limit stock has been reached"))
                        {
                           
                            ClientScriptManager def= Page.ClientScript;

                            {
                                string strconfirm = "<script>if(window.confirm('Limit Stock has been reached!')){window.location.href='/Inventory system/Manager/Updateproductdetails.aspx'}</script>";
                                def.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false);
                            }
                       
                        }
                    }
                }
                rdr.Close();





在上面的代码中,我将sqlcommand输出存储在列表框中,然后警报消息将根据列表内容显示警报消息。如果列表框中已达到限制库存消息,则会出现警报消息。



实际上我想让它更具体地显示特定的pid达到极限。例如,警报消息将显示消息产品1已达到其限制。

请建议我解决此问题。

我应该先将值存储在gridview中吗?或其他任何方式吗?

先谢谢你。



At code above, i store the sqlcommand output in list box then the alert message will show the alert message based on the list content. If there is limit stock has been reached message in the listbox then the alert message will come out.

Actually i want to make it more specific where it shows the specific pid that reached its limit. for example, the alert message will show message 'Product 1 has reached its limit'.
please suggest me solution for this problem.
should i store the value in gridview first? or any other way to do it?
thank you in advanced.

推荐答案

Response.Write("<script>");
            

Response.Write("window.open('AssigningMainChemicals.aspx?RECID=" + recid + "','_blank')");
            
Response.Write("</script>");


试试这个,,, :)



Try this,,,:)

string ser="product 1 has reached its level";







ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Limit Stock has been reached!!!on " + ser + "')", true);


这篇关于如何使用数据库中的特定数据显示警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆