예제 #1
0
 private async void Save_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(Title_TextBox.Text))
     {
         var dialog = new ContentDialog
         {
             Title             = "请输入标题",
             PrimaryButtonText = "确定"
         };
         await dialog.ShowAsync();
     }
     else
     {
         using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
         {
             var AddMemo = new Memo();
             AddMemo.Title     = Title_TextBox.Text;
             AddMemo.Memo_Date = Calendar_TextBlock.Text;
             AddMemo.Body      = Content_TextBox.Text;
             conn.Insert(AddMemo);
             shrOpration?.ReportCompleted();
             if (Frame.CanGoBack)
             {
                 Frame.GoBack();
             }
         }
     }
 }
예제 #2
0
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(Title_TextBox.Text))
            {
                var dialog = new ContentDialog
                {
                    Title             = "请输入标题",
                    PrimaryButtonText = "确定"
                };
                await dialog.ShowAsync();
            }
            else
            {
                using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
                {
                    conn.Execute("update Memo set Title = ?, Memo_Date = ?,Body = ? where Title= ?", Title_TextBox.Text, Calendar_TextBlock.Text, Content_TextBox.Text, Receive_Title);
                }
                var dialog = new ContentDialog
                {
                    Content = "更新成功",

                    IsPrimaryButtonEnabled = true
                };
                dialog.ShowAsync();

                await Task.Delay(1000);

                dialog.Hide();
                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
            }
        }
예제 #3
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
     {
         conn.Execute("delete from Memo where Title = ?", Receive_Title);
     }
     if (Frame.CanGoBack)
     {
         Frame.GoBack();
     }
 }
예제 #4
0
        public AddPage()
        {
            this.InitializeComponent();
            using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
            {
                List <Memo>   Memolist = conn.Query <Memo>("select * from Memo");
                List <string> r        = new List <string>();
                foreach (var items in Memolist)
                {
                    r.Add(items.Title);
                }

                Searchbox.ItemsSource = r;
            }
        }
예제 #5
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     Receive_Title      = e.Parameter.ToString();
     Title_TextBox.Text = e.Parameter.ToString();
     using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
     {
         List <Memo> Memolist = conn.Query <Memo>("select * from Memo where Title = ?", e.Parameter.ToString());
         foreach (var items in Memolist)
         {
             Calendar_TextBlock.Text = items.Memo_Date;
             Content_TextBox.Text    = items.Body;
         }
     }
 }
예제 #6
0
        public MainPage()
        {
            this.InitializeComponent();
            using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
            {
                List <Memo>   Memolist = conn.Query <Memo>("select * from Memo order by Number desc");
                List <string> r        = new List <string>();
                foreach (var items in Memolist)
                {
                    Memo_List.Items.Add(items.Title);

                    r.Add(items.Title);
                    Memo_List.SelectionMode = SelectionMode.Single;
                }

                Searchbox.ItemsSource = r;
            }
        }
예제 #7
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            using (var conn = ConnectMemoDatabase.GetMemoDbConnect())
            {
                if (Memo_List.SelectedIndex == -1)
                {
                    var dialog = new ContentDialog
                    {
                        Title             = "未选中日记",
                        PrimaryButtonText = "确定"
                    };
                    await dialog.ShowAsync();
                }
                else
                {
                    string xxx = Memo_List.SelectedIndex.ToString();
                    string xx  = Memo_List.SelectedValue.ToString();
                    for (int i = Memo_List.SelectedItems.Count - 1; i >= 0; i--)
                    {
                        Memo_List.Items.Remove(Memo_List.SelectedItems[i]);
                    }
                    var msg    = String.Format("第{0}行已被删除", int.Parse(xxx) + 1);
                    var dialog = new ContentDialog
                    {
                        Title   = "提示",
                        Content = msg,
                        IsPrimaryButtonEnabled = true
                    };
                    dialog.ShowAsync();

                    await Task.Delay(1000);

                    dialog.Hide();
                    conn.Execute("delete from Memo where Title = ?", xx);
                }
            }
        }