diff --git a/Powork/Repository/MemoRepository.cs b/Powork/Repository/MemoRepository.cs index 963b6d9..e6bb184 100644 --- a/Powork/Repository/MemoRepository.cs +++ b/Powork/Repository/MemoRepository.cs @@ -23,11 +23,11 @@ public static string SelectMemo(string date) return string.Empty; } - public static string SelectPreviousMemoDate(string date) + public static string SelectPreviousMemoDate(string date, string search) { SQLiteConnection connection = CommonRepository.GetConnection(); - string sql = $"SELECT * FROM TMemo WHERE date < '{date}' AND memo IS NOT NULL AND memo <> '' ORDER BY date DESC LIMIT 1"; + string sql = $"SELECT * FROM TMemo WHERE date < '{date}' AND memo IS NOT NULL AND memo <> '' AND memo LIKE '%{search}%' ORDER BY date DESC LIMIT 1"; using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { @@ -42,11 +42,11 @@ public static string SelectPreviousMemoDate(string date) return null; } - public static string SelectNextMemoDate(string date) + public static string SelectNextMemoDate(string date, string search) { SQLiteConnection connection = CommonRepository.GetConnection(); - string sql = $"SELECT * FROM TMemo WHERE date > '{date}' AND memo IS NOT NULL AND memo <> '' ORDER BY date ASC LIMIT 1"; + string sql = $"SELECT * FROM TMemo WHERE date > '{date}' AND memo IS NOT NULL AND memo <> '' AND memo LIKE '%{search}%' ORDER BY date ASC LIMIT 1"; using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { diff --git a/Powork/View/MainWindow.xaml b/Powork/View/MainWindow.xaml index d8d1120..c65416e 100644 --- a/Powork/View/MainWindow.xaml +++ b/Powork/View/MainWindow.xaml @@ -173,7 +173,7 @@ - + diff --git a/Powork/View/MemoPage.xaml b/Powork/View/MemoPage.xaml index 92962b4..22f1a83 100644 --- a/Powork/View/MemoPage.xaml +++ b/Powork/View/MemoPage.xaml @@ -37,6 +37,7 @@ + @@ -50,26 +51,27 @@ - - - - - - - - diff --git a/Powork/ViewModel/MemoPageViewModel.cs b/Powork/ViewModel/MemoPageViewModel.cs index 61980bc..b897ea2 100644 --- a/Powork/ViewModel/MemoPageViewModel.cs +++ b/Powork/ViewModel/MemoPageViewModel.cs @@ -31,6 +31,12 @@ public string Date } } } + private string _search; + public string Search + { + get => _search; + set => SetProperty(ref _search, value); + } private string _memo; public string Memo { @@ -179,7 +185,7 @@ private void PreviousMemo() { if (DateTime.TryParse(Date, out DateTime dateTime)) { - string date = MemoRepository.SelectPreviousMemoDate(dateTime.ToString(Format.DateTimeFormat)); + string date = MemoRepository.SelectPreviousMemoDate(dateTime.ToString(Format.DateTimeFormat), Search); if (date != null) { Date = date; @@ -191,7 +197,7 @@ private void NextMemo() { if (DateTime.TryParse(Date, out DateTime dateTime)) { - string date = MemoRepository.SelectNextMemoDate(dateTime.ToString(Format.DateTimeFormat)); + string date = MemoRepository.SelectNextMemoDate(dateTime.ToString(Format.DateTimeFormat), Search); if (date != null) { Date = date;