Esempio n. 1
0
        private void CreateButton_Clicked(object sender, RoutedEventArgs e)
        {
            bool judge = this.datetime.Date < DateTime.Today;

            if (title.Text != "" && details.Text != "" && !judge)
            {
                if (createButton.Content.ToString() == "Create")
                {
                    var n = new MessageDialog("Congratulations! You have created a new item successfully!").ShowAsync();
                    ViewModel.AddTodoItem(title.Text, image.Source, details.Text, datetime.Date.DateTime);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                }
                if (createButton.Content.ToString() == "Update")
                {
                    var n = new MessageDialog("Congratulations! You have updated a new item successfully!").ShowAsync();
                    ViewModel.UpdateTodoItem(ViewModel.SelectedItem.GetId(), title.Text, details.Text, image.Source, datetime.Date.DateTime);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                    ViewModel.SelectedItem = null;
                }
            }
            else if (judge)
            {
                var n = new MessageDialog("You can't enter the date before!").ShowAsync();
            }
            else
            {
                var n = new MessageDialog("Something has not finished above!").ShowAsync();
            }
        }
Esempio n. 2
0
        private void CreateButton_Clicked(object sender, RoutedEventArgs e)
        {
            bool judge = this.datetime.Date < DateTime.Today;

            if (title.Text != "" && details.Text != "" && !judge)
            {
                if (createButton.Content.ToString() == "Create")
                {
                    var db = App.conn;
                    using (var item = db.Prepare("INSERT INTO Items (title, details, datetime) VALUES(?, ?, ?)"))
                    {
                        item.Bind(1, title.Text);
                        item.Bind(2, details.Text);
                        item.Step();
                    }
                    var n = new MessageDialog("Congratulations! You have created a new item successfully!").ShowAsync();
                    ViewModel.AddTodoItem(title.Text, image.Source, details.Text, datetime.Date.DateTime);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                }
                if (createButton.Content.ToString() == "Update")
                {
                    var db = App.conn;
                    using (var item = db.Prepare("UPDATE Items SET title = ?, details = ?, datetime = ? WHERE id = ?"))
                    {
                        item.Bind(1, title.Text);
                        item.Bind(2, details.Text);
                        item.Bind(3, datetime.Date.ToString("yyyy/MM/dd hh:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        item.Bind(4, GetTodoitemId());
                        item.Step();
                    }
                    var n = new MessageDialog("Congratulations! You have updated a new item successfully!").ShowAsync();
                    ViewModel.UpdateTodoItem(ViewModel.SelectedItem.GetId(), title.Text, details.Text, image.Source, datetime.Date.DateTime);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                    ViewModel.SelectedItem = null;
                }
            }
            else if (judge)
            {
                var n = new MessageDialog("You can't enter the date before!").ShowAsync();
            }
            else
            {
                var n = new MessageDialog("Something has not finished above!").ShowAsync();
            }
        }