private void BtAdd_Click(object sender, EventArgs e) { string name; string cals; string amount; string id; string cost; if (tbName.Text.Length > 0) { name = tbName.Text; } else { name = "none"; } if (DBOps.isReal(tbCals.Text)) { cals = tbCals.Text; } else { cals = "0.0"; } if (DBOps.isReal(tbAmount.Text)) { amount = tbAmount.Text; } else { amount = "0.0"; } if (DBOps.isInteger(tbCost.Text)) { cost = tbCost.Text; } else { cost = "0"; } if (cbUnits.Text != "") { id = cbUnits.SelectedIndex.ToString(); } else { id = "0"; } string Query = $"INSERT INTO Products ('Name', 'Calories', 'Amount', 'UnitID', 'Cost') values" + $" ('{name}','{cals}','{amount}','{id}','{cost}')"; DBOps.WriteDB(Query); }