private void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextboxFname.Text) == true) { MessageBox.Show("Please Enter Name"); TextboxFname.Focus(); } if (string.IsNullOrEmpty(textBoxAddress.Text) == true) { MessageBox.Show("Please Enter Address"); TextboxFname.Focus(); textBoxAddress.Focus(); } if (string.IsNullOrEmpty(textBoxPhone.Text) == true) { MessageBox.Show("Please Enter Phone"); textBoxAddress.Focus(); } if (string.IsNullOrEmpty(textBoxCusname.Text) == true) { MessageBox.Show("Please Enter Category"); textBoxCusname.Focus(); } else { PurchaseController.NewPurchases(TextboxFname.Text, textBoxAddress.Text, textBoxPhone.Text, textBoxCusname.Text); string message = "Do you want to confirm this program..?"; string title = "Alert"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { this.Hide(); UserType f = new UserType(); f.Show(); } else { // Do something } } }