コード例 #1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var id = Convert.ToInt32(((Button)sender).CommandParameter);

            if (id > 0)
            {
                var item = Daftar.Where(O => O.Id == id).FirstOrDefault();
                if (item != null)
                {
                    Daftar.Remove(item);
                    DaftarView.Refresh();
                }
            }
        }
コード例 #2
0
        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            var textBox = (TextBox)sender;

            if (textBox.Text != string.Empty && CategorySelected != null)
            {
                var text = textBox.Text.Trim().ToUpper();
                using (var db = new OcphDbContext())
                {
                    var newKata = new Kata {
                        KategoriId = CategorySelected.Id.Value, Nilai = text
                    };
                    newKata.Id = db.Words.InsertAndGetLastID(newKata);
                    if (newKata.Id > 0)
                    {
                        Daftar.Add(newKata);
                    }
                }

                textBox.Text = string.Empty;
                DaftarView.Refresh();
            }
        }