private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox3.Text) || string.IsNullOrEmpty(textBox4.Text)) { MessageBox.Show("One or more required fields are missing", "Missing Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Supplier supplier = new Supplier(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text); supplier.addSupplier(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, db.con); this.Refresh(); this.DialogResult = DialogResult.OK; this.Close(); }