private void buttonSave_Click(object sender, RoutedEventArgs e)
 {
     BdTools.DeleteWord(MyWord.WordId);
     initNewWord();
     if (wordSample != null)
     {
         int id = BdTools.AddNewWords(wordSample);
         wordButton.DataContext = id;
     }
     this.DialogResult = true;
 }
示例#2
0
        private void ClickButtonSave(object sender, RoutedEventArgs e)
        {
            if (GreateNewWord())
            {
                ChengeIconButtonSave(pathGreenTick, ColorIconButtonsave.Green);
                int ind = BdTools.AddNewWords(_wordsSample);
                _wordsSample = new WordSample();

                inerGrid.DataContext = null;
            }


            //imageButtonSave.Source = BitmapFrame.Create(new Uri(@"Picture\\tick_green.png", UriKind.Relative));
        }
示例#3
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            string translate = textboxTranslation.Text;
            IEnumerable <string> translates = translate.Split(new char[] { ',', '.', '\n', '\r', ';' }).Select(n => n.Trim()).Where(n => Regex.IsMatch(n, "\\S"));
            string example = textboxExample.Text;
            IEnumerable <string> examples = example.Split(new char[] { ';' }).Select(n => n.Trim());

            string word          = textboxWord.Text.ToLower().Trim();
            string audio         = textboxAudio.Text.ToLower().Trim();
            string transcription = textboxTranscrition.Text.ToLower().Trim();

            if (word == "" || audio == "" || translate == "" || audioFile == null)
            {
                MessageBox.Show("Заполните все поля!");
                return;
            }

            if (!File.Exists(FIleTools.NameDirectoryAudio + "/" + audioFile.Name))
            {
                FileInfo copy = FIleTools.CopyTo(audioFile, true);
                copy.IsReadOnly = false;
            }

            WordSample _wordsSample = new WordSample();

            _wordsSample.Word             = word;
            _wordsSample.Translate        = new ObservableCollection <string>(translates);
            _wordsSample.DateTimeInsert   = DateTime.Now;
            _wordsSample.DateTimeLastCall = DateTime.Now;
            _wordsSample.State            = (int)State.New;
            _wordsSample.SoundName        = audioFile.Name;
            _wordsSample.Transcription    = transcription;
            _wordsSample.Example          = new ObservableCollection <string>(examples);
            _wordsSample.PartOfSpeach     = "";

            int st = 0;

            try
            {
                st = BdTools.AddNewWords(_wordsSample);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Внимание!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            Clear();
        }