feat: pridal jsem team1 a udelal funkce
This commit is contained in:
parent
6f0f11032e
commit
aa2c749855
35
src/team1.cs
Normal file
35
src/team1.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
namespace Team1
|
||||
{
|
||||
class Library
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user