예제 #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();
     }
 }
예제 #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;
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }