//if product occur in table enable settle payment and discount else disable public void tableShow() { try { bool hasEnable = false; dataGridTransaction.Rows.Clear(); MySqlDataReader reader = pos.displayRecord(Transactionlbl.Text); double total = 0; double isdiscount = 0; while (reader.Read()) { total += Convert.ToDouble(reader["total"].ToString()); isdiscount += Convert.ToDouble(reader["discount"].ToString()); cart_qty = int.Parse(reader["quantity"].ToString()); dataGridTransaction.Rows.Add(reader["transaction_id"].ToString(), reader["products_id"].ToString(), reader["description"].ToString(), reader["price"].ToString(), reader["quantity"].ToString(), reader["discount"].ToString(), reader["total"].ToString()); hasEnable = true; } total_sales.Text = total.ToString("#,##0.00"); txtdiscount.Text = isdiscount.ToString("#,##0.00"); getTotal(); if (hasEnable == true) { settlePayment.Enabled = true; addDiscount.Enabled = true; } else { settlePayment.Enabled = false; addDiscount.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }