|
@@ -28,19 +28,36 @@ namespace WPF01.pages
|
|
|
|
|
|
database = new db2.Test02Entities();
|
|
database = new db2.Test02Entities();
|
|
|
|
|
|
- LoadProduct();
|
|
|
|
|
|
+ LoadProduct("");
|
|
}
|
|
}
|
|
|
|
|
|
- void LoadProduct()
|
|
|
|
|
|
+ void LoadProduct(string search)
|
|
{
|
|
{
|
|
- var products = database.Product.ToList();
|
|
|
|
|
|
+ List<db2.Product> products;
|
|
|
|
+
|
|
|
|
+ if (search.Length == 0)
|
|
|
|
+ {
|
|
|
|
+ products = database.Product.ToList();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ products = database.Product.Where(p => p.Title.IndexOf(search) > -1).ToList();
|
|
|
|
+ }
|
|
|
|
|
|
int productCouter = 0;
|
|
int productCouter = 0;
|
|
|
|
|
|
|
|
+ ProductGrid.Children.Clear();
|
|
|
|
+
|
|
for (int i = 0; i < 2; i++)
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
{
|
|
for (int j = 0; j < 3; j++) {
|
|
for (int j = 0; j < 3; j++) {
|
|
|
|
|
|
|
|
+ // 5 < 4
|
|
|
|
+ if ((products.Count - 1) < productCouter)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
Border border = new Border();
|
|
Border border = new Border();
|
|
border.BorderBrush = Brushes.Gray;
|
|
border.BorderBrush = Brushes.Gray;
|
|
border.BorderThickness = new Thickness(1);
|
|
border.BorderThickness = new Thickness(1);
|
|
@@ -58,6 +75,13 @@ namespace WPF01.pages
|
|
//< Image Source = "/WPF01;component/Товары автосервиса/E9308929.jpg" Height = "129" Margin = "20,10,20,0" />
|
|
//< Image Source = "/WPF01;component/Товары автосервиса/E9308929.jpg" Height = "129" Margin = "20,10,20,0" />
|
|
|
|
|
|
Image image = new Image();
|
|
Image image = new Image();
|
|
|
|
+
|
|
|
|
+ BitmapImage bitmapImage = new BitmapImage();
|
|
|
|
+ bitmapImage.BeginInit();
|
|
|
|
+ bitmapImage.UriSource = new Uri("pack://application:,,,/" + products[productCouter].MainImagePath);
|
|
|
|
+ bitmapImage.EndInit();
|
|
|
|
+
|
|
|
|
+ image.Source = bitmapImage;
|
|
image.Height = 130;
|
|
image.Height = 130;
|
|
|
|
|
|
stackPanel.Children.Add(image);
|
|
stackPanel.Children.Add(image);
|
|
@@ -90,5 +114,10 @@ namespace WPF01.pages
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void TextBox_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ LoadProduct(Search.Text);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|