Exemple #1
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            if (name.Text == "" || name.Text.Trim() == string.Empty || num.Text == "" || num.Text.Trim() == string.Empty)
            {
                var n = new MessageDialog("信息输入有误!").ShowAsync();
            }
            else
            {
                ViewModel.AddTel(name.Text, num.Text, group.Text, image.Source);
                Frame.Navigate(typeof(ContactsPage), ViewModel);
                if (ViewModel.SelectTel != null)
                {
                    ViewModel.Remove();
                }
                ViewModel.SelectTel = null;

                var db = App.conn;
                using (var item = db.Prepare("INSERT INTO Tels (Name, Number, Group_By, head) VALUES(?, ?, ?, ?)"))
                {
                    item.Bind(1, name.Text);
                    item.Bind(2, num.Text);
                    item.Bind(3, group.Text);
                    string temp = "ms-appx://Todos/Assets/" + filename;
                    item.Bind(4, temp);
                    item.Step();
                }
                var n = new MessageDialog("信息已经成功保存至通讯录!").ShowAsync();
            }
        }
Exemple #2
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            if (name.Text == "" || name.Text.Trim() == string.Empty || num.Text == "" || num.Text.Trim() == string.Empty)
            {
                var n = new MessageDialog("信息输入有误!").ShowAsync();
            }
            else
            {
                ViewModel.AddTel(name.Text, num.Text, group.Text, image.Source);
                Frame.Navigate(typeof(ContactsPage), ViewModel);
                if (ViewModel.SelectTel != null)
                {
                    ViewModel.Remove();
                }
                ViewModel.SelectTel = null;

                var db = App.conn;

                string q = "%" + name.Text + "%";
                using (var statement = db.Prepare("SELECT Name, head FROM Tels WHERE Name LIKE ?"))
                {
                    statement.Bind(1, q);
                    if (statement.Step() != SQLiteResult.DONE)
                    {
                        oldfilepath = (string)statement[1];
                    }
                }
                using (var item = db.Prepare("UPDATE Tels SET Number = ?, Group_By = ?, head = ? WHERE Name = ?"))
                {
                    item.Bind(1, num.Text);
                    item.Bind(2, group.Text);
                    if (temp != "")
                    {
                        item.Bind(3, temp);
                    }
                    else
                    {
                        item.Bind(3, oldfilepath);
                    }
                    item.Bind(4, name.Text);
                    item.Step();
                }
                var n = new MessageDialog("信息已经成功保存至通讯录!").ShowAsync();
            }
        }