Inheritance: IAuditEntity
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string word = null;
            if (e.RowIndex >= 0)
            {
                word= dataGridView1.Rows[e.RowIndex].Cells["Word"].Value.ToString();
            }
            if (e.ColumnIndex == 0)
            {

                dbOperator.AddIgnoreWord(word);
                dataGridView1.Rows.RemoveAt(e.RowIndex);
            }
            if (e.ColumnIndex == 1) //已经记住该单词
            {
                string sentence = dataGridView1.Rows[e.RowIndex].Cells["SubtitleSentence"].Value.ToString();
                //var subtitleName = Path.GetFileNameWithoutExtension(SubtitleFileName);
                var userVo = dbOperator.GetUserWord(word);
                if (userVo == null)
                {
                    userVo = new UserVocabulary()
                    {

                        Word = word,
                        Sentence = sentence,
                        Source = this.SubtitleFileName,
                        CreateTime = DateTime.Now

                    };
                }
                userVo.KnownStatus = KnownStatus.Known;
                userVo.UpdateTime = DateTime.Now;
                dbOperator.SaveUserVocabulary(userVo);
                dataGridView1.Rows.RemoveAt(e.RowIndex);
            }
            else if (e.ColumnIndex == 2) //IsStar
            {
               var star = dataGridView1.Rows[e.RowIndex].Cells["IsStar"].Value;
                if (star == "☆")
                {
                    dataGridView1.Rows[e.RowIndex].Cells[2].Value = "★";
                    dbOperator.UpdateStarFlag(word, true);
                }
                else if (star == "★")
                {
                    dataGridView1.Rows[e.RowIndex].Cells[2].Value = "☆";
                    dbOperator.UpdateStarFlag(word, false);
                }
            }
        }
        public VUserWord(UserVocabulary v)
        {
            Word = v.Word;
            CreateTime = v.CreateTime;
            UpdateTime = v.UpdateTime;
            var m = Global.DictionaryService.GetChineseMeanInDict(v.Word);
            if (m != null)
            {
                Meaning = m.GetAllMeans();
                PhoneticSymbols = m.PhoneticSymbols;
            }
            Source = v.Source;

            Sentence = v.Sentence;
            IsNewWord = v.KnownStatus == KnownStatus.Unknown ? "是" : "否";
            IsStar = v.IsStar ? "★" : "☆";
        }
        public void SaveUserVocabulary(IList<Vocabulary> userWords, string source)
        {
            var allUserVocabulary = GetAllUserVocabulary();

            BeginTran();
            foreach (var word in userWords)
            {
                var dbWord = allUserVocabulary.SingleOrDefault(v => v.Word == word.Word);
                if (dbWord != null)
                {
                    dbWord.KnownStatus = word.IsKnown ? KnownStatus.Known : KnownStatus.Unknown;
                    dbWord.Source = source;
                    SaveUserVocabulary(dbWord);
                }
                else
                {

                    UserVocabulary uv = new UserVocabulary() { Word = word.Word, Source = source, KnownStatus = word.IsKnown ? KnownStatus.Known : KnownStatus.Unknown };
                    allUserVocabulary.Add(uv);
                    SaveUserVocabulary(uv);
                }
            }

            Commit();
        }
 public void SaveUserVocabulary(UserVocabulary userVocabulary)
 {
     context.UserVocabulary.AddOrUpdate(userVocabulary);
     context.SaveChanges();
 }
        //public void SaveUserKnownWords(IList<string> words)
        //{
        //    BeginTran();
        //    foreach (var w in words)
        //    {
        //        Subtitle_KnownWord word = new Subtitle_KnownWord() {AddTime = DateTime.Now, Word = w};
        //        context.KnownWords.Add(word);
        //        UserVocabulary vocabulary = context.UserVocabulary.SingleOrDefault(v => v.Word == w);
        //        if (vocabulary == null)
        //        {
        //            vocabulary = new UserVocabulary();
        //        }
        //        vocabulary.Word = w;
        //        vocabulary.Source = "Subtitle";
        //        vocabulary.KnownStatus = KnownStatus.Known;
        //        context.UserVocabulary.AddOrUpdate(vocabulary);
        //        context.SaveChanges();
        //    }
        //    Commit();
        //}
        //public UserVocabulary GetUserVocabulary(string word)
        //{
        //    return FindFirst<UserVocabulary>(v => v.Word == word);
        //}
        public void SaveSubtitleNewWords(IList<SubtitleWord> newWords, string subtitleName)
        {
            BeginTran();
            RunSql("delete from Subtitle_NewWord where SubtitleName='" +subtitleName.Replace("'", "''") + "'");

            foreach (var userNewWord in newWords.Distinct())
            {
                Subtitle_NewWord entity = new Subtitle_NewWord()
                                              {
                                                  Word = userNewWord.Word,
                                                  SubtitleName = subtitleName,
                                                  Sentence = userNewWord.SubtitleSentence,
                                                  WordMean = userNewWord.SelectMean,
                                                  CreateTime = DateTime.Now,
                                                  KnownStatus = userNewWord.IsNewWord?KnownStatus.Unknown : KnownStatus.Known
                                              };
                context.NewWords.Add(entity);

                UserVocabulary vocabulary = context.UserVocabulary.SingleOrDefault(v => v.Word == userNewWord.Word);
                if (vocabulary == null)
                {
                    vocabulary = new UserVocabulary();
                    vocabulary.CreateTime = DateTime.Now;
                }
                else
                {
                   vocabulary.IsStar = userNewWord.IsStar;
                }
                vocabulary.Word = userNewWord.Word;
                vocabulary.Source = subtitleName;
                vocabulary.Sentence = userNewWord.SubtitleSentence;
                vocabulary.KnownStatus = userNewWord.IsNewWord ? KnownStatus.Unknown : KnownStatus.Known;
                vocabulary.UpdateTime = DateTime.Now;
                context.UserVocabulary.AddOrUpdate(vocabulary);
                context.SaveChanges();
            }
            Commit();
        }