宝臣 王 3 місяців тому
батько
коміт
4276088efe

+ 3 - 3
UniformMaterialManagementSystem/ViewModels/RegisterPageViewModel.cs

@@ -39,7 +39,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private ICollection<Company> _companyList = [];
 
         [ObservableProperty]
-        private Company _selectedCompany = null!;
+        private Company? _selectedCompany;
 
         [ObservableProperty]
         [Required(ErrorMessage = "用户名不能为空")]
@@ -87,9 +87,9 @@ namespace UniformMaterialManagementSystem.ViewModels
                 Password = PasswordHashing.GenerateSaltedHash(Password, salt),
                 UserName = UserName,
                 LoginName = UserName,
-                CompanyGuid = SelectedCompany.Guid,
+                CompanyGuid = SelectedCompany?.Guid,
                 Company = SelectedCompany,
-                CompanyName = SelectedCompany.Name,
+                CompanyName = SelectedCompany?.Name,
                 IsEnabled = true,
                 RegisterDate = DateTime.Now,
                 Roles = [_roles[SelectedUnitType]],