private void buttonGO_Click(object sender, RoutedEventArgs e) { bool flag = false; for (int i = 0; i < List.Count; i++) { if (List[i].val1 != -1 || List[i].val2 != -1) { string names = "GOST_ID,MARKA,VYTYAZHKA"; for (int j = 0; j < List.Count; j++) { names += "," + task.yAll[j].name + "_MIN," + task.yAll[j].name; } string values = "'" + textBoxGost.Text + "','" + textBoxMarka.Text + "','" + textBoxType.Text + "'"; for (int j = 0; j < List.Count; j++) { values += "," + List[j].val1.ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + List[j].val2.ToString(System.Globalization.CultureInfo.InvariantCulture); } DBWorker dbConnection = new DBWorker(); int res = dbConnection.InsertGOST(names, values); dbConnection.CloseConnection(); if (res == 1) { MessageBox.Show("Запись добавлена!"); } else { MessageBox.Show("Ошибка добавления!"); } this.Close(); flag = true; break; } } if (flag == false) { MessageBox.Show("Введите границы!"); } }