Пример #1
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();
            }
        }