예제 #1
0
 public void SetPublisherInfoElement(PublisherInfo info)
 {
     if (info == null)
         return;
     using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
     {
         connection.Open();
         using (SQLiteCommand insertCommand = new SQLiteCommand(connection))
         {
             insertCommand.CommandText =
                 "INSERT INTO PUBLISHER_INFO (PUBLISHER_ID, PUBLISHER_NAME, " +
                 "PUBLISHER_COUNTRY, PUBLISHER_WEBSITE, PUBLISHER_NOTE) values (?, ?, ?, ?, ?)";
             insertCommand.Parameters.AddWithValue(null, info.Id);
             insertCommand.Parameters.AddWithValue(null, info.Name);
             insertCommand.Parameters.AddWithValue(null, info.Country);
             insertCommand.Parameters.AddWithValue(null, info.Website);
             insertCommand.Parameters.AddWithValue(null, info.Note);
             insertCommand.ExecuteNonQuery();
         }
         connection.Close();
     }
 }
예제 #2
0
 private void GetPublisherDataForSpecificPublisher(int publisherId)
 {
     _publisherInfo = DatabaseWrapper.Instance.GetPublisherInfoElement(publisherId);
     publisherNameTextBox.Text = _publisherInfo.Name;
     publisherCountryTextBox.Text = _publisherInfo.Country;
     publisherNoteTextBox.Text = _publisherInfo.Note;
     publisherWebsiteTextBox.Text = _publisherInfo.Website;
 }
예제 #3
0
        public PublisherInfo GetPublisherInfoElement(int publisherId)
        {
            PublisherInfo returnData = new PublisherInfo();
            if (publisherId <= 0)
            {
                return returnData;
            }
            try
            {
                using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                {
                    connection.Open();
                    using (SQLiteCommand selectCommand = new SQLiteCommand(connection))
                    {
                        selectCommand.CommandText =
                            "SELECT PUBLISHER_NAME, PUBLISHER_COUNTRY, PUBLISHER_WEBSITE, PUBLISHER_NOTE " +
                            "FROM PUBLISHER_INFO " +
                            "WHERE PUBLISHER_ID = ?";

                        selectCommand.Parameters.AddWithValue(null, publisherId);
                        SQLiteDataReader reader = selectCommand.ExecuteReader();
                        DataTable dataTable = new DataTable();
                        dataTable.Load(reader);
                        returnData.Name = dataTable.Rows[0][0].ToString();
                        returnData.Country = dataTable.Rows[0][1].ToString();
                        returnData.Website = dataTable.Rows[0][2].ToString();
                        returnData.Note = dataTable.Rows[0][3].ToString();
                        reader.Close();
                    }
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.LogError(ex);
            }
            return returnData;
        }