private void Save_btn_Click(object sender, EventArgs e) { // get values from textboxes string goal_name = goalname_textBox.ForeColor == Color.Black ? goalname_textBox.Text : ""; string amount = goalamount_textBox.ForeColor == Color.Black ? goalamount_textBox.Text : ""; int cat_id = categories[Categories_comboBox.SelectedItem.ToString()]; DateTime term = term_dateTimePicker.Value; // verify if field is filled if (goal_name.Equals("")) { ErrorMessenger.EmptyField("Goal name"); return; } if (amount.Equals("")) { ErrorMessenger.EmptyField("Goal amount"); return; } double goal_amount = DB_API.UnMoneyfy(amount); // add new goal if (!Subcategories_comboBox.SelectedItem.ToString().Equals(this.none)) { cat_id = categories[Subcategories_comboBox.SelectedItem.ToString()]; } try { DB_API.InsertGoal(account_id, cat_id, goal_name, goal_amount, term); } catch (SqlException ex) { ErrorMessenger.Exception(ex); } PopulateGoalsListBox(); }