diff --git a/App.config b/App.config index 8324aa6..3138ac4 100644 --- a/App.config +++ b/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/ViewModel/StuffViewModel.cs b/ViewModel/StuffViewModel.cs new file mode 100644 index 0000000..474374b --- /dev/null +++ b/ViewModel/StuffViewModel.cs @@ -0,0 +1,63 @@ +using formula_manage.SQLModels; +using formula_manage.Windows; +using GalaSoft.MvvmLight; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Threading; + +namespace formula_manage.ViewModel +{ + /// + /// StuffViewModel + /// + public class StuffViewModel : ViewModelBase + { + private List products = new List(); + + /// + /// 所有原料 + /// + public List Product + { + get + { + return products; + } + set + { + products = value; + RaisePropertyChanged(); + } + } + + /// + /// StuffViewModeldl + /// + public StuffViewModel() + { + //products = new ProductProvider().Select(); + DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event + { + Interval = TimeSpan.FromSeconds(0.1) + }; + timer.Tick += Tick_Event; + timer.Start(); + } + + void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件 + { + if (Stuff.Button_sql == true)//获取按钮状态 + { + // if (Stuff.Buttontype_sql == -1) Product = new ProductProvider().Select(); + // if (Stuff.Buttontype_sql == 0) Product = new ProductProvider().Selects0(); + // if (Stuff.Buttontype_sql == 1) Product = new ProductProvider().Selects1(); + // if (Stuff.Buttontype_sql == 2) Product = new ProductProvider().Selects2(); + // if (Stuff.Buttontype_sql == 3) Product = new ProductProvider().Selects3(); + Stuff.Button_sql = false;//清除按钮状态 + } + } + } +} diff --git a/Windows/Stuff.xaml b/Windows/Stuff.xaml index c8d0a27..c501096 100644 --- a/Windows/Stuff.xaml +++ b/Windows/Stuff.xaml @@ -4,7 +4,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:formula_manage.Windows" - xmlns:ConvertMoels="clr-namespace:formula_manage.ConvertMoels" + xmlns:ConvertMoels="clr-namespace:formula_manage.ConvertMoels" + xmlns:viewmodel="clr-namespace:formula_manage.ViewModel" + DataContext="{Binding Source={StaticResource Locator},Path=Stuff}" mc:Ignorable="d" Title="Stuff" Height="720" Width="1100" BorderBrush="White" Background="#FFE0E0E0"> @@ -17,7 +19,8 @@ + BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" CanUserReorderColumns="False" + ItemsSource="{Binding Product, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> @@ -70,12 +73,12 @@ - - + + diff --git a/Windows/Stuff.xaml.cs b/Windows/Stuff.xaml.cs index 82c37af..fffbade 100644 --- a/Windows/Stuff.xaml.cs +++ b/Windows/Stuff.xaml.cs @@ -12,7 +12,8 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; - +using GalaSoft.MvvmLight; +using formula_manage.SQLModels; namespace formula_manage.Windows { @@ -24,10 +25,10 @@ namespace formula_manage.Windows public Stuff() { WindowStartupLocation = WindowStartupLocation.CenterScreen; + InitializeComponent(); this.DataGridStuff.LoadingRow += new EventHandler(this.DataGridEquipment_LoadingRow);//生成序列号 - InitializeComponent(); } /// @@ -38,9 +39,11 @@ namespace formula_manage.Windows e.Row.Header = e.Row.GetIndex() + 1; } + public static Boolean Button_sql = true; + public static int Buttontype_sql = -1; private void Radiobutton(object sender, EventArgs e) { - /* System.Windows.Controls.RadioButton Radiobutton = (sender as System.Windows.Controls.RadioButton); + System.Windows.Controls.RadioButton Radiobutton = (sender as System.Windows.Controls.RadioButton); string radiobutton = Radiobutton.Content.ToString(); if (radiobutton == "全部原料") Buttontype_sql = -1; if (radiobutton == "染料") Buttontype_sql = 0; @@ -48,7 +51,7 @@ namespace formula_manage.Windows if (radiobutton == "粉体助剂") Buttontype_sql = 2; if (radiobutton == "液体染料") Buttontype_sql = 3; Button_sql = true; - */ } + } private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件 { diff --git a/formula_manage.csproj b/formula_manage.csproj index 0ba3b3e..339b183 100644 --- a/formula_manage.csproj +++ b/formula_manage.csproj @@ -54,9 +54,21 @@ false + + packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll + packages\ModernUI.WPF.1.0.9\lib\net45\FirstFloor.ModernUI.dll + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + packages\SamOatesGames.ModernUI.Xceed.Toolkit.1.0.1905191936\lib\net45\ModernUI.Xceed.AvalonDock.dll @@ -67,6 +79,9 @@ + + packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + @@ -79,20 +94,20 @@ - - packages\Extended.Wpf.Toolkit.3.5.0\lib\net40\Xceed.Wpf.AvalonDock.dll + + packages\Extended.Wpf.Toolkit.4.5.1\lib\net40\Xceed.Wpf.AvalonDock.dll - - packages\Extended.Wpf.Toolkit.3.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll + + packages\Extended.Wpf.Toolkit.4.5.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll - - packages\Extended.Wpf.Toolkit.3.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll + + packages\Extended.Wpf.Toolkit.4.5.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll - - packages\Extended.Wpf.Toolkit.3.5.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll + + packages\Extended.Wpf.Toolkit.4.5.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll - - packages\Extended.Wpf.Toolkit.3.5.0\lib\net40\Xceed.Wpf.Toolkit.dll + + packages\Extended.Wpf.Toolkit.4.5.1\lib\net40\Xceed.Wpf.Toolkit.dll @@ -113,6 +128,7 @@ + Formula.xaml @@ -232,7 +248,6 @@ - \ No newline at end of file diff --git a/packages.config b/packages.config index 169215d..f7e5d14 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,8 @@  - + + + \ No newline at end of file