View Single Post
  #1 (permalink)  
Old May 14th, 2014, 06:13 AM
meme meme is offline
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question automatic alert message by detecting sql command

hii guys, please help me to solve my problem.
actually im doing inventory system where one of its function is to automatically detect the stock/product that has reach its limit by using alert message.
for this case, i have product table that consist pid, pname, vendorid, productamount, lead time and safetystockamount.
im doing it using c#.net (visual studio 2010). im using sql server for database.

in my page, i actually will show the product details by using gridview tool in visual studio by referring to product table in my database and when the user first come into the page, the alert message will come out. This alert message only will pop out if there is one or more product that reached its stock limit. If all the product amount are in more than safetyamount then this alert message will not coming up.

my sql command for this function is :
<code>
select case when (P_Amount <= SafetyStockamount)
then 'Limit stock has been reached'
end as Alert
from Product </code>

when i execute this statement in my sql server management studio then the result will show the list of product stock level condition. if the product amount is less than safetystockamount then it will show 'limit stock has been reached' while if the product amount is in good condition then it will be 'null'.

For the c# code i also tried to combine both alert message code and sql command but as i can see the program only execute the alert message code so everytime when i open the page then the alert message will pop up. It will happen everytime which means even though one of the product amount is still in good condition (> then safetystockamount), the pop up alert also will come out. @@

below is my c# code :
<code>if (Page.IsPostBack)
{
SqlConnection connection = new SqlConnection("Data Source=MELINA_YEO-VAIO; Initial Catalog=InventorySystem; Integrated Security=True");
connection.Open();
SqlCommand abc = new SqlCommand("Select case when (P_Amount <= SafetyStockamount) then 'Limit stock has been reached' end as Alert from Product");
Page.RegisterStartupScript("ScriptDescription", "<script type=\"text/javascript\"> alert('Limit stock has been reached');</script>");
} </code>


my javascript code:
<script type="text/javascript">
alert('Limit stock has been reached!');
</script>

please give me solution for this problem. thanks in advance :)
Reply With Quote