Пример #1
0
        private void buttonAdd_Click_1(object sender, EventArgs e)
        {
            CarsSet carsSet = new CarsSet();

            carsSet.Mark      = textBoxMarka.Text;
            carsSet.Model     = textBoxModel.Text;
            carsSet.Kompl     = textBoxKompl.Text;
            carsSet.SerNumber = textBoxSerNomer.Text;
            carsSet.Price     = textBoxPrice.Text;
            Program.dbmotor.CarsSet.Add(carsSet);
            Program.dbmotor.SaveChanges();
            ShowCars();
        }
Пример #2
0
 private void buttonEdit_Click_1(object sender, EventArgs e)
 {
     if (listViewCars.SelectedItems.Count == 1)
     {
         CarsSet carsset = listViewCars.SelectedItems[0].Tag as CarsSet;
         carsset.Mark      = textBoxMarka.Text;
         carsset.Model     = textBoxModel.Text;
         carsset.Kompl     = textBoxKompl.Text;
         carsset.SerNumber = textBoxSerNomer.Text;
         carsset.Price     = textBoxPrice.Text;
         Program.dbmotor.SaveChanges();
         ShowCars();
     }
 }
Пример #3
0
 private void listViewCars_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     if (listViewCars.SelectedItems.Count == 1)
     {
         CarsSet carsSet = listViewCars.SelectedItems[0].Tag as CarsSet;
         textBoxMarka.Text    = carsSet.Mark;
         textBoxModel.Text    = carsSet.Model;
         textBoxKompl.Text    = carsSet.Kompl;
         textBoxSerNomer.Text = carsSet.SerNumber;
         textBoxPrice.Text    = carsSet.Price;
     }
     else
     {
         textBoxMarka.Text    = "";
         textBoxModel.Text    = "";
         textBoxKompl.Text    = "";
         textBoxSerNomer.Text = "";
         textBoxPrice.Text    = "";
     }
 }
Пример #4
0
 private void buttonDel_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (listViewCars.SelectedItems.Count == 1)
         {
             CarsSet carsSet = listViewCars.SelectedItems[0].Tag as CarsSet;
             Program.dbmotor.CarsSet.Remove(carsSet);
             Program.dbmotor.SaveChanges();
             ShowCars();
         }
         textBoxMarka.Text    = "";
         textBoxModel.Text    = "";
         textBoxKompl.Text    = "";
         textBoxSerNomer.Text = "";
         textBoxPrice.Text    = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }