diff --git a/Models/ProductProvider.cs b/Models/ProductProvider.cs index ad90535..3c69ce4 100644 --- a/Models/ProductProvider.cs +++ b/Models/ProductProvider.cs @@ -9,7 +9,7 @@ namespace Models public class ProductProvider : IProvider { private readonly TicketEntities db = new TicketEntities(); - public int Delete(Product t) + public int Delete(Product t)//删除 { if (t == null) return 0; var model = db.Product.ToList().FirstOrDefault(item => t.ProductCode == item.ProductCode); @@ -19,7 +19,7 @@ namespace Models return count; } - public int Insert(Product t) + public int Insert(Product t)//插入 { if (t == null) return 0; if (String.IsNullOrEmpty(t.ProductCode)) return 0; @@ -33,6 +33,19 @@ namespace Models return db.Product.SqlQuery("select * from Product").ToList();//查询 } + public List Selects0() + { + return db.Product.SqlQuery("select * from Product where ProductType = 0").ToList();//查询 + } + + public List Selects1() + { + return db.Product.SqlQuery("select * from Product where ProductType = 1").ToList();//查询 + } + public List Selects2() + { + return db.Product.SqlQuery("select * from Product where ProductType = 2").ToList();//查询 + } public int Update(Product t) { throw new NotImplementedException(); diff --git a/View/StuffView.xaml b/View/StuffView.xaml index ab7be07..3a46f97 100644 --- a/View/StuffView.xaml +++ b/View/StuffView.xaml @@ -88,13 +88,13 @@ - - - - /// 公共变量数组实体 /// private Product product = new Product();//最终存入sql的实体 private Product product_temp = new Product();//取出自sql的实体缓存 public static Boolean Button_sql = false; + public static int Buttontype_sql = -1; + private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件 { diff --git a/ViewModel/StuffViewModel.cs b/ViewModel/StuffViewModel.cs index bbcc92a..ca2386d 100644 --- a/ViewModel/StuffViewModel.cs +++ b/ViewModel/StuffViewModel.cs @@ -43,8 +43,10 @@ namespace Audit.ViewModel public StuffViewModel() { products = new ProductProvider().Select(); - DispatcherTimer timer = new DispatcherTimer();//每0.5秒调用一次Tick_Event - timer.Interval = TimeSpan.FromSeconds(0.1); + DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event + { + Interval = TimeSpan.FromSeconds(0.1) + }; timer.Tick += Tick_Event; timer.Start(); } @@ -53,7 +55,10 @@ namespace Audit.ViewModel { if (StuffView.Button_sql == true)//获取按钮状态 { - Product = new ProductProvider().Select();//扫描数据库 + if (StuffView.Buttontype_sql == -1) Product = new ProductProvider().Select(); + if (StuffView.Buttontype_sql == 0) Product = new ProductProvider().Selects0(); + if (StuffView.Buttontype_sql == 1) Product = new ProductProvider().Selects1(); + if (StuffView.Buttontype_sql == 2) Product = new ProductProvider().Selects2(); StuffView.Button_sql = false;//清除按钮状态 } }