Exemple #1
0
        private void AddVocabularyCommandHandler()
        {
            int    weekOfYear  = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            string defaultName = string.Format("{0:MMdd}.Vocabulary{0:yyyy}.{1:0#}", DateTime.Now, weekOfYear);

            var strVocabularyName = InputBox.ShowDialog("Please, insert name of new Vocabulary", defaultName);

            if (string.IsNullOrEmpty(strVocabularyName))
            {
                return;
            }

            if (Vocabularies.Any(v => string.Compare(v.FileName, strVocabularyName, true) == 0))
            {
                MessageBox.ShowDialog(string.Format("Vocabulary '{0}' already exists.", strVocabularyName), "Warning");
            }
            else
            {
                Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService)
                {
                    FileName = strVocabularyName
                });
                dataService.Set(new VocabularyRecord[0], strVocabularyName);
            }

            AddVocabularyCommand.RaiseCanExecuteChanged();
        }
Exemple #2
0
        private void Refresh()
        {
            var files = dataService.GetFiles();

            Vocabularies.Clear();
            foreach (var file in files)
            {
                Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService)
                {
                    FileName = file
                });
            }
            ;
        }
Exemple #3
0
        private void CreateVocabularyList(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            if (Vocabularies.Any(v => string.Compare(v.FileName, fileName, true) == 0))
            {
                return;
            }

            var vocabularyList = new VocabularyListViewModel(dataService, dialogService)
            {
                FileName = fileName
            };

            Vocabularies.Add(vocabularyList);
            vocabularyList.SaveCommand.Execute(null);
        }
Exemple #4
0
        protected static bool InsertVocabulary(VocModel Voc)
        {
            string query = string.Format(InsertSQL + "'{1}', '{2}', {3}, '{4}', '{5}', {6})",
                                         Model.Voc.ToDesc(),
                                         Voc.Text, Voc.Answer,
                                         Null, Null, Voc.Importance, Voc.IsActive);

            if (!SendQuery(query))
            {
                return(false);
            }

            var inserted = GetLast(Model.Voc.ToDesc());

            Vocabularies.Add(inserted.Tables[0].AsEnumerable().
                             Select(GetDatarowVocabulary()).First().ToVM());

            return(true);
        }