Пример #1
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            decimal dailyprice = 0;

            decimal.TryParse(tbxDailyPrice.Text, out dailyprice);

            int modelYear = 0;

            int.TryParse(tbxModelYear.Text, out modelYear);

            Car car = new Car
            {
                BrandId     = (int)cbxBrands_Add.SelectedValue,
                ColorId     = (int)cbxColors_Add.SelectedValue,
                DailyPrice  = dailyprice,
                ModelYear   = modelYear,
                Description = tbxDescription.Text,
                Name        = tbxName.Text
            };
            var result = _carService.Add(car);

            if (result.Success)
            {
                WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Başarılı", result.Message);
                success.ShowDialog();
                LoadCars();
                ShowCount();
                ClearInsertField();
            }
            else
            {
                WindowErrorMessage error = new WindowErrorMessage("Sistem Uyarısı", result.Message);
                error.ShowDialog();
            }
        }
Пример #2
0
        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (!(_selectedCar is null))
            {
                _selectedCar.BrandId     = (int)cbxUpdateBrand.SelectedValue;
                _selectedCar.ColorId     = (int)cbxUpdateColor.SelectedValue;
                _selectedCar.DailyPrice  = Convert.ToDecimal(tbxUpdateDailyPrice.Text);
                _selectedCar.ModelYear   = Convert.ToInt32(tbxUpdateModelYear.Text);
                _selectedCar.Description = tbxUpdateDescription.Text;
                _selectedCar.Name        = tbxUpdatedName.Text;

                var result = _carService.Update(_selectedCar);
                if (result.Success)
                {
                    WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Başarılı", result.Message);
                    success.ShowDialog();
                    LoadCars();
                    ShowCount();
                    ClearInsertField();
                }
                else
                {
                    WindowErrorMessage error = new WindowErrorMessage("Sistem Uyarısı", result.Message);
                    error.ShowDialog();
                }
                LoadCars();
                ClearUpdateField();
                _selectedCar   = null;
                tbxSearch.Text = null;
            }
        }
Пример #3
0
 private void BtnAddRental_Click(object sender, RoutedEventArgs e)
 {
     if (_selectedCustomer != null)
     {
         Rental rental = new Rental
         {
             CarId      = _car.Id,
             RentDate   = DateTime.Now,
             ReturnDate = null,
             CustomerId = _selectedCustomer.Id
         };
         var result = _rentalService.Add(rental);
         if (result.Success)
         {
             WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Sistem Mesajı", result.Message);
             success.ShowDialog();
             this.Close();
         }
         else
         {
             WindowErrorMessage error = new WindowErrorMessage("Sistem Mesajı", result.Message);
             error.ShowDialog();
         }
     }
 }
Пример #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button senderButton = sender as Button;
            var    result       = _rentalService.CheckReturnDate(int.Parse(senderButton.Tag.ToString()));

            if (result.Success)
            {
                WindowRental rental = new WindowRental(carsDto.FirstOrDefault(x => x.Id == int.Parse(senderButton.Tag.ToString())));
                rental.ShowDialog();
            }
            else
            {
                WindowErrorMessage error = new WindowErrorMessage("Sistem Mesajı", result.Message);
                error.ShowDialog();
            }
        }
Пример #5
0
        private void BtnReturnCar_Click(object sender, RoutedEventArgs e)
        {
            if (_rentalDetails != null)
            {
                var result = _rentalService.UpdateReturnDate(_car.Id);

                if (result.Success)
                {
                    WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Sistem Mesajı", "Araç Teslim Alındı");
                    success.ShowDialog();
                    LoadRentals();
                }
                else
                {
                    WindowErrorMessage success = new WindowErrorMessage("Sistem Mesajı", "Araç Zaten Teslim Alınmış");
                    success.ShowDialog();
                }
            }
        }
Пример #6
0
        private void error(string message)
        {
            WindowErrorMessage error = new WindowErrorMessage("Sistem Mesajı", message);

            error.Show();
        }