Pārlūkot izejas kodu

Реализовано цветовое различие в списке заказов

MeseryGG 7 mēneši atpakaļ
vecāks
revīzija
af9259c8db

+ 23 - 0
OOO_WriteAndClear/DBModels/OrderPartialClass.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
 
 namespace OOO_WriteAndClear.DBModels
 {
@@ -17,5 +18,27 @@ namespace OOO_WriteAndClear.DBModels
         public decimal OrderDiscount => OrderCostWithoutDiscount - OrderCost;
 
         public decimal OrderDiscountPercent => 1 - (OrderCost / OrderCostWithoutDiscount);
+
+        public SolidColorBrush OrderBackGround
+        {
+            get
+            {
+                SolidColorBrush brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#20b2aa");
+                foreach (var item in OrderProducts)
+                {
+                    if (item.ProductArticleNumberNavigation.ProductQuantityInStock == 0)
+                    {
+                        brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#ff8c00");
+                        break;
+                    }
+                    if (item.ProductArticleNumberNavigation.ProductQuantityInStock <= 3)
+                    {
+                        brush = (SolidColorBrush)new BrushConverter().ConvertFrom("#ffffff");
+                        break;
+                    }
+                }
+                return brush;
+            }
+        }
     }
 }

+ 1 - 0
OOO_WriteAndClear/MVP/Views/OrdersUserControl.xaml

@@ -37,6 +37,7 @@
                 <Setter.Value>
                     <DataTemplate DataType="db_models:Order">
                         <Border Padding="10"
+                                Background="{Binding OrderBackGround}"
                                 BorderThickness="1" BorderBrush="Black"
                                 CornerRadius="10">
                             <Grid HorizontalAlignment="Stretch">