C# og Databaser

Her er en samling af mine afleveringer fra 1.semester med databaser og C#
på webudvikling uddannelsen lavet i Visual Studio 2019
Alle afleveringer er på engelsk, da undervisningen foregik herpå

4

4. Aflevering

Den sidste opgave med C#, på første semester, skulle vi vise at vi kunne koble en database på og vise alle CRUD funktionerne med SQL

Opgavebeskrivelse

Make a database for Las Vegas Magical Stage.
Make a corresponding web site.

Make a table Magician with id, name, artist name and password.
This table must also hold a manager and one or more secretaries.

Make a table Act with title, performing magician, short description, duration and a link to a picture.

Make a table Program with id, act and sequence number.


The site must have a public welcome page showing the program (with pictures) plus total duration of the performance.
The site must have a simple login and logout page for all users.

If a magician logs in the magician should be able to CRUD (create, read, update, delete) own acts.
Try to use a trigger to add a default picture link to acts with no picture data.
Make it possible to upload pictures to a folder in the project.

If a secretary logs in the secretary should be allowed to CRUD (create, read, update, delete) the persons.

If a manager logs in the manager should be able to select acts and their sequence for the program.

3

3. Aflevering

I vores 3. aflevering skulle vi, blandt andet, vise at vi havde forstået at bruge en abstract class med to subclasses, hvor den ene af dem skulle indeholde en collection af strings. Dernæst skulle vi lage en login site.

Opgave beskrivelse

Make a Person class.
You decide which information is needed, but id, name and password must be present.
The Person class must be abstract.

Make two subclasses Magician and Staff which inherit Person.
You decide which information is needed, but staff needs a salary.
Magicians need a collection of favourite tricks and must have an AddFavouriteTrick method.
It must be possible to create magicians with or without a single favourite trick.

Make web pages where magicians and staff can enlist by entering the necessary data.
Persons must be created as objects and placed in an ArrayList.
Make a simple login page where existing magicians and staff can login and logout using your own code.
Make pages for displaying and updating magicians and staff including adding magicians favourite tricks.
A person must be able to change own data only.
Magicians who have logged in must be able to see a list of all magicians.
Staff who have logged in must be able to see a list of all persons.

2

2. Aflevering

I vores 2. aflevering skulle vi vise at vi kunne oprette to classes med hver deres constuctor, property og methods. Og derudover bruge en Arrayliste til at indeholde de forskellige objekter i den ene class

Opgavebeskrivelse

Make an Agent class.
You decide which information is needed, but id, real name and code name must be present.
The Agent must also have a list of 2 spoken languages, and a method which can set or update the 2 languages.
The Agent class must have a ToString method.


Make an Encryption class.
The class should have a method that receive a string and a key for a Caesar encryption.
The method should return the encrypted string. (See en.wikipedia.org “Caesar Cipher”)


Make a single webpage with two tasks : Creation of agents, and handling agent data and encryption.
The creation part should place the agents an ArrayList. (Note : In this hand in the ArrayList must be static (belong to a class), else it is lost after a PostBack).
The handling part should have TextBox’s for a real name, two languages, a text and a key.
If the real name does not exist the page should do nothing. Else the page should change the agents languages, display all data for the agent and display the coded message.

1

1. Aflevering

Database opgave hvor vi først skulle vise at vi havde forstået at oprette tabeller og lave connections imellem dem med brug af primary og foreign keys. Bagefter skulle vi vise at vi kunne skrive SQL statements for at få resultatet af forskellige givne opgaver.

Opgavebeskrivelse

Make a table Pet with id, type (e.g. bird), breed (e.g. dove) and price.
Make a table Petshop with id, name and address.
Make the database so a certain kind of pet can be in many petshops and a petshop can have many different pets.
A petshop should be able to have many of a certain kind of pet.
Set up the necessary relations.
Populate the tables with typical data.

Make a SQL query to show the pets of a given type.
Make a SQL query to show where a given kind of pet can be found.

And try to :
Make a SQL query to show the number of different pets at a given petshop.
Make a SQL query to show the number of pets at a given petshop.