I'm stuck with a part of a project. I have a database set up in SQL server with a table called stockTable which keep account of the four different types of materials needed.
I am using c# and ASP.net and doing this is Visual studio 2013.
I ultimately want to be able to be notified (maybe a messagebox) when these stock levels have reached below a certain level (EG: 200) and then email the manager to order some more materials.
I have the materials within a table and they are out putted by using a placeholder.
I am unsure in how to check the values in this placeholder and compare it to the minimum level that i will set. (EG:200).
This is how the table is created and shown on the webform.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ToString();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select * from [StockTable]";
cmd.Connection = con;
SqlDataReader rd = cmd.ExecuteReader();
table.Append("");
| ID | Amount Of Stickers | Amount of Small Jars | Amount of Large Jars | Amount of Lids | ");
|---|---|---|---|---|
| " + rd[0] + " | ");" + rd[1] + " | ");" + rd[2] + " | ");" + rd[3] + " | ");" + rd[4] + " | ");
PlaceHolder1.Controls.Add(new Literal { Text = table.ToString() });
rd.Close();
}
}
Does anyone know how to do this, was thinking an if statement comparing the values but i am unsure of how to go about this.
if anyone has suggestions or snippets of code, it would be greatly appreciated, or easier ways in order to email the manager when stock levels are low.
Thank you very much!
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nitin SontakkePosted Jan 9, 2018, 11:02 PM
Carol CashmanPosted Jan 9, 2018, 11:46 AM
Laxmidhar SahooPosted Jan 9, 2018, 1:28 AM
Nitin SontakkePosted Jan 8, 2018, 10:29 PM