Exemple #1
0
 public void RefreshGrid(string content = "", string level = "")
 {
     try
     {
         IEnumerable <EnglishSentences> iq = target.ToList();
         if (!string.IsNullOrEmpty(content))
         {
             iq = iq.Where(o => o.Content.Contains(txtContentSearch.Text));
         }
         if (!string.IsNullOrEmpty(level))
         {
             int iLevel = 0;
             try
             {
                 iLevel = int.Parse(level);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Can not parse " + level + ",make sure your level is numberic.");
             }
             iq = iq.Where(o => o.Level == iLevel);
         }
         if (iq != null)
         {
             actual = iq.ToList();
             dataGridView1.DataSource = actual;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void btNext_Click(object sender, EventArgs e)
        {
            var Sentences = target.ToList();

            if (Sentences != null)
            {
                var rand     = new Random();
                var sentence = Sentences.ElementAt(rand.Next(Sentences.Count()));

                if (sentence != null)
                {
                    txtSentence.Text = sentence.Content;
                }
                else
                {
                    MessageBox.Show("Nothing in DB,please using Add to put some data in db");
                }
            }
            else
            {
                MessageBox.Show("Nothing in DB,please using DBHelperGUI to put some data in db");
            }
        }
        public void Refresh()
        {
            var actual = target.ToList();

            dataGridView1.DataSource = actual;
        }