예제 #1
0
        private ClassAuthor GetAuthorFromDB(string inID)
        {
            DataTable   dt = DbReturnDataTable($"SELECT * FROM Forfatter WHERE id = {inID}");
            ClassAuthor CA = new ClassAuthor();

            foreach (DataRow row in dt.Rows)
            {
                CA.id     = row["id"].ToString();
                CA.author = row["forfatter"].ToString();
            }

            return(CA);
        }
예제 #2
0
        public ObservableCollection <ClassAuthor> GetAuthors()
        {
            ObservableCollection <ClassAuthor> cAuthors = new ObservableCollection <ClassAuthor>();
            string    sqlQuery  = "SELECT * FROM Forfatter";
            DataTable dataTable = DbReturnDataTable(sqlQuery);

            foreach (DataRow row in dataTable.Rows)
            {
                ClassAuthor authors = new ClassAuthor();
                authors.author = row["forfatter"].ToString();
                authors.id     = row["id"].ToString();
                cAuthors.Add(authors);
            }

            return(cAuthors);
        }
예제 #3
0
 public void UpdateAuthorInDB(ClassAuthor inAuthor)
 {
     ExecuteNonQuery($"UPDATE Forfatter SET forfatter = '{inAuthor.author}' WHERE id = {inAuthor.id}");
 }
예제 #4
0
 public void InsertAuthorIntoDB(ClassAuthor inAuthor)
 {
     ExecuteNonQuery($"INSERT INTO Forfatter (forfatter) VALUES('{inAuthor.author}')");
 }