private void ButtonOK_Click(object sender, RoutedEventArgs e) { TableCars selectedCar = new TableCars(); selectedCar = (TableCars)(from c in context.TableCars where c.VIN == selectedCarVIN select c).First(); TableStatus selectedStatus = new TableStatus(); selectedStatus = (TableStatus)(from c in context.TableStatus where c.Status == this.ComboBoxStatus.Text select c).First(); TableOrders newRow = new TableOrders(); newRow.idCar = selectedCar.Id; newRow.idPerson = selectedPersonID; newRow.Date = this.DatePickerBirth.SelectedDate; newRow.Amount = Convert.ToDecimal(this.TextBoxAmount.Text); //!!! newRow.StatusID = selectedStatus.Id; context.TableOrders.Add(newRow); context.SaveChanges(); this.Close(); }
private void ButtonAdd_Click(object sender, RoutedEventArgs e) { TableCars newCar = new TableCars(); var row1 = (TableMakers)(from c in context.TableMakers where c.Maker == this.ComboBoxMaker.Text select c).First(); newCar.MakerID = (int)row1.Id; var row2 = (TableModels)(from c in context.TableModels where c.Model == this.ComboBoxModel.Text select c).First(); newCar.ModelID = (int)row2.Id; newCar.Year = this.DatePicketYear.SelectedDate; newCar.VIN = this.TextBoxVIN.Text; context.TableCars.Add(newCar); context.SaveChanges(); this.Close(); }