TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Carol Cashman
NA
74
11.7k
how to notify when stock levels have reached below a certain
Jan 8 2018 10:54 AM
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("<table border='1'>");
table.Append("<tr><th>ID</th><th>Amount Of Stickers</th><th>Amount of Small Jars</th><th>Amount of Large Jars</th><th> Amount of Lids</th>");
table.Append("</tr>");
if (rd.HasRows)
{
while (rd.Read())
{
table.Append("<tr>");
table.Append("<td>" + rd[0] + "</td>");
table.Append("<td>" + rd[1] + "</td>");
table.Append("<td>" + rd[2] + "</td>");
table.Append("<td>" + rd[3] + "</td>");
table.Append("<td>" + rd[4] + "</td>");
table.Append("</tr>");
}
}
table.Append("</table");
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!
Reply
Answers (
4
)
Error when trying reduce a certain number from the database
How to fetch data from perticular column in excel using C# ?