Browse Source

Made it so that the user cannot save bills with empty numbers or suppliers.

Kenric Nugteren 1 năm trước cách đây
mục cha
commit
9fa25ba1c9
1 tập tin đã thay đổi với 14 bổ sung0 xóa
  1. 14 0
      prs.desktop/Panels/Suppliers/Bills/SupplierBills.cs

+ 14 - 0
prs.desktop/Panels/Suppliers/Bills/SupplierBills.cs

@@ -128,5 +128,19 @@ namespace PRSDesktop
         {
             return LoadItems(rows);
         }
+
+        protected override void DoValidate(Bill[] items, List<string> errors)
+        {
+            base.DoValidate(items, errors);
+
+            if(items.Any(x => x.Number.IsNullOrWhiteSpace()))
+            {
+                errors.Add($"[{nameof(Bill.Number)}] may not be blank!");
+            }
+            if(items.Any(x => x.SupplierLink.ID == Guid.Empty))
+            {
+                errors.Add($"[{nameof(Bill.SupplierLink)}] may not be blank!");
+            }
+        }
     }
 }