private void checkForLowStock() { try { //load a list of all products products = handler.getAllProductsAndDetails(); //sort the products by stock count products = Tuple.Create(products.Item1.OrderBy(o => o.Qty).ToList(), products.Item2.OrderBy(o => o.Qty).ToList()); #region out of stock //check for out of stock products //check out of stock treatments foreach (SP_GetAllTreatments treat in products.Item2) { if (treat.Qty <= 0 && dashOutCount == 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("❗", "Out Of Stock", "<a href='../Manager/Products.aspx?ProductID=" + treat.ProductID.ToString() + "&Action=NewOrder" + "'>" + treat.Name + "</a>"); dashOutCount++; } else if (treat.Qty <= 0 && dashOutCount > 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("❗", "", "<a href='../Manager/Products.aspx?ProductID=" + treat.ProductID.ToString() + "&Action=NewOrder" + "'>" + treat.Name + "</a>"); dashOutCount++; } } //check out of stock accessories foreach (SP_GetAllAccessories Access in products.Item1) { if (Access.Qty <= 0 && dashOutCount == 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("❗", "Out Of Stock", "<a href='../Manager/Products.aspx?ProductID=" + Access.ProductID.ToString() + "&Action=NewOrder" + "'>" + Access.Name + "</a>"); dashOutCount++; } else if (Access.Qty <= 0 && dashOutCount > 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("❗", "", "<a href='../Manager/Products.aspx?ProductID=" + Access.ProductID.ToString() + "&Action=NewOrder" + "'>" + Access.Name + "</a>"); dashOutCount++; } } #endregion #region Low Stock int lowStock = handler.getStockSettings().LowStock; //check for low stock //check low stock treatments foreach (SP_GetAllTreatments treat in products.Item2) { if (treat.Qty < lowStock && treat.Qty > 0 && dashLowCount == 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("⚠", "Low Stock", "<a href='../Manager/Products.aspx?ProductID=" + treat.ProductID.ToString() + "&Action=NewOrder" + "'>" + treat.Name + "</a><br/> " + treat.Qty + " Left in stock"); dashLowCount++; } else if (treat.Qty < lowStock && treat.Qty > 0 && dashLowCount > 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("⚠", "", " <a href='../Manager/Products.aspx?ProductID=" + treat.ProductID.ToString() + "&Action=NewOrder" + "'>" + treat.Name + "</a><br/> " + treat.Qty + " Left in stock"); dashLowCount++; } } //check low stock accessories foreach (SP_GetAllAccessories Access in products.Item1) { if (Access.Qty < lowStock && Access.Qty > 0 && dashLowCount == 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("⚠", "Low Stock", "<a href='../Manager/Products.aspx?ProductID=" + Access.ProductID.ToString() + "&Action=NewOrder" + "'>" + Access.Name + "</a><br/>" + Access.Qty + " Left in stock"); dashLowCount++; } else if (Access.Qty < lowStock && Access.Qty > 0 && dashLowCount > 0) { //if the accessory is low and stock add an alert to the alert table addAlertToTable("⚠", "", "<a href='../Manager/Products.aspx?ProductID=" + Access.ProductID.ToString() + "&Action=NewOrder" + "'>" + Access.Name + "</a><br/> " + Access.Qty + " Left in stock"); dashLowCount++; } } #endregion } catch (Exception Err) { addAlertToTable("", "Error", "An error occurred loading all alerts"); function.logAnError("unable to load alerts on Receptionist/Dashboard.aspx: " + Err); } }