Esempio n. 1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewDealSet.SelectedItems.Count == 1)
     {
         DealSet deal = listViewDealSet.SelectedItems[0].Tag as DealSet;
         deal.IdSupply = Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]);
         deal.IdDemand = Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]);
         Program.wftDb.SaveChanges();
         ShowDealSet();
     }
 }
Esempio n. 2
0
 private void listViewDealSet_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDealSet.SelectedItems.Count == 1)
     {
         DealSet deal = listViewDealSet.SelectedItems[0].Tag as DealSet;
         comboBoxSupply.SelectedIndex = comboBoxSupply.FindString(deal.IdSupply.ToString());
         comboBoxDemand.SelectedIndex = comboBoxDemand.FindString(deal.IdDemand.ToString());
     }
     else
     {
         comboBoxSupply.SelectedItem = null;
         comboBoxDemand.SelectedItem = null;
     }
 }
Esempio n. 3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxDemand.SelectedItem != null && comboBoxSupply.SelectedItem != null)
     {
         DealSet deal = new DealSet();
         deal.IdSupply = Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]);
         deal.IdDemand = Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]);
         Program.wftDb.DealSet.Add(deal);
         Program.wftDb.SaveChanges();
         ShowDealSet();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewDealSet.SelectedItems.Count == 1)
         {
             DealSet deal = listViewDealSet.SelectedItems[0].Tag as DealSet;
             Program.wftDb.DealSet.Remove(deal);
             Program.wftDb.SaveChanges();
             ShowDealSet();
         }
         comboBoxSupply.SelectedItem = null;
         comboBoxDemand.SelectedItem = null;
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись уже используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }