private void btn_SaveBook_Click(object sender, EventArgs e) { List <Film> parse = FileOPs.ParseFilmXmlToList(form_Catalog.filmFileName); List <string> filePath = new List <string>(); int count = 1; foreach (string file in fileNames) { try { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Films" + txtbox_Producer.Text + @"\" + txtbox_Title.Text); string extension = Path.GetExtension(file); string path = string.Format(@".\Pics\Films\" + txtbox_Producer.Text + @"\" + txtbox_Title.Text + @"\"); string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++); string fullPath = Path.Combine(path, tempFileName + extension); FileInfo newFile = new FileInfo(file).CopyTo(fullPath, true); filePath.Add(fullPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } } Film filmToEdit = new Film(int.Parse(txtbox_ID.Text), txtbox_Title.Text, txtbox_Genre.Text, txtbox_Producer.Text, txtbox_Actors.Text, int.Parse(txtbox_Length.Text), txtbox_Country.Text, DateTime.Parse(txtbox_Premiere.Text), cmbbox_MPAA.Text, txtbox_CriticsRating.Text, int.Parse(txtbox_Grosses.Text), txtbox_Notes.Text, filePath); try { FileOPs.EditXmlFile(filmToEdit, form_Catalog.filmFileName); txtbox_ID.Clear(); txtbox_Title.Clear(); txtbox_Genre.Clear(); txtbox_Producer.Clear(); txtbox_Actors.Clear(); txtbox_Length.Clear(); txtbox_Country.Clear(); txtbox_Premiere.Clear(); cmbbox_MPAA.SelectedIndex = -1; txtbox_CriticsRating.Clear(); txtbox_Grosses.Clear(); txtbox_Notes.Clear(); flp_FileSelector.Controls.Clear(); tssl_StatusFilmEdit.Text = "Success!"; Close(); } catch (FileNotFoundException ex) { MessageBox.Show(ex.Message); tssl_StatusFilmEdit.Text = "Error!"; } }
private void btn_SaveBook_Click(object sender, EventArgs e) { List <Book> parse = FileOPs.ParseBookXmlToList(form_Catalog.bookFileName); List <string> filePath = new List <string>(); int count = 1; foreach (string file in fileNames) { try { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"Pics\Books" + txtbox_Author.Text + @"\" + txtbox_Title.Text); string extension = Path.GetExtension(file); string path = string.Format(@".\Pics\Books\" + txtbox_Author.Text + @"\" + txtbox_Title.Text + @"\"); string tempFileName = string.Format("{0}-{1}", txtbox_Title.Text, count++); string fullPath = Path.Combine(path, tempFileName + extension); FileInfo newFile = new FileInfo(file).CopyTo(fullPath, true); filePath.Add(fullPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } } Book bookToEdit = new Book(int.Parse(txtbox_ID.Text), txtbox_MajorSeries.Text, txtbox_Author.Text, txtbox_Title.Text, txtbox_Series.Text, int.Parse(txtbox_NumberInSeries.Text), txtbox_Genre.Text, int.Parse(txtbox_PagesCount.Text), txtbox_Publisher.Text, int.Parse(txtbox_PrintYear.Text), txtbox_PrintCity.Text, long.Parse(txtbox_ISBN.Text), txtbox_Translator.Text, txtbox_Artist.Text, txtbox_Notes.Text, filePath); try { FileOPs.EditXmlFile(bookToEdit, form_Catalog.bookFileName); txtbox_ID.Clear(); txtbox_MajorSeries.Clear(); txtbox_Author.Clear(); txtbox_Title.Clear(); txtbox_Series.Clear(); txtbox_NumberInSeries.Clear(); txtbox_Genre.Clear(); txtbox_PagesCount.Clear(); txtbox_Publisher.Clear(); txtbox_PrintYear.Clear(); txtbox_PrintCity.Clear(); txtbox_ISBN.Clear(); txtbox_Translator.Clear(); txtbox_Artist.Clear(); txtbox_Notes.Clear(); flp_FileSelector.Controls.Clear(); tssl_StatusBookEdit.Text = "Success!"; Close(); } catch (FileNotFoundException ex) { MessageBox.Show(ex.Message); tssl_StatusBookEdit.Text = "Error!"; } }