Exemple #1
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStorage.SelectedItems.Count == 1)
     {
         StorageSet storageSet = listViewStorage.SelectedItems[0].Tag as StorageSet;
         storageSet.IdProvider = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]);
         storageSet.IdProduct  = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
         Program.psDb.SaveChanges();
         ShowStorage();
     }
 }
Exemple #2
0
 private void ListViewStorage_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewStorage.SelectedItems.Count == 1)
     {
         StorageSet storageSet = listViewStorage.SelectedItems[0].Tag as StorageSet;
         comboBoxProvider.Text = storageSet.IdProvider.ToString() + ". " + storageSet.ProviderSet.NameCompany;
         comboBoxProduct.Text  = storageSet.IdProduct.ToString() + ". " + storageSet.ProductSet.Product;
     }
     else
     {
         comboBoxProvider.Text = "";
         comboBoxProduct.Text  = "";
     }
 }
Exemple #3
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            if (comboBoxProvider.SelectedItem != null && comboBoxProduct.SelectedItem != null)
            {
                StorageSet storageSet = new StorageSet();
                storageSet.IdProvider = Convert.ToInt32(comboBoxProvider.SelectedItem.ToString().Split('.')[0]);
                storageSet.IdProduct  = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]);
                Program.psDb.StorageSet.Add(storageSet);
                Program.psDb.SaveChanges();
                ShowStorage();
            }

            else
            {
                MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #4
0
 private void ButtonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewStorage.SelectedItems.Count == 1)
         {
             StorageSet storageSet = listViewStorage.SelectedItems[0].Tag as StorageSet;
             Program.psDb.StorageSet.Remove(storageSet);
             Program.psDb.SaveChanges();
             ShowStorage();
         }
         comboBoxProvider.Text = "";
         comboBoxProduct.Text  = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }