コード例 #1
0
        private async void ChangeCarButtonClick(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedCar != null)
            {
                var engTypes = await _db.EngTypes.ToArrayAsync();

                var addCarWindow = new AddCarWindow(engTypes, _db, ViewModel.SelectedCar);
                if (addCarWindow.ShowDialog(this) == true)
                {
                    ViewModel.Cars = await _db.Phones.ToArrayAsync();
                }
            }
            else
            {
                var err = new ErrorWindow("Выберите автомобиль из списка!");
                err.ShowDialog(this);
            }
        }
コード例 #2
0
        private async void OkClick(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedEngType != null && !ViewModel.SelectedEngType.Type.IsNullOrWhiteSpace() &&
                !ViewModel.WorkType.IsNullOrWhiteSpace())
            {
                _db.EngWorks.Add(new EngWork()
                {
                    EngType = ViewModel.SelectedEngType.Type, WorkType = ViewModel.WorkType
                });
                await _db.SaveChangesAsync();


                this.Close();
            }
            else
            {
                var err = new ErrorWindow("Заполните поля!");
                err.ShowDialog(this);
            }
        }
コード例 #3
0
        private async void AddWorkClick(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedWork != null)
            {
                var work = new Work()
                {
                    CarNumber = _car.CarNumber,
                    Date      = ViewModel.SelectedDate.ToShortDateString(),
                    WorkType  = ViewModel.SelectedWork.WorkType
                };
                _db.Works.Add(work);
                await _db.SaveChangesAsync();

                this.Close();
            }
            else
            {
                var err = new ErrorWindow("Выберите тип работы!");
                err.ShowDialog(this);
            }
        }
コード例 #4
0
        private async void AddCarButtonClick(object sender, RoutedEventArgs e)
        {
            if (ViewModel.EngType != null && !ViewModel.Mark.IsNullOrWhiteSpace() &&
                !ViewModel.Model.IsNullOrWhiteSpace() &&
                !ViewModel.Number.IsNullOrWhiteSpace())
            {
                if (Car == null)
                {
                    var car = new Car()
                    {
                        CarModel  = ViewModel.Model,
                        CarBrand  = ViewModel.Mark,
                        CarNumber = ViewModel.Number,
                        EngType   = ViewModel.EngType.Type
                    };
                    _db.Phones.Add(car);
                }
                else
                {
                    _db.Phones.AddOrUpdate(new Car()
                    {
                        Id        = Car.Id,
                        CarBrand  = ViewModel.Mark,
                        CarModel  = ViewModel.Model,
                        CarNumber = ViewModel.Number,
                        EngType   = ViewModel.EngType.Type
                    });
                }

                await _db.SaveChangesAsync();

                DialogResult = true;
                this.Close();
            }
            else
            {
                var err = new ErrorWindow("Заполните поля!");
                err.ShowDialog(this);
            }
        }