void setOutofStockandLowStock() { try { int LowStockcount = 0; int outOfStockcount = 0; BusinessObjects.stock_product stoProduct = new stock_product(); outOfStockcount = stoProduct.GetOutOfStock(con); BusinessObjects.GetProductStock spObj = new GetProductStock(); List <GetProductStock> avalibilityList = new List <GetProductStock>(); avalibilityList = spObj.getProdAlongWithStockQuantity_All(con); foreach (var item in avalibilityList) { if (item.TotalQuantity < 5) { LowStockcount++; } } lblOutOfStock.Text = outOfStockcount.ToString() + " Prods"; lblLowStock.Text = LowStockcount.ToString() + " Prods"; } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitialloadGrid() { try { List <GetProductStock> GridList = new List <GetProductStock>(); BusinessObjects.GetProductStock spObj = new GetProductStock(); GridList = spObj.getProdAlongWithStockQuantity_All(con); List <M_Product_BS> cObjList = new List <M_Product_BS>(); BusinessObjects.M_Product_BS cObj = new M_Product_BS(); cObjList = cObj.GetProducts(con); //MessageBox.Show(cObjList.Count.ToString()); //this is to set the category name List <Category_BS> catList = new List <Category_BS>(); Category_BS catObj = new Category_BS(); catList = catObj.GetCategory(con); foreach (Category_BS itemCat in catList) { foreach (GetProductStock itemProd in GridList) { if (itemProd.category == itemCat.ID) { itemProd.catObj = itemCat; } } } int i = 0; tblProduct.Rows.Clear(); foreach (GetProductStock item in GridList) { if (item.TotalQuantity > 3) { continue; } tblProduct.Rows.Add(); tblProduct.Rows[i].Cells[0].Value = item.ID; tblProduct.Rows[i].Cells[1].Value = item.name; tblProduct.Rows[i].Cells[2].Value = item.catObj.name; tblProduct.Rows[i].Cells[3].Value = item.cost; tblProduct.Rows[i].Cells[4].Value = item.unitPrice; tblProduct.Rows[i].Cells[5].Value = item.warranty; tblProduct.Rows[i].Cells[6].Value = item.TotalQuantity; i++; } } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "MetroMessageBox", MessageBoxButtons.OK, MessageBoxIcon.Error); } }