public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (INN != null ? INN.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (KPP != null ? KPP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PositionsCount.GetHashCode(); hashCode = (hashCode * 397) ^ Sum.GetHashCode(); return(hashCode); } }
private void KPP_Click(object sender, RoutedEventArgs e) { KPP add = new KPP(); add.Show(); }
public KPPViewModel() { kPP = new KPP(); }
private void addBtn_Click(object sender, EventArgs e) { EntitiesAutomobiles automobiles = new EntitiesAutomobiles(); string brandN = textBrand.Text; string modelN = textModel.Text; string classN = textClass.Text; string kppN = textKPP.Text; Automobiles auto = new Automobiles(); auto.price = decimal.Parse(textPrice.Text); auto.yearModel = Int32.Parse(textYear.Text); if (brandN != "") { Brands brand = automobiles.Brands.Where(x => x.nameBrand == brandN).FirstOrDefault(); if (brand == null) { Brands newBrand = new Brands { nameBrand = brandN }; automobiles.Brands.Add(newBrand); automobiles.SaveChanges(); brand = automobiles.Brands.Where(x => x.nameBrand == brandN).FirstOrDefault(); auto.idBrand = brand.idBrand; } else { auto.idBrand = brand.idBrand; } } if (modelN != "" && classN != "") { Models model = automobiles.Models.Where(x => x.nameModel == modelN && x.classModel == classN).FirstOrDefault(); if (model == null) { Models newModel = new Models { nameModel = modelN, classModel = classN }; automobiles.Models.Add(newModel); automobiles.SaveChanges(); model = automobiles.Models.Where(x => x.nameModel == modelN && x.classModel == classN).FirstOrDefault(); auto.idModel = model.idModel; } else { auto.idModel = model.idModel; } } if (kppN != "") { KPP kpp = automobiles.KPP.Where(x => x.nameKPP == kppN).FirstOrDefault(); if (kpp == null) { KPP newKpp = new KPP { nameKPP = kppN }; automobiles.KPP.Add(newKpp); automobiles.SaveChanges(); kpp = automobiles.KPP.Where(x => x.nameKPP == kppN).FirstOrDefault(); auto.idKPP = kpp.idKPP; } else { auto.idKPP = kpp.idKPP; } } automobiles.Automobiles.Add(auto); automobiles.SaveChanges(); SaveFoto(); auto = automobiles.Automobiles .Where(x => x.Brands.nameBrand == brandN && x.Models.nameModel == modelN && x.Models.classModel == classN).FirstOrDefault(); foreach (ListViewItem lvi in listView1.Items) { string path = "packages\\Foto\\"; path += lvi.Text + ".jpg"; Images image = new Images(); image.idAuto = auto.idAuto; image.image = path; automobiles.Images.Add(image); } automobiles.SaveChanges(); }