Example #1
0
 private void listView_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView.SelectedItems.Count == 1)
     {
         DealSet deal = listView.SelectedItems[0].Tag as DealSet;
         comboBoxSupply.SelectedIndex = comboBoxSupply.FindString(deal.idSupply.ToString());
         comboBoxDemand.SelectedIndex = comboBoxDemand.FindString(deal.idDemand.ToString());
     }
 }
Example #2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count == 1)
            {
                DealSet deal = listView.SelectedItems[0].Tag as DealSet;
                deal.idSupply = Convert.ToInt32(comboBoxSupply.SelectedItem.ToString().Split('.')[0]);
                deal.idDemand = Convert.ToInt32(comboBoxDemand.SelectedItem.ToString().Split('.')[0]);

                Program.RPE.SaveChanges();
                ShowDealSet();
            }
        }
Example #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.RPE.DealSet.Add(deal);
         Program.RPE.SaveChanges();
         ShowDealSet();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView.SelectedItems.Count == 1)
         {
             DealSet deal = listView.SelectedItems[0].Tag as DealSet;
             Program.RPE.DealSet.Remove(deal);
             Program.RPE.SaveChanges();
             ShowDealSet();
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }