Ejemplo n.º 1
0
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Car car = new Car
         {
             BrandId     = (int)cbxBrands_Add.SelectedValue,
             ColorId     = (int)cbxColors_Add.SelectedValue,
             DailyPrice  = Convert.ToDecimal(tbxDailyPrice.Text),
             Description = tbxDescription.Text,
             ModelYear   = Convert.ToInt32(tbxModelYear.Text),
             Name        = tbxName.Text
         };
         _carService.Add(car);
         WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Başarılı", "Araç Kayıt İşlemi Başarılı");
         success.ShowDialog();
         LoadCars();
         ShowCount();
         ClearInsertField();
     }
     catch (NullReferenceException)
     {
         WindowErrorMessage error = new WindowErrorMessage("Sistem Uyarısı", "Kayıt başarısız, girdiğiniz bilgileri kontrol ediniz.");
         error.ShowDialog();
     }
     catch (Exception ex)
     {
         WindowErrorMessage error = new WindowErrorMessage("Sistem Uyarısı", ex.Message);
         error.ShowDialog();
     }
 }
Ejemplo n.º 2
0
 private void BtnUpdate_Click(object sender, RoutedEventArgs e)
 {
     if (!(_selectedCar is null))
     {
         try
         {
             _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;
             _carService.Update(_selectedCar);
             WindowsSuccesfulMessage success = new WindowsSuccesfulMessage("Başarılı", "Araç Güncelleme İşlemi Başarılı");
             success.ShowDialog();
             LoadCars();
             ClearUpdateField();
             _selectedCar   = null;
             tbxSearch.Text = null;
         }
         catch (Exception ex)
         {
             WindowErrorMessage error = new WindowErrorMessage("Sistem Uyarısı", ex.Message);
             error.ShowDialog();
         }
     }
 }