1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace GGwp
- {
- /// <summary>
- /// Логика взаимодействия для Cart.xaml
- /// </summary>
- public partial class Cart : Window
- {
- TradePrytovEntities DB = new TradePrytovEntities();
- public static List<Product> Products = new List<Product>();
- public static List<AmountProduct> AmountProduct = new List<AmountProduct>();
- public Cart()
- {
- InitializeComponent();
- CartList.ItemsSource = Products;
- }
- public Cart(int id)
- {
- InitializeComponent();
- CartList.ItemsSource = Products;
- }
- private void CostCalculate(object sender, RoutedEventArgs e)
- {
- TextBlock tb = (TextBlock)sender;
- string Article = tb.Uid.ToString();
- Product pr = DB.Product.Where(x => x.ProductArticleNumber == Article).FirstOrDefault();
- if (pr.ProductMaxDiscountAmount > 0)
- {
- tb.Text = "Цена: " + string.Format("{0:C2}", (pr.ProductCost - (pr.ProductCost / 100 * pr.ProductMaxDiscountAmount)));
- }
- }
- private void Photo(object sender, RoutedEventArgs e)
- {
- Image pic = (Image)sender;
- string Article = pic.Uid.ToString();
- string photoPath = DB.Product.Where(x => x.ProductArticleNumber == Article).Select(x => x.ProductPhoto).FirstOrDefault();
- if (photoPath != null && photoPath != "")
- {
- pic.Source = new BitmapImage(new Uri(Environment.CurrentDirectory + "\\Pictures\\" + photoPath, UriKind.RelativeOrAbsolute));
- }
- else
- {
- pic.Source = new BitmapImage(new Uri(Environment.CurrentDirectory + "\\Pictures\\picture.png", UriKind.RelativeOrAbsolute));
- }
- }
- private void AmountCalculate(object sender, RoutedEventArgs e)
- {
- TextBlock tb = (TextBlock)sender;
- string Article = tb.Uid.ToString();
- Product pr = Products.Where(x => x.ProductArticleNumber == Article).FirstOrDefault();
- int index = Products.IndexOf(pr);
- tb.Text = AmountProduct[index].Amount.ToString();
- }
- }
- }
|