private void buttonAdd_Click(object sender, EventArgs e) { TypeOfGoodsSet typeOfGoodsSet = new TypeOfGoodsSet(); typeOfGoodsSet.Model = textBoxModel.Text; typeOfGoodsSet.Country = textBoxCountry.Text; typeOfGoodsSet.PriceMax = textBoxPriceMax.Text; typeOfGoodsSet.PriceMin = textBoxPriceMin.Text; typeOfGoodsSet.Color = textBoxColor.Text; if (comboBoxType.SelectedIndex == 0) { typeOfGoodsSet.Type = 0; typeOfGoodsSet.Manufacturer = textBoxManufacturer.Text; typeOfGoodsSet.Year = textBoxYear.Text; typeOfGoodsSet.SIMСards = textBoxSIMСards.Text; } else if (comboBoxType.SelectedIndex == 1) { typeOfGoodsSet.Type = 1; typeOfGoodsSet.Manufacturer = textBoxManufacturer.Text; typeOfGoodsSet.Year = textBoxYear.Text; } else { typeOfGoodsSet.Type = 2; } Program.wftDb.TypeOfGoodsSet.Add(typeOfGoodsSet); Program.wftDb.SaveChanges(); TypeOfGoodsSet(); }
private void listView0_SelectedIndexChanged(object sender, EventArgs e) { if (listView0.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView0.SelectedItems[0].Tag as TypeOfGoodsSet; textBoxManufacturer.Text = typeOfGoodsSet.Manufacturer; textBoxModel.Text = typeOfGoodsSet.Model; textBoxCountry.Text = typeOfGoodsSet.Country; textBoxPriceMax.Text = typeOfGoodsSet.PriceMax; textBoxPriceMin.Text = typeOfGoodsSet.PriceMin; textBoxYear.Text = typeOfGoodsSet.Year; textBoxSIMСards.Text = typeOfGoodsSet.SIMСards; textBoxColor.Text = typeOfGoodsSet.Color; } else { textBoxManufacturer.Text = ""; textBoxModel.Text = ""; textBoxCountry.Text = ""; textBoxPriceMax.Text = ""; textBoxPriceMin.Text = ""; textBoxYear.Text = ""; textBoxSIMСards.Text = ""; textBoxColor.Text = ""; } }
private void listView2_SelectedIndexChanged(object sender, EventArgs e) { if (listView2.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView2.SelectedItems[0].Tag as TypeOfGoodsSet; textBoxModel.Text = typeOfGoodsSet.Model; textBoxCountry.Text = typeOfGoodsSet.Country; textBoxPriceMax.Text = typeOfGoodsSet.PriceMax; textBoxPriceMin.Text = typeOfGoodsSet.PriceMin; textBoxColor.Text = typeOfGoodsSet.Color; } else { textBoxModel.Text = ""; textBoxCountry.Text = ""; textBoxPriceMax.Text = ""; textBoxPriceMin.Text = ""; textBoxColor.Text = ""; } }
private void buttonEdit_Click(object sender, EventArgs e) { if (comboBoxType.SelectedIndex == 0) { if (listView0.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView0.SelectedItems[0].Tag as TypeOfGoodsSet; typeOfGoodsSet.Manufacturer = textBoxManufacturer.Text; typeOfGoodsSet.Model = textBoxModel.Text; typeOfGoodsSet.Country = textBoxCountry.Text; typeOfGoodsSet.PriceMax = textBoxPriceMax.Text; typeOfGoodsSet.PriceMin = textBoxPriceMin.Text; typeOfGoodsSet.Year = textBoxYear.Text; typeOfGoodsSet.SIMСards = textBoxSIMСards.Text; typeOfGoodsSet.Color = textBoxColor.Text; Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } else if (comboBoxType.SelectedIndex == 1) { if (listView1.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView1.SelectedItems[0].Tag as TypeOfGoodsSet; typeOfGoodsSet.Manufacturer = textBoxManufacturer.Text; typeOfGoodsSet.Model = textBoxModel.Text; typeOfGoodsSet.Country = textBoxCountry.Text; typeOfGoodsSet.PriceMax = textBoxPriceMax.Text; typeOfGoodsSet.PriceMin = textBoxPriceMin.Text; typeOfGoodsSet.Year = textBoxYear.Text; typeOfGoodsSet.Color = textBoxColor.Text; Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } else { if (listView2.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView2.SelectedItems[0].Tag as TypeOfGoodsSet; typeOfGoodsSet.Model = textBoxModel.Text; typeOfGoodsSet.Country = textBoxCountry.Text; typeOfGoodsSet.PriceMax = textBoxPriceMax.Text; typeOfGoodsSet.PriceMin = textBoxPriceMin.Text; typeOfGoodsSet.Color = textBoxColor.Text; Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } } } } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (comboBoxType.SelectedIndex == 0) { if (listView0.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView0.SelectedItems[0].Tag as TypeOfGoodsSet; Program.wftDb.TypeOfGoodsSet.Remove(typeOfGoodsSet); Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } textBoxManufacturer.Text = ""; textBoxModel.Text = ""; textBoxCountry.Text = ""; textBoxPriceMax.Text = ""; textBoxPriceMin.Text = ""; textBoxYear.Text = ""; textBoxSIMСards.Text = ""; textBoxColor.Text = ""; } else if (comboBoxType.SelectedIndex == 1) { if (listView1.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView1.SelectedItems[0].Tag as TypeOfGoodsSet; Program.wftDb.TypeOfGoodsSet.Remove(typeOfGoodsSet); Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } textBoxManufacturer.Text = ""; textBoxModel.Text = ""; textBoxCountry.Text = ""; textBoxPriceMax.Text = ""; textBoxPriceMin.Text = ""; textBoxYear.Text = ""; textBoxColor.Text = ""; } else { if (listView2.SelectedItems.Count == 1) { TypeOfGoodsSet typeOfGoodsSet = listView2.SelectedItems[0].Tag as TypeOfGoodsSet; Program.wftDb.TypeOfGoodsSet.Remove(typeOfGoodsSet); Program.wftDb.SaveChanges(); TypeOfGoodsSet(); } textBoxModel.Text = ""; textBoxCountry.Text = ""; textBoxPriceMax.Text = ""; textBoxPriceMin.Text = ""; textBoxColor.Text = ""; } } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }