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 RemoveOrder_Click(object sender, RoutedEventArgs e)
        {
            FuncOrders1_Result selectedRow = new FuncOrders1_Result();

            selectedRow = (FuncOrders1_Result)this.DataGridOrders.SelectedItems[0];

            TableOrders rowForDel = new TableOrders();

            rowForDel = (from c in context.TableOrders where c.Id == selectedRow.id select c).First();

            context.TableOrders.Remove(rowForDel);
            context.SaveChanges();
            RefreshWindow();
        }
Exemple #3
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            TableOrders editedOrder = new TableOrders();

            editedOrder = (TableOrders)(from c in context.TableOrders where c.Id == selectedRow.id select c).First();

            editedOrder.idPerson = editedPersonID;
            editedOrder.idCar    = editedCarID;
            editedOrder.Date     = this.DatePickedDateEdited.SelectedDate;
            editedOrder.Amount   = Convert.ToDecimal(this.TextBoxAmountEdited.Text);

            TableStatus editedStatus = new TableStatus();

            editedStatus = (from c in context.TableStatus
                            where c.Status == this.ComboBoxEditStatus.Text
                            select c).First();
            editedOrder.StatusID = editedStatus.Id;

            context.SaveChanges();
            this.Close();
        }