Esempio n. 1
0
        private void Save_Click(object sender, EventArgs e)
        {
            expl_textbox.Text = expl_textbox.Text.Trim();
            word_textBox.Text = word_textBox.Text.Trim();

            if (expl_textbox.Text == "" && word_textBox.Text == "")
            {
                return;
            }

            int index = MainForm.AllWords.FindIndex(word => word.Value == word_textBox.Text);

            if (index == -1 || (index != -1 && MainForm.AllWords[index].Value == CurrentWord.Value))
            {
                Word NewWord = new Word();
                NewWord.Value     = word_textBox.Text;
                NewWord.Translate = expl_textbox.Text;
                NewWord.Weight    = GetCurrentWeight();
                NewWord.DateAdded = CurrentWord.DateAdded;

                DB_Access.DeleteWord(CurrentWord);
                MainForm.AllWords.Remove(CurrentWord);
                DB_Access.SaveWord(NewWord);

                Close();
            }
        }
Esempio n. 2
0
        void UpdateWordList()
        {
            AllWords = DB_Access.LoadWords();

            foreach (Word word in AllWords)
            {
                word.DT_DateAdded = Convert.ToDateTime(word.DateAdded);
            }

            if (AllWords.Count == 0)
            {
                PagesCount = 1;
                return;
            }
            else
            {
                double val = (double)AllWords.Count / (double)PageLength;
                val        = Math.Ceiling(val);
                PagesCount = (int)val;

                AllWords = AllWords.OrderBy(item => item.Weight).ToList();
                if (AllWords.Count != 0)
                {
                    MinWeight = AllWords[0].Weight;
                    MaxWeight = AllWords[AllWords.Count - 1].Weight;
                }
            }

            SortWords();
        }
Esempio n. 3
0
        private void Add_Click(object sender, EventArgs e)
        {
            if (word_textBox.Text == "")
            {
                word_textBox.Focus();
                return;
            }
            if (expl_textbox.Text == "")
            {
                expl_textbox.Focus();
                return;
            }

            if (done.Text == "Done")
            {
                CurrentWord.Value     = word_textBox.Text;
                CurrentWord.Translate = expl_textbox.Text;
                CurrentWord.Weight    = CurrentWeight;
                CurrentWord.DateAdded = DateTime.Now.ToString();
            }
            else
            {
                CurrentWord.Value     = word_textBox.Text;
                CurrentWord.Translate = expl_textbox.Text;
                CurrentWord.Weight    = CurrentWeight + 1;
            }

            DB_Access.SaveWord(CurrentWord);

            Close();
        }
Esempio n. 4
0
        private void Delete_Click(object sender, EventArgs e)
        {
            expl_textbox.Text = expl_textbox.Text.Trim();
            word_textBox.Text = word_textBox.Text.Trim();

            if (expl_textbox.Text == "" && word_textBox.Text == "")
            {
                return;
            }

            if (word_textBox.Text == CurrentWord.Value)
            {
                DB_Access.DeleteWord(CurrentWord);
                MainForm.AllWords.Remove(CurrentWord);

                Close();
            }
        }
Esempio n. 5
0
 private void Clear_DB_Click(object sender, EventArgs e)
 {
     DB_Access.ClearTable(AllWords);
     UpdateWordList();
     UpdatePage();
 }