Exemple #1
0
        private void listViewAvailability_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewAvailability.SelectedItems.Count == 1)
            {
                AvailabilitySet availabilitySet = listViewAvailability.SelectedItems[0].Tag as AvailabilitySet;

                comboBoxCar.Text  = availabilitySet.CarsSet.Model;
                comboBoxFirm.Text = availabilitySet.FirmsSet.NameFirm;
            }
            else
            {
                comboBoxFirm.SelectedItem = null;
                comboBoxCar.SelectedItem  = null;
            }
        }
Exemple #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (comboBoxCar.SelectedItem != null && comboBoxFirm.SelectedItem != null)
     {
         AvailabilitySet availabilitySet = new AvailabilitySet();
         availabilitySet.IdCar  = Convert.ToInt32(comboBoxCar.SelectedItem.ToString().Split('.')[0]);
         availabilitySet.IdFirm = Convert.ToInt32(comboBoxFirm.SelectedItem.ToString().Split('.')[0]);
         Program.cGG.SaveChanges();
         ShowAvailability();
     }
     else
     {
         MessageBox.Show("Выберите автомобиль и фирму!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #3
0
        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewAvailability.SelectedItems.Count == 1)
                {
                    AvailabilitySet availabilitySet = listViewAvailability.SelectedItems[0].Tag as AvailabilitySet;
                    Program.cGG.AvailabilitySet.Remove(availabilitySet);
                    Program.cGG.SaveChanges();
                    ShowAvailability();
                }

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