title: How to Display Warning message if quantity is less than 5 items
body: <p>I'm creating an inventory system which should display the products that needs to be restock. If the quantity of the product is only 5 it should display a message that says you need to restock now. But I don't know how to do that because I'm creating an Inventory System only and not Sales and Inventory so how should I deduct it if I don't have sales system? I'm sorry, hope u guys understand.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void all()
  {
          SqlConnection MySqlConnection;
          DataTable p_table = new DataTable();
  
          MySqlConnection = new SqlConnection("Data Source=christina\\sqlexpress;Initial Catalog=cafe_inventory;User ID=sa;Password=tina;");
  
          MySqlConnection.Open();
          SqlCommand command1 = new SqlCommand("Select * from inventory", MySqlConnection);
  
          //Clear the datatable to prevent duplicate generation of data in gridview.
          p_table.Clear();
          SqlDataAdapter m_da = new SqlDataAdapter("Select * from inventory", MySqlConnection);
          //DataSet ds = new DataSet();
          //DataTable dtable = ds.Tables["empinfo1"];
          m_da.Fill(p_table);
          // Clear the ListView control
          //listView3.Items.Clear();
  
          // Display items in the ListView control
          for (int i = 0; i &lt; p_table.Rows.Count; i++)
          {
              DataRow drow = p_table.Rows[i];
  
              // Only row that have not been deleted
              if (drow.RowState != DataRowState.Deleted)
              {
                  // Define the list items
                  //(drow["bnum"].ToString());
                  ListViewItem lvi = new ListViewItem(drow["pnum"].ToString());
                  lvi.SubItems.Add(drow["pname"].ToString());
                  lvi.SubItems.Add(drow["descr"].ToString());
                  lvi.SubItems.Add(((DateTime)drow["dater"]).ToShortDateString());
                  //lvi.SubItems.Add(drow["exp"].ToString());
                  lvi.SubItems.Add(((DateTime)drow["exp"]).ToShortDateString());
                  lvi.SubItems.Add(drow["qt"].ToString());
  
                  // Add the list items to the ListView
                  listView2.Items.Add(lvi);
              }
          }
      }
  </code></pre>
  
  <p>edited code:</p>
  
  <pre><code>public void stock()
      {
  
          SqlConnection MySqlConnection;
          DataTable p_table = new DataTable();
  
          MySqlConnection = new SqlConnection("Data Source=christina\\sqlexpress;Initial Catalog=cafe_inventory;User ID=sa;Password=tina;");
  
          MySqlConnection.Open();
          SqlCommand command1 = new SqlCommand("Select pname from inventory where qt &lt; 5", MySqlConnection);
  
          //Clear the datatable to prevent duplicate generation of data in gridview.
          p_table.Clear();
          SqlDataAdapter m_da = new SqlDataAdapter("Select pname from inventory where qt &lt; 5", MySqlConnection);
          m_da.Fill(p_table);
  
          SqlDataReader reader;
          reader = command1.ExecuteReader();
  
          StringBuilder productNames = new StringBuilder();
  
          while (reader.Read())
          {
              productNames.Append(reader["pname"].ToString() + Environment.NewLine);
          }
  
          MySqlConnection.Close();
  
          MessageBox.Show("There are products that needs restocking, check to restock now." + productNames);
  
          // Display items in the ListView control
          for (int i = 0; i &lt; p_table.Rows.Count; i++)
          {
  
              DataRow drow = p_table.Rows[i];
  
              // Only row that have not been deleted
              if (drow.RowState != DataRowState.Deleted)
              {
                  // Define the list items
                  //ListViewItem lvi = new ListViewItem(drow["bnum"].ToString());
                  ListViewItem lvi = new ListViewItem(drow["pnum"].ToString());
                  lvi.SubItems.Add(drow["pname"].ToString());
                  lvi.SubItems.Add(drow["descr"].ToString());
                  lvi.SubItems.Add(((DateTime)drow["dater"]).ToShortDateString());
                  //lvi.SubItems.Add(drow["exp"].ToString());
                  lvi.SubItems.Add(((DateTime)drow["exp"]).ToShortDateString());
                  lvi.SubItems.Add(drow["qt"].ToString());
                  lvi.SubItems.Add(drow["interval"].ToString());
  
                  // Add the list items to the ListView
                  listView4.Items.Add(lvi);
              }
          }
  
      }
  </code></pre>