Здравствуйте, у меня проблемы с выяснением, в чем проблема с моей формой.Я попробовал отладку и дал бы мне следующее:
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\UIAutomationProvider\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationProvider.dll'. Cannot find or open the PDB file.
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll'. Cannot find or open the PDB file.
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.UI.winmd'. Module was built without symbols.
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded 'C:\WINDOWS\system32\WinMetadata\Windows.Foundation.winmd'. Module was built without symbols.
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.InteropServices.WindowsRuntime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.InteropServices.WindowsRuntime.dll'. Module was built without symbols.
'ProjectDAD.exe' (CLR v4.0.30319: ProjectDAD.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.WindowsRuntime\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.WindowsRuntime.dll'. Cannot find or open the PDB file.
The program '[13388] ProjectDAD.exe' has exited with code 0 (0x0).
Никаких ошибок не появляется вообще, но каждый раз, когда я запускаю форму и нажимаю кнопку на форме, ничего не происходит.Не дал бы мне никаких ошибок.Как будто событие не запускается, когда я нажимаю кнопку.
Вот мой код Cs для формы:
using System;
using System.Windows;
using ProjectDAD.Models.DB;
namespace ProjectDAD.Rental_Management
{
/// <summary>
/// Interaction logic for toRent.xaml
/// </summary>
public partial class toRent : Window
{
public toRent()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Data.CollectionViewSource truckRentalViewSource =
((System.Windows.Data.CollectionViewSource)
(this.FindResource("truckRentalViewSource")));
// Load data by setting the CollectionViewSource.Source property:
// truckRentalViewSource.Source = [generic data source]
System.Windows.Data.CollectionViewSource truckCustomerViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("truckCustomerViewSource")));
// Load data by setting the CollectionViewSource.Source property:
// truckCustomerViewSource.Source = [generic data source]
System.Windows.Data.CollectionViewSource truckPersonViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("truckPersonViewSource")));
// Load data by setting the CollectionViewSource.Source property:
// truckPersonViewSource.Source = [generic data source]
}
private void Button_Click(object sender, RoutedEventArgs e)
{
TruckCustomer cust = new TruckCustomer();
cust.Age = int.Parse(ageTextBox.Text);
cust.LicenseNumber = licenseNumberTextBox.Text;
cust.LicenseExpiryDate = licenseExpiryDateDatePicker.SelectedDate.Value.Date;
TruckPerson per = new TruckPerson();
per.Address = addressTextBox.Text;
per.Telephone = telephoneTextBox.Text;
per.Name = nameTextBox.Text;
int truckId = int.Parse(truckIdTextBox.Text);
IndividualTruck truck = DataService.searchTruckByID(truckId);
decimal priceTotal = decimal.Parse(totalPriceTextBox.Text);
TruckRental toRent = new TruckRental();
toRent.TotalPrice = priceTotal;
toRent.RentDate = new DateTime();
toRent.ReturnDate = new DateTime();
toRent.Customer = cust;
toRent.Truck = truck;
truck.Status = "Rented";
DataService.rentTruck(toRent, true);
MessageBox.Show("Truck rented succesfully");
}
}
}
Вот моя служба данныхcs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectDAD.Models.DB;
using Microsoft.EntityFrameworkCore;
namespace ProjectDAD
{
public class DataService
{
public static void rentTruck(TruckRental toRent, bool isNewCustomer)
{
using (var ctx = new DAD_TruckRental_RGMContext())
{
if(!isNewCustomer)
{
ctx.Entry(toRent.Customer).State = EntityState.Unchanged;
}
ctx.Entry(toRent.Customer).State = EntityState.Modified;
ctx.TruckRental.Add(toRent);
ctx.SaveChanges();
}
}
public static IndividualTruck searchTruckByID(int truckid)
{
using (var ctx = new DAD_TruckRental_RGMContext())
{
return ctx.IndividualTruck.Where(t => t.TruckId == truckid).FirstOrDefault();
}
}
}
}