Przeglądaj źródła

Обновить 'help'

1 zmienionych plików z 226 dodań i 0 usunięć
  1. 226 0
      help

+ 226 - 0
help

@@ -198,3 +198,229 @@ public static List<Product> products = new List<Product>();
                 </DataTemplate>
             </ListView.ItemTemplate>
         </ListView>    
+// частичный класс 
+               public partial class Order
+    {
+        public string FullName
+        {
+            get
+            {
+                return User.UserSurname + " " + User.UserName + " " + User.UserPatronymic;
+            }
+        }
+                
+        public string OrderComposition
+        {
+            get
+            {
+                string str = "Состав заказа: ";
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct prod in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == prod.ProductArticleNumber);
+                    str += product.ProductName + " (" + product.ProductArticleNumber + "), ";
+                }
+                str = str.Substring(0, str.Length - 2);
+                return str;
+            }
+        }
+
+        public string OrderAmountPrint
+        {
+            get
+            {
+                double resultCost = 0;
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct prod in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == prod.ProductArticleNumber);
+                    resultCost += product.CostOrder;
+                }
+                return "Стоимость заказа: " + resultCost;
+            }
+        }
+
+        public double OrderAmount
+        {
+            get
+            {
+                double resultCost = 0;
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct orderProduct in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == orderProduct.ProductArticleNumber);
+                    resultCost += product.CostOrder;
+                }
+                return resultCost;
+            }
+        }
+
+        public string DiscountOrderPrint
+        {
+            get
+            {
+                double discount = 0;
+                double withoutDiscount = 0;
+                double newAmount = 0;
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct prod in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == prod.ProductArticleNumber);
+                    withoutDiscount += (double)product.ProductCost;
+                    newAmount += product.CostOrder;
+                }
+                discount = 100 - 100 * newAmount / withoutDiscount;
+                return "Общая скидка: " + discount + "%";
+            }
+        }
+
+        public double DiscountOrder
+        {
+            get
+            {
+                double discount = 0;
+                double withoutDiscount = 0;
+                double newAmount = 0;
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct prod in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == prod.ProductArticleNumber);
+                    withoutDiscount += (double)product.ProductCost;
+                    newAmount += product.CostOrder;
+                }
+                discount = 100 - 100 * newAmount / withoutDiscount;
+                return discount;
+            }
+        }
+
+        public SolidColorBrush ColorOrder
+        {
+            get
+            {
+                bool moreThree = false;
+                bool zero = false;
+                List<OrderProduct> orderProducts = ClassDBase.DB.OrderProduct.Where(x => x.OrderID == OrderID).ToList();
+                foreach (OrderProduct prod in orderProducts)
+                {
+                    Product product = ClassDBase.DB.Product.FirstOrDefault(z => z.ProductArticleNumber == prod.ProductArticleNumber);
+                    if (product.ProductQuantityInStock > 3)
+                    {
+                        moreThree = true;
+                    }
+                    else
+                    {
+                        moreThree = false;
+                        if (product.ProductQuantityInStock == 0)
+                        {
+                            moreThree = false;
+                            zero = true;
+                            goto met;
+                        }
+                    }
+                }
+            met: if (moreThree == true)
+                {
+                    return (SolidColorBrush)new BrushConverter().ConvertFrom("#20b2aa");
+                }
+                else if (zero == true)
+                {
+                    return (SolidColorBrush)new BrushConverter().ConvertFrom("#ff8c00");
+                }
+                else
+                {
+                    return Brushes.White;
+                }
+            }
+        }
+    }
+              
+// и еще один
+              public partial class Product
+    {
+        public SolidColorBrush Brush
+        {
+            get
+            {
+                var brushConverter = new BrushConverter();
+
+                if (ProductDiscountAmount < 15 || ProductDiscountAmount == null)
+                {
+                    return Brushes.White;
+                }
+                else
+                {
+                    return (SolidColorBrush)(Brush)brushConverter.ConvertFrom("#7fff00");
+
+                }
+
+            }
+        }
+        public string Price
+        {
+            get
+            {
+                if (ProductDiscountAmount != null)
+                {
+                    double b = (Convert.ToDouble(ProductCost) / 100) * (100 - ProductDiscountAmount.Value);                   
+                    return b + "";
+                }
+                else
+                {
+                    double a = Convert.ToDouble(ProductCost);                   
+                    return a + "";
+                }
+            }
+        }
+        public string Cost
+
+        {
+            get
+            {
+                if (ProductDiscountAmount != null)
+                {
+                   
+                    return Math.Round(Convert.ToDouble(ProductCost)) + " ";
+                }
+                return "";
+
+            }
+        }
+        public double PriceOrder
+        {
+            get
+            {
+                if (ProductDiscountAmount != null)
+                {
+                    double b = (Convert.ToDouble(ProductCost) / 100) * (100 - ProductDiscountAmount.Value);
+                    return b;
+                }
+                else
+                {
+                    double a = Convert.ToDouble(ProductCost);
+                    return a;
+                }
+            }
+        }
+        public double CostOrder
+
+        {
+            get
+            {
+                if (ProductDiscountAmount != null)
+                {
+
+                    return Math.Round(Convert.ToDouble(ProductCost));
+                }
+
+                return 0;
+            }
+        }
+
+        public string Discount
+        {
+            get
+            {
+                return ProductDiscountAmount + "%";
+            }
+        }
+    }