private void button1_Click(object sender, EventArgs e) { if (inputtextBox.Text == "") { MessageBox.Show("Plase input a department!"); return; } if (Department.GetDepartmentList().Any(department => department.GetDepartment() == inputtextBox.Text)) { MessageBox.Show("Sorry, but that department already exists! :("); return; } //Изиква метод, който изпраща SQL завката към базата и връща true или if (!DBConnection.InsertDepartment(inputtextBox.Text)) { MessageBox.Show("There was and error with inserting!"); return; } MessageBox.Show("Successfully added a new department in the company!"); //Добавяне на отдела към listBox-а, за да не се изпълнява наново INSERT заявка depListB.Items.Add(inputtextBox.Text); delCombo.Items.Add(inputtextBox.Text); }