コード例 #1
0
ファイル: FormCar.cs プロジェクト: K2lmar/Auto_Project
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            CarsSet carSet = new CarsSet();

            carSet.ModelCar    = textBoxModelCar.Text;
            carSet.Color       = Convert.ToInt32(comboBoxColor.Text);
            carSet.Price       = Convert.ToInt32(textBoxPrice.Text);
            carSet.StateNumber = textBoxStateNumber.Text;
            carSet.ReleaseYear = textBoxReleaseYear.Text;
            Program.wftDb.CarsSet.Add(carSet);
            Program.wftDb.SaveChanges();
            ShowCar();
        }
コード例 #2
0
ファイル: FormCar.cs プロジェクト: K2lmar/Auto_Project
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewCar.SelectedItems.Count == 1)
     {
         CarsSet carSet = listViewCar.SelectedItems[0].Tag as CarsSet;
         carSet.ModelCar    = textBoxModelCar.Text;
         carSet.Color       = Convert.ToInt32(comboBoxColor.Text);
         carSet.Price       = Convert.ToInt32(textBoxPrice.Text);
         carSet.StateNumber = textBoxStateNumber.Text;
         carSet.ReleaseYear = textBoxReleaseYear.Text;
         Program.wftDb.SaveChanges();
         ShowCar();
     }
 }
コード例 #3
0
ファイル: FormCar.cs プロジェクト: K2lmar/Auto_Project
 private void listViewCar_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewCar.SelectedItems.Count == 1)
     {
         CarsSet carSet = listViewCar.SelectedItems[0].Tag as CarsSet;
         textBoxModelCar.Text    = carSet.ModelCar;
         comboBoxColor.Text      = carSet.Color.ToString();
         textBoxPrice.Text       = carSet.Price.ToString();
         textBoxStateNumber.Text = carSet.StateNumber;
         textBoxReleaseYear.Text = carSet.ReleaseYear;
     }
     else
     {
         textBoxModelCar.Text    = "";
         comboBoxColor.Text      = "";
         textBoxPrice.Text       = "";
         textBoxStateNumber.Text = "";
         textBoxReleaseYear.Text = "";
     }
 }
コード例 #4
0
ファイル: FormCar.cs プロジェクト: K2lmar/Auto_Project
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewCar.SelectedItems.Count == 1)
         {
             CarsSet carSet = listViewCar.SelectedItems[0].Tag as CarsSet;
             Program.wftDb.CarsSet.Remove(carSet);
             Program.wftDb.SaveChanges();
             ShowCar();
         }
         textBoxModelCar.Text    = "";
         comboBoxColor.Text      = "";
         textBoxPrice.Text       = "";
         textBoxStateNumber.Text = "";
         textBoxReleaseYear.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }