private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStorage.SelectedItems.Count == 1)
     {
         StorageSet storage = listViewStorage.SelectedItems[0].Tag as StorageSet;
         storage.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]);
         storage.Location       = textBoxLocation.Text;
         Program.wftDb.SaveChanges();
         ShowStorage();
     }
 }
 private void listViewStorage_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewStorage.SelectedItems.Count == 1)
     {
         StorageSet storage = listViewStorage.SelectedItems[0].Tag as StorageSet;
         comboBoxMaterials.SelectedIndex = comboBoxMaterials.FindString(storage.idNameMaterial.ToString());
         textBoxLocation.Text            = storage.Location;
     }
     else
     {
         comboBoxMaterials.SelectedItem = null;
         textBoxLocation.Text           = "";
     }
 }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxMaterials.SelectedItem != null && textBoxLocation.Text != "")
     {
         StorageSet storage = new StorageSet();
         storage.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]);
         storage.Location       = textBoxLocation.Text;
         Program.wftDb.StorageSet.Add(storage);
         Program.wftDb.SaveChanges();
         ShowStorage();
     }
     else
     {
         MessageBox.Show("Выберите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewStorage.SelectedItems.Count == 1)
                {
                    StorageSet storage = listViewStorage.SelectedItems[0].Tag as StorageSet;
                    Program.wftDb.StorageSet.Remove(storage);
                    Program.wftDb.SaveChanges();
                    ShowStorage();
                }
                comboBoxMaterials.SelectedItem = null;
                textBoxLocation.Text           = "";
            }


            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }