diff --git a/.vs/SubCabinetSolution/v17/.suo b/.vs/SubCabinetSolution/v17/.suo index a0bac4c..0898120 100644 --- a/.vs/SubCabinetSolution/v17/.suo +++ b/.vs/SubCabinetSolution/v17/.suo Binary files differ diff --git a/.vs/SubCabinetSolution/v17/.suo b/.vs/SubCabinetSolution/v17/.suo index a0bac4c..0898120 100644 --- a/.vs/SubCabinetSolution/v17/.suo +++ b/.vs/SubCabinetSolution/v17/.suo Binary files differ diff --git a/SubCabinetSolution/ViewModel/CabinetViewModel.cs b/SubCabinetSolution/ViewModel/CabinetViewModel.cs index 5ce8b04..b83489c 100644 --- a/SubCabinetSolution/ViewModel/CabinetViewModel.cs +++ b/SubCabinetSolution/ViewModel/CabinetViewModel.cs @@ -50,6 +50,18 @@ } private string _mainTopImage; + public string UserInputKeywords + { + get { return _inputKeywords; } + set + { + _inputKeywords = value; + RaisePropertyChanged(() => UserInputKeywords); + } + } + private string _inputKeywords; + public RelayCommand SearchDataCommand { get; set; } + public CabinetViewModel() { DispatcherTimer showTimer = new DispatcherTimer(); @@ -78,6 +90,11 @@ new FunctionModel("/Images/近消耗品.png", "近消耗品") }; this.FuncSelectedCommand = new RelayCommand(ItemSelectionChanged); + this.SearchDataCommand = new RelayCommand(SearchData); + // 设置默认值 + this.MainTopImage = FunctionModelList[7].Image; + this.MainTopTitle = FunctionModelList[7].Title; + // TODO 显示默认功能项数据 } private void ShowCurTimer(object sender, EventArgs e) @@ -106,5 +123,13 @@ this.MainTopImage = functionModel.Image; this.MainTopTitle = functionModel.Title; } + + private void SearchData() + { + if (!string.IsNullOrWhiteSpace(_inputKeywords)) return; + MessageBox.Show("请输入关键字", "错误", MessageBoxButton.OK, MessageBoxImage.Error); + return; + // TODO 搜索数据库 + } } } \ No newline at end of file diff --git a/.vs/SubCabinetSolution/v17/.suo b/.vs/SubCabinetSolution/v17/.suo index a0bac4c..0898120 100644 --- a/.vs/SubCabinetSolution/v17/.suo +++ b/.vs/SubCabinetSolution/v17/.suo Binary files differ diff --git a/SubCabinetSolution/ViewModel/CabinetViewModel.cs b/SubCabinetSolution/ViewModel/CabinetViewModel.cs index 5ce8b04..b83489c 100644 --- a/SubCabinetSolution/ViewModel/CabinetViewModel.cs +++ b/SubCabinetSolution/ViewModel/CabinetViewModel.cs @@ -50,6 +50,18 @@ } private string _mainTopImage; + public string UserInputKeywords + { + get { return _inputKeywords; } + set + { + _inputKeywords = value; + RaisePropertyChanged(() => UserInputKeywords); + } + } + private string _inputKeywords; + public RelayCommand SearchDataCommand { get; set; } + public CabinetViewModel() { DispatcherTimer showTimer = new DispatcherTimer(); @@ -78,6 +90,11 @@ new FunctionModel("/Images/近消耗品.png", "近消耗品") }; this.FuncSelectedCommand = new RelayCommand(ItemSelectionChanged); + this.SearchDataCommand = new RelayCommand(SearchData); + // 设置默认值 + this.MainTopImage = FunctionModelList[7].Image; + this.MainTopTitle = FunctionModelList[7].Title; + // TODO 显示默认功能项数据 } private void ShowCurTimer(object sender, EventArgs e) @@ -106,5 +123,13 @@ this.MainTopImage = functionModel.Image; this.MainTopTitle = functionModel.Title; } + + private void SearchData() + { + if (!string.IsNullOrWhiteSpace(_inputKeywords)) return; + MessageBox.Show("请输入关键字", "错误", MessageBoxButton.OK, MessageBoxImage.Error); + return; + // TODO 搜索数据库 + } } } \ No newline at end of file diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs index fd3b7f9..dc5346e 100644 --- a/SubCabinetSolution/ViewModel/MainViewModel.cs +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -1,10 +1,10 @@ +using System.Data; +using System.Windows; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using MySql.Data.MySqlClient; using SubCabinetSolution.Utils; using SubCabinetSolution.Views; -using System.Data; -using System.Windows; namespace SubCabinetSolution.ViewModel { @@ -13,30 +13,30 @@ /* * TextBlock双向绑定 */ - public string userName; + public string _userName; /* * PasswordBox双向绑定 */ - public string userPassword; + public string _userPassword; public string UserName { - get { return userName; } + get { return _userName; } set { - userName = value; - RaisePropertyChanged(); + _userName = value; + RaisePropertyChanged(() => UserName); } } public string UserPassword { - get { return userPassword; } + get { return _userPassword; } set { - userPassword = value; - RaisePropertyChanged(); + _userPassword = value; + RaisePropertyChanged(() => UserPassword); } } @@ -57,13 +57,13 @@ private void Login(MainWindow window) { - if (string.IsNullOrWhiteSpace(userName)) + if (string.IsNullOrWhiteSpace(_userName)) { MessageBox.Show("请输入用户名", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return; } - if (string.IsNullOrWhiteSpace(userPassword)) + if (string.IsNullOrWhiteSpace(_userPassword)) { MessageBox.Show("请输入密码", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return; @@ -85,7 +85,7 @@ string account = reader.GetString("ACCOUNT"); string secretKey = reader.GetString("PASSWORD"); //被加盐之后的密码 // TODO 解码得到密码 - if (account != userName || secretKey != userPassword) continue; + if (account != _userName || secretKey != _userPassword) continue; reader.Close(); CabinetWindow cabinetWindow = new CabinetWindow(); cabinetWindow.Show(); diff --git a/.vs/SubCabinetSolution/v17/.suo b/.vs/SubCabinetSolution/v17/.suo index a0bac4c..0898120 100644 --- a/.vs/SubCabinetSolution/v17/.suo +++ b/.vs/SubCabinetSolution/v17/.suo Binary files differ diff --git a/SubCabinetSolution/ViewModel/CabinetViewModel.cs b/SubCabinetSolution/ViewModel/CabinetViewModel.cs index 5ce8b04..b83489c 100644 --- a/SubCabinetSolution/ViewModel/CabinetViewModel.cs +++ b/SubCabinetSolution/ViewModel/CabinetViewModel.cs @@ -50,6 +50,18 @@ } private string _mainTopImage; + public string UserInputKeywords + { + get { return _inputKeywords; } + set + { + _inputKeywords = value; + RaisePropertyChanged(() => UserInputKeywords); + } + } + private string _inputKeywords; + public RelayCommand SearchDataCommand { get; set; } + public CabinetViewModel() { DispatcherTimer showTimer = new DispatcherTimer(); @@ -78,6 +90,11 @@ new FunctionModel("/Images/近消耗品.png", "近消耗品") }; this.FuncSelectedCommand = new RelayCommand(ItemSelectionChanged); + this.SearchDataCommand = new RelayCommand(SearchData); + // 设置默认值 + this.MainTopImage = FunctionModelList[7].Image; + this.MainTopTitle = FunctionModelList[7].Title; + // TODO 显示默认功能项数据 } private void ShowCurTimer(object sender, EventArgs e) @@ -106,5 +123,13 @@ this.MainTopImage = functionModel.Image; this.MainTopTitle = functionModel.Title; } + + private void SearchData() + { + if (!string.IsNullOrWhiteSpace(_inputKeywords)) return; + MessageBox.Show("请输入关键字", "错误", MessageBoxButton.OK, MessageBoxImage.Error); + return; + // TODO 搜索数据库 + } } } \ No newline at end of file diff --git a/SubCabinetSolution/ViewModel/MainViewModel.cs b/SubCabinetSolution/ViewModel/MainViewModel.cs index fd3b7f9..dc5346e 100644 --- a/SubCabinetSolution/ViewModel/MainViewModel.cs +++ b/SubCabinetSolution/ViewModel/MainViewModel.cs @@ -1,10 +1,10 @@ +using System.Data; +using System.Windows; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using MySql.Data.MySqlClient; using SubCabinetSolution.Utils; using SubCabinetSolution.Views; -using System.Data; -using System.Windows; namespace SubCabinetSolution.ViewModel { @@ -13,30 +13,30 @@ /* * TextBlock双向绑定 */ - public string userName; + public string _userName; /* * PasswordBox双向绑定 */ - public string userPassword; + public string _userPassword; public string UserName { - get { return userName; } + get { return _userName; } set { - userName = value; - RaisePropertyChanged(); + _userName = value; + RaisePropertyChanged(() => UserName); } } public string UserPassword { - get { return userPassword; } + get { return _userPassword; } set { - userPassword = value; - RaisePropertyChanged(); + _userPassword = value; + RaisePropertyChanged(() => UserPassword); } } @@ -57,13 +57,13 @@ private void Login(MainWindow window) { - if (string.IsNullOrWhiteSpace(userName)) + if (string.IsNullOrWhiteSpace(_userName)) { MessageBox.Show("请输入用户名", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return; } - if (string.IsNullOrWhiteSpace(userPassword)) + if (string.IsNullOrWhiteSpace(_userPassword)) { MessageBox.Show("请输入密码", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return; @@ -85,7 +85,7 @@ string account = reader.GetString("ACCOUNT"); string secretKey = reader.GetString("PASSWORD"); //被加盐之后的密码 // TODO 解码得到密码 - if (account != userName || secretKey != userPassword) continue; + if (account != _userName || secretKey != _userPassword) continue; reader.Close(); CabinetWindow cabinetWindow = new CabinetWindow(); cabinetWindow.Show(); diff --git a/SubCabinetSolution/Views/CabinetWindow.xaml b/SubCabinetSolution/Views/CabinetWindow.xaml index 7051f8d..377df80 100644 --- a/SubCabinetSolution/Views/CabinetWindow.xaml +++ b/SubCabinetSolution/Views/CabinetWindow.xaml @@ -92,7 +92,8 @@ HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0" - ItemsSource="{Binding FunctionModelList}"> + ItemsSource="{Binding FunctionModelList}" + SelectedIndex="7"> @@ -278,7 +279,8 @@ Width="300" Height="30" Padding="3,0" - VerticalContentAlignment="Center"> + VerticalContentAlignment="Center" + Text="{Binding UserInputKeywords}"> -