private void button1_Click(object sender, EventArgs e) { switch (whichForm) { case WhichForm.Defendant: { if (nameValid.IsMatch(NameTB.Text) || NameTB.Text == "" || nameValid.IsMatch(SurnameTB.Text) || SurnameTB.Text == "" || nameValid.IsMatch(PatronymicTB.Text) || PatronymicTB.Text == "") { MessageBox.Show("Id writed incorrect. Only numbers."); } else { Connection.Connector(defendant.Insert(NameTB.Text, SurnameTB.Text, PatronymicTB.Text), cantDisp); } break; } case WhichForm.Judge: { if (nameValid.IsMatch(NameTB.Text) || NameTB.Text == "" || nameValid.IsMatch(SurnameTB.Text) || SurnameTB.Text == "" || nameValid.IsMatch(PatronymicTB.Text) || PatronymicTB.Text == "") { MessageBox.Show("Id writed incorrect. Only numbers."); } else { Connection.Connector(judge.Insert(NameTB.Text, SurnameTB.Text, PatronymicTB.Text), cantDisp); } break; } case WhichForm.Plaintiff: { if (nameValid.IsMatch(NameTB.Text) || NameTB.Text == "" || nameValid.IsMatch(SurnameTB.Text) || SurnameTB.Text == "" || nameValid.IsMatch(PatronymicTB.Text) || PatronymicTB.Text == "") { MessageBox.Show("Id writed incorrect. Only numbers."); } else { Connection.Connector(plaintiff.Insert(NameTB.Text, SurnameTB.Text, PatronymicTB.Text), cantDisp); } break; } default: { MessageBox.Show("NO FORM SELECTED"); Close(); break; } } Cleaning(); }