/// <summary>
 /// SetFavorite
 /// </summary>
 /// <param name="inWord"></param>
 public void SetFavorite(string inWord)
 {
     using (var context = new EnViEntities1())
     {
         // update table EnWord!
         try
         {
             // var a = context.ENWORDs.Single(p => p.EnWord1.Equals(inWord));
             var result = (from a in context.ENWORDs
                           where a.EnWord1.Equals(inWord)
                           select a).FirstOrDefault();
             result.Favote = 1;
             // a.Favote = 1;
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         //insert word to Favorite Table
         try
         {
         }
         catch (Exception e)
         { }
     }
 }
 /// <summary>
 /// XoaFavorite
 /// </summary>
 /// <param name="inWord"></param>
 public void XoaFavorite(string inWord)
 {
     using (var context = new EnViEntities1())
     {
         var result = (from a in context.ENWORDs
                       where a.EnWord1 == inWord &&
                       a.Favote == 1
                       select a).First();
         result.Favote = 0;
         context.SaveChanges();
     }
 }
        /// <summary>
        /// AddRecentWord
        /// </summary>
        /// <param name="inWords"></param>
        public void AddRecentWord(string inWords)
        {
            using (var context = new EnViEntities1())
            {
                Favorite word = new Favorite()
                {
                    ID     = DemRecent() + 1,
                    EnWord = inWords
                };
                context.Favorites.Add(word);
                context.Entry(word).State = EntityState.Added;
                context.SaveChanges();

                //context.ENWORDs.Add(word);
                //context.Entry(word).State = EntityState.Added;


                //context.SaveChanges();
            }
        }
        /// <summary>
        /// InsertNewWords
        /// </summary>
        /// <param name="inID"></param>
        /// <param name="inEnWord"></param>
        /// <param name="inViWord"></param>
        /// <param name="inType"></param>
        /// <param name="inExample"></param>
        public void InsertNewWords(int inID, string inEnWord, string inViWord, string inType, string inExample)
        {
            using (var context = new EnViEntities1())
            {
                var result = (from a in context.ENWORDs
                              where a.EnWord1 == inEnWord
                              select a).ToList();
                if (result.Count() > 0)
                {
                    MessageBox.Show("this word is existed!");
                }
                else
                {
                    {
                        //try
                        {
                            ENWORD word = new ENWORD()
                            {
                                ID      = inID,
                                EnWord1 = inEnWord,
                                EnVi    = inViWord,
                                Type    = inType,
                                Example = inExample,
                                Favote  = 0
                            };


                            context.ENWORDs.Add(word);
                            context.Entry(word).State = EntityState.Added;


                            context.SaveChanges();
                        }
                        //catch (Exception ex)
                        //{

                        //}
                    }
                }
            }
        }