Преглед на файлове

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

MeseryGG преди 7 месеца
родител
ревизия
af9259c8db
променени са 2 файла, в които са добавени 24 реда и са изтрити 0 реда
  1. 23 0
      OOO_WriteAndClear/DBModels/OrderPartialClass.cs
  2. 1 0
      OOO_WriteAndClear/MVP/Views/OrdersUserControl.xaml

+ 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">