diff --git a/Models/ProductProvider.cs b/Models/ProductProvider.cs index 65523ae..0429e25 100644 --- a/Models/ProductProvider.cs +++ b/Models/ProductProvider.cs @@ -8,19 +8,29 @@ namespace Models { public class ProductProvider : IProvider { + private readonly TicketEntities db = new TicketEntities(); public int Delete(Product t) { - throw new NotImplementedException(); + if (t == null) return 0; + var model = db.Product.ToList().FirstOrDefault(item => t.ProductCode == item.ProductCode); + if (model == null) return 0; + db.Product.Remove(model); + int count = db.SaveChanges(); + return count; } public int Insert(Product t) { - throw new NotImplementedException(); + if (t == null) return 0; + if (String.IsNullOrEmpty(t.ProductCode)) return 0; + db.Product.Add(t); + int count = db.SaveChanges(); + return count; } public List Select() { - throw new NotImplementedException(); + return db.Product.SqlQuery("select * from Product").ToList();//查询 } public int Update(Product t) diff --git a/View/QueryView.xaml.cs b/View/QueryView.xaml.cs index c9a5cdb..09b148e 100644 --- a/View/QueryView.xaml.cs +++ b/View/QueryView.xaml.cs @@ -85,5 +85,6 @@ namespace Audit.View } } + } } diff --git a/View/StuffView.xaml b/View/StuffView.xaml index 278dca3..a37a0f3 100644 --- a/View/StuffView.xaml +++ b/View/StuffView.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Audit.View" - mc:Ignorable="d" DataContext="{Binding Source={StaticResource Locator},Path=Statistics}" + mc:Ignorable="d" DataContext="{Binding Source={StaticResource Locator},Path=Stuff}" d:DesignHeight="900" d:DesignWidth="1140" xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"> @@ -60,11 +60,65 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +