37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
namespace Team1
|
|
{
|
|
class Library
|
|
{
|
|
private SqliteConnection connection;
|
|
public Library(SqliteConnection connection)
|
|
{
|
|
this.connection = connection;
|
|
}
|
|
public static void AddAuthor(string name, string lastName, DateTime dateOfBirth, SqliteConnection connection)
|
|
{
|
|
string sql = @"INSERT INTO Authors (Name, Surname, DateOfBirth) VALUES (@name, @lastName, @dateOfBirth)";
|
|
using (var com = new SqliteCommand(sql, connection))
|
|
{
|
|
com.Parameters.AddWithValue("@name", name);
|
|
com.Parameters.AddWithValue("@lastName", lastName);
|
|
com.Parameters.AddWithValue("@dateOfBirth", dateOfBirth);
|
|
com.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public static void AddPublisher(string name, string state, SqliteConnection connection)
|
|
{
|
|
string sql = @"INSERT INTO Publishers (Name, State) VALUES (@name, @state)";
|
|
using (var com = new SqliteCommand(sql, connection))
|
|
{
|
|
com.Parameters.AddWithValue("@name", name);
|
|
com.Parameters.AddWithValue("@state", state);
|
|
com.ExecuteNonQuery();
|
|
}
|
|
}
|
|
}
|
|
}
|