private void btnAddMilitaryUnit_Click(object sender, RoutedEventArgs e) { MilitaryUnit m = addMilitaryUnit.getNewMilitaryUnit(); if (m != null) { if (mList == null) { mList = new MilitaryUnitList(); } int id = sqlWorker.getNewId("MilitaryUnit"); m.Id = id; if (sqlWorker.addMilitaryUnit(id, m)) { mList.values.Add(m); } else { MessageBox.Show("Ошибка при добавлении элемента"); } } }