public void SetMangaInfoElement(MangaInfo info) { if (info == null) return; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (SQLiteCommand insertCommand = new SQLiteCommand(connection)) { insertCommand.CommandText = "INSERT INTO MANGA_INFO " + "(MANGA_ID, MANGA_TITLE, MANGA_DESCRIPTION, MANGA_PUBLICATION_DATE, MANGA_PUBLICATION_STATUS, " + "MANGA_PUBLISHER_ID, MANGA_COVER) VALUES (?, ?, ?, ?, ?, ?, ?)"; insertCommand.Parameters.AddWithValue(null, info.Id); insertCommand.Parameters.AddWithValue(null, info.Title); insertCommand.Parameters.AddWithValue(null, info.Description); insertCommand.Parameters.AddWithValue(null, info.PublicationDate); insertCommand.Parameters.AddWithValue(null, info.PublicationStatus); insertCommand.Parameters.AddWithValue(null, info.PublisherId); insertCommand.Parameters.AddWithValue(null, Convert.FromBase64String(info.Image)); insertCommand.ExecuteNonQuery(); } connection.Close(); } }
private void GetMangaDataForSpecificManga(int mangaId) { _mangaInfo = DatabaseWrapper.Instance.GetMangaInfoElement(mangaId); mangaTitleTextBox.Text = _mangaInfo.Title; if (_mangaInfo.PublicationDate != null) dateOfPublishDateTimePicker.Value = (DateTime) _mangaInfo.PublicationDate; mangaStatusComboBox.Text = _mangaInfo.PublicationStatus; mangaDescriptionTextBox.Text = _mangaInfo.Description; mangaCoverPictureBox.Image = DatabaseWrapper.Instance.GetMangaCover(mangaId); authorsNameListBox.DataSource = DatabaseWrapper.Instance.GetAuthorsList(mangaId); genreNameListBox.DataSource = DatabaseWrapper.Instance.GetGenresList(mangaId); mangaPublisherNameTextBox.Text = DatabaseWrapper.Instance.GetPublisherName(mangaId); authorsComboBox.DataSource = DatabaseWrapper.Instance.GetNonSelectedAuthors(mangaId); genreNameComboBox.DataSource = DatabaseWrapper.Instance.GetNonSelectedGenresList(mangaId); }
public MangaInfo GetMangaInfoElement(int mangaId) { MangaInfo returnData = new MangaInfo(); if (mangaId <= 0) { return returnData; } try { using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { connection.Open(); using (SQLiteCommand selectCommand = new SQLiteCommand(connection)) { selectCommand.CommandText = "SELECT MANGA_TITLE, MANGA_DESCRIPTION, MANGA_PUBLICATION_DATE, MANGA_PUBLICATION_STATUS " + "FROM MANGA_INFO " + "WHERE MANGA_ID = ?"; selectCommand.Parameters.AddWithValue(null, mangaId); SQLiteDataReader reader = selectCommand.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); returnData.Title = dataTable.Rows[0][0].ToString(); returnData.Description = dataTable.Rows[0][1].ToString(); returnData.PublicationDate = DateTime.Parse(dataTable.Rows[0][2].ToString()); returnData.PublicationStatus = dataTable.Rows[0][3].ToString(); reader.Close(); } connection.Close(); } } catch (Exception ex) { ErrorHandler.LogError(ex); } return returnData; }