IIO91110 .NET Programming Distances tasks

Spring 2008

Pre task Before Kick Start

Goal: learn to create a console application, to use arrays 

Task: In Finnish Lotto there is 39 numbers, and seven (7) numbers are drawn at randomly. Create a console application that draws seven numbers out of 39 and shows numbers in order in the console. Example: 1, 10, 20, 21, 37, 38, 39. (of course same number cannot occur). An end user can select how many drawns will be made, by given it as an start argument, if argument is not given, default is one (1). If more draws is done, every draw will be presented at own line.

Week 6

Goal: learn to handle text- and XML-files in .NET, console programming

Reading data from a text file

Create a console application that reads our customer's names from a text file (for example Brown Charlie, Peanuts ltd). Sort the names to alphabetical order and show them in a console each name in own line. In the file each name is own row, and there can be rows from one to about a almost infinite. Create and name a test text file yourself, put about 10 different names and place the file to c:\temp folder. The file name must be defined in the starting argument of the program. Check in the beginning that the given file exists and it is accessible. Use normal try-catch-finally -exception handling.

Reading data from console and writing to a XML file

Create a console application that reads customers name that an end user gives as long as user want to stop giving names. If the end user gives a valid name (for example "Donald Duck"), put the name to an array. If user gives number zero-length string we will end the reading. If user gives an invalid name (for example only a last name "Duck", the application gives a warning.
After the user has ended giving names, the application writes the names to a XML file named in the starting argument of the program. Create a suitable XML schema for the application. Use normal try-catch-finally -exception handling, no other error handling needed yet.

Week 7

Task 1: WinLotto

Voluntary, do this if you have not done any Windows application with .NET

Goal: Learn to create a Windows application and how to use basic controls

Task: Take your pre-task Lotto and create itLotto.dll -Create a Windows application for Lotto. There is a combobox where to select what Lotto to play, there are textboxes where to give how many drawns will be made and there is a control where to show drawns, of course there are needed buttons where to start playing.

Task 2: Four Windows Forms

Goal: Learn to create a Windows application and how to transfer data between forms.

Usable information: Best Practices for Windows Forms Applications

Task: Build a Windows application with four forms (and one message box). An end-user must log in the application. In the application there is one prebuild user account (username=Charlie password=Brown) [not very good in we think security issues, but in this task we will not pay attention to this very important issue]. When the application is started it automatically shows the Login form. An end user must log on successfully before she or he can go the Main form. If an end user has not user account he/she can create a new user account for him/her. Store created user accounts in XML-file UserAccounts.xml, create suitable XML schema for user accounts.

Week 8

Strange objects in SM-Liiga

Goal: to learn classes, C# oo-programming, ArrayList, Arrays, List, generics

Task: Create GUI presented in picture 1 and create needed functionality for it. Create these three classes: Person, Employee and HockeyPlayer. Inherit classes HockeyPlayer and Employee from Person. Add possibility to store two types of persons: employee and players. The end user will select the type of person, add proper control to UI to select the type.
Needed public properties and methods are presented in picture 1. Create properties as they should create in C# (not like in Java). Use MVC model and create all functionality to a separate class.

The application has following functions:

- when the application is started, the Team combobox is filled with fourteen teams in SM-Liiga ( you can find teams from www.sm-liiga.fi) , use enum list here and think what would be best place to store that data

- when the person type is selected the Texts in buttons are changed accordin the type

- Create Player: check that all fields has proper value and check that there is not all ready player with same name. Then create a Player object, add it the Players –array and add it to the Player listbox. The player is presented in listbox in format ”Lastname Firstname, Team” for example “Straka Joseph, Lukko”.

- listbox shows all time the all players, if any changes are made, the listbox is automatically refreshed.

- If a player’s name is clicked in the listbox then all information of the player is presented in textboxes for editing. Save player button is disabled as long as some changes in any textbox has been made.

- Save player: The application does not create a new player, it saves the information of the player and shows the saved information also in the list boxes if needed. - Delete Player: Delete the selected player from the listbox (and from the array). Button is disabled as long as no player is selected.

- Write Players to …: look the Extra task [this is voluntary, only for those are really interested learn to program with C#]

- End: Ends the application

- statuBar shows all action that the application makes

Additional task: Where would you store the data of the players? What are reasonable possibilities?
Create a function that asks from an end user where to save data, possibilities are: 1) an ASCII text file 2) a xml file 3) Windows registry 4) serialization 5) a database. Use a class myIO to handle that functionality.

Create methods for 1-4, number 5 database is no need to yet (you can do that later).

Add also button “Read Players from…” and create a proper functionality for that.

Picture 1: UI

Picture 2a Classes

Picture 2b Extra Task: saving players’ data to external data stores

Week 9

Using GDI+

Goal: To learn use Graphics GDI+

Background: The Graphics Device Interface (GDI) is one of the three core components or "subsystems", together with the kernel and the user window manager in Windows. GDI is a Microsoft Windows standard for representing graphical objects and transmitting them to output devices such as monitors and printers. With the introduction of Windows XP, GDI was deprecated in favour of its successor, the C++ based GDI+ subsystem. GDI+ is a "next generation" 2D graphics environment, adding advanced features such as anti-aliased 2D graphics, floating point coordinates, alpha blending, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG (which were conspicuously absent in GDI), etc. Use of these features is apparent in Windows XP's user interface, and their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as Flash or SVG. The GDI+ dynamic library can be shipped with an application and used under older versions of Windows. The Microsoft .NET class library provides a managed interface for GDI+ via the System.Drawing namespace. (source: http://en.wikipedia.org/wiki/GDI%2B)

Read from MSDN: Windows Forms Programming / Getting Started with Graphics Programming

Task: Create one of the 80’s classic games: Pong, Pacman, Space Invaders, Tetris or some else with GDI+’ graphics.
Look closer the games in web http://www.80smusiclyrics.com/games.shtml

Those who are born in January or February will program Pong. In March or April born will program Pacman. In May or June born will program Space Invaders. In July or August born will make Tetris. In September, October, November or December  can select any arcade-type game from 80's and program it.

Because it can take quite long time to implement all features of the game, you should concentrate first the main functionality and graphics and make the “nice extra” [so called 'golden' features] in the end.

List first all functionality and features that you can find from the game. Estimate needed coding time for all list items. Estimate also importance of the function and/or feature, from one (must have) to five (obligatory=golden features). If those golden features will take veryyyy loooong time, you can skip them. So do only the main functionality. Send your estimation with your code.

Use basic drawing elements from .NET System.Drawing namespace. If you are not sure, what features to implement and what not, do not hesitate ask, I'm glad to answer your questions

Week 10

Note: You can combine tasks 1 and 2 to same UI if you want to. Please, put information about it to your email, if you will decide to do so.

Task1: Reading data from a database

Goal: to get familiar to read database from a database

Read this first from MSDN: Connecting and Retrieving Data in ADO.NET

Task: Create a simple Windows application where an end user can look data of customers. Data is located in Access database customers in the table person. Create connection to the database with  Microsoft.Jet.4.0 provider. Use a datareader to show all customers in a listbox. When an end-user clicks a customer in the listbox, show all data from selected customer in the form.
Create also a datagridview which is populated with a selected customers; so there is textbox where we can write a part of lastname of our customers.
Put connection strings to the app.config configuration file, so it is for end-users configure the application to use the proper database.

Task2: Multi tier db application for handling data of our customers

Sometimes it is wise to split a db application to different tiers (so called multitier architecture): UI-tier, BL-tier and DB-tier. BL means Business Logic.

Goal: to understand and  learn how to build three tier architecture in .NET

Look this firstData tutorials

Task: Create a Windows application where an end user can view, add, update and delete data of customers. Data is located in Access database customers in the table person. There are three tables in db: person, company and category and two tables for relations. You can create also same database to SQLServer if you want to. See picture.

Create a class that handles Business logic of transfering data from UI to DB. Create methods and properties, plan and design functionality of BL-tier before you start programming. Think where you should create connection and so on. 

Week 11

Task1: Half-way estimation

We are almost in half-way of our course. Estimate and give feedback about the course. Put the following headings to your estimate:
1 What I have learnt
2 What has been easy, what has been difficult, has some parts been tought too quickly
3 What shoud I learn more
4 What do I want to learn more, so what are most interesting subjects
5 Open questions
6 Suggestions, questions, ideas...
7 Brickbats and/or bouquets for the lecturer about...

Task2: Hockey database

Goal: to get more experience how to read/write data from/to database, specially SQL Server

Check this before you start: Data Walkthroughs

Task: We created a little application in the task of the week 8, let's continue it.
You have to create a SQLServer based database application to handle HockeyPlayer data. Look the picture.

Make needed changes/addings to UI. Use the readymade HockeyPlayer-class in the application and  create needed BLHandler and DBHandler classes with attributes and operations. Create two tables to the database, create creating scripts and send them with you email. Create a dbuser named "koodari" (password "pwkoodari") to SQLServer, give him needed permission to tables. 
Put the connection string to the App.Config configuration file.
Add a ListBox-control to the form. Fill the control with team names. If an end-user select a team, player of the selected team are shown in the resultpane.
Add also The Search-button. If an end-user writes some chars to textboxes and push the button, all players how fill the search criteria are shown in the resultpane. If there are texts in many textboxes use boolean operator AND in search, also wildcard is always added automatically to the end of strings. Example: so if an end-user writes "Pel" to the lastname field and ">100000"; all players who lastname are starting with "Pel" and price is more than 100000€ are shown in the resultpane.

Test your application carefully. List all presented requirements and created functions and changes and present is the test made and was it succesful or not.

All justified adds and changes to the task are allowed, please just give explanation why changes were made.

Week 12

Goal: to learn 1) how to write C# scripts and code to ASPX-pages 2) use validation controls

If you not familiar at all with ASP.NET, would be good to check:
Wiki-article, ASP.NET Introduction
or you can start you exploring from here ASP.NET or Quick Start Tutorials.

Two simple calculators with C# AND webforms

Task: Create two simple calculators 1) with C# scripts AND 2) with webforms and a main page.

In a webpage there is two textboxes to where an user can write numbers, name them txtValue1 and txtValue2. There is five buttons: + - * / ^. User can click a button and the application count the right result and shows it in a textbox (name txtResult). There is also a label (name lblResult) where the calculus is presented for example "5x6=30". There is also other label (named lblCount) where is presented how many calculus an end user has made. Use session to store the number of calculus.

In the C# scripts version use only a editor (not Visual Studio, they are some fine editors that recognize nicely different program languages) and create a webpage named as Calculator.aspx. Place a code to the page, not to code behind class

In the webform version use VisualStudio.NET and code behind. Name it as CalculatorCB.aspx.
Use also field validator to validate that content of texboxes is valid before the application counts the result. Add also a button that copies the content from the result textbox to the Windows clipboard. For those who are starters in ASP.NET may be wice to do this version first; but you can decide.

Create also mainpage (named index.aspx), set it start page of your project. Create linkbuttons to both calculator pages with suitable controls.

Try to run pages in different browsers, is there differencies between browsers?

Write analysis from this task. What was new for you, what was easy, difficult, strange, cure. Put also main sources what you use to. Tell also what editor you use and why. Think and present also what else you should know about ASP.NET. In the following task we will learn more about authorization and authentication, Web.Config and using databases.

Extra task:

For those who allready are familiar with ASP.NET basics, could create and use a suitable css-stylesheet for the pages. You can also use MasterPage and learn how to create and use them.

Week 13

Authentication in ASP.NET

Goal: to understand different authentication and authorization methods in ASP.NET

Before the task look this: Authentication and Authorization

Task:

Step 1: Simple authentication for a website  - model "hardcoded"  

Create a simple ASP.NET application where an enduser has to authenticate before he or she can continue. Use Forms-autentication. So there must be four webpages:

  1. a welcome page where everybody can come and there is button where an enduser can start to login.
  2. an login page, where is textboxes for username and password,
    username and password are stored in application level variables,
    username "student" and password "tneduts" is only valid combination to access.
    Count the tries, an enduser can tries tree times, if he/she doen not succeed to authenticate redirect him/her to an errorpage
  3. a secure page for authenticated user,
    the page shows following information: username, System.Environment.UserName, time of login and Unique sessionID
  4. an errorpage; plain html where is said politely that the login was not succesful and an enduser should take contact to the webadmin

Step 2: Authentication for a website - model "database"

Create another website, you can use same pages as in step 1. Make followings additions.

Create a ASP.NET application where an enduser has to authenticate before he or she can continue. An endusers login name, password and hash are stored in database in SQL Server.(look article How To: Use Forms Authentication with SQL Server in ASP.NET 1.1)  Create needed tables and scripts (send them with you email), create needed functionality. Test with different login names.

Step 3: Evaluation

Read the article: How To: Protect Forms Authentication in ASP.NET 2.0

Compare your solutions in step1 and step2 to the content=message of the article . Evaluate what you have done right way and what could be done better, what should be changed, selfevaluate also what you have learn.

Condense also main things that should take care when you want to build secure web site. What are threats, what are possibilities in .NET prepare against risks and threats. Evaluate and condense also what else you should know more and learn about Security in web applications.

Extra task (not compulsory, but very recommended):
Create the final secure website according what you have learn!

Further reading.

Week 14

Database in WebApplication

Goal: to learn how to create database webapplication  with readymade databinded controls

Background: ASP.NET includes many databinded controls. In ASP.NET 2.0 there was introduced some changes and additions to those controls, look What is new in ASP.NET 2.0. Before the task look this: Binding to Databases.

Task: You task is create a Web-application WineCellary, where end users can search, browse wines. Browsing is allowed to everyone. Adding, editing and deleting wine data is allowed only for authorized users. Create a Web site for WineCellary. Create needed pages, functionality, etc. Design UI yourself, create nicelooking and user friendly outlook for pages. I hope that everyone of you will design and build as individual and artistic website as possible, show me what kind of webartist you are, try avoid "standard engineer look" :-)

Use so many different databinded ASP.NET control as possible. Use SQL Server or SQL Server Express, you can use this SQL scripts to generate the database and some test data to tables. In the db creating script could be wise to set/change the location of the db files before running it. Create needed users/logins to your database, use Web.Config to set the connection string to the database.

After you have done you website evaluate your work. Describe main design goals, describe also keypoints of implemantation, list controls that you used. Describe also what you have learned and how well you succeeded. Good luck!

Extra task For those who will get more challenges:

Add pictures (labels of wines) to the database. Make needed changes to UI, that the label of the wine is shown in webpages. There must be also possibility to add pictures to the database via webpages.

Week 15

Configuration files and COM interoperability

Goal: to learn to use xml-based configuration file app.config and get idea how to connect Excel application with COM.

Prerequisites: You have to have Excel application installed to you computer, versions 2000, 2003 or newer are suitable, check your version. If you do not have Excel you can do this task with some else suitable application.

Read these first, about configuration files: .NET Framework Developer's Guide Configuration Files
  about Excel: How to query and display Excel data , How to transfer data to an Excel workbook (or any releated article you find from web)

Task: We need a Windows application that can read data from Excels workbooks and consolidate it to one certain Excel workbook to the worksheet named Result. And after that the application will create a diagram from consolidated data. In a configuration file app.config the application will store the folder from where Excel workbooks will be read and also the folder to where a new workbook with consolidated data will be created, also the name of the new workbook is set in configuration file. Store also suitable heading info of new worksheet and a diagram in the file. So create an application that reads all workbooks from source folder and consolidate data to one worksheet named "Result" and create a chart from data to sheet ResultChart. Download source workbooks and the example from the result workbook here.

Week 16

Select according of your interest Task 1 or Task 2 and do&return that task.
Of course it is allowed to do both tasks :-)

Task 16-1 / Localization of WebSite

Goal: To understand how to localize WebPages

Background: Web Applications can have users from different counties and different culturies, so it suitable to offer webpages with many languages. There are many possibilities how to do that.
Read this article: Globalization and localization demystified in ASP.NET 2.0  Search also at least one other web article about localization and add url your email.

Task: Localize your WineCellary webapplication, it must have two language interface: english and your mother language.

Task 16-2 / Using Windows EventLog

Goal: To understand how to access OS’s features and learn use Windows Event log

Background: Applications can write different information to Windows' event log. You can read Event log with Computer Management - System Tools - Event Viewer.

Look closer: read this page from MSDN: Server-Based Components for .NET Framework Applications Logging Application, Server, and Security Events

Task: Create a Windows application named "EventLogger" that writes information to the Event log. When the application is started it writes Information ID=101 "The EventLogger started 1.1.2007 12:00" where of course you will write current date and time the string. There is a form, where an end-user can write selected events to the Event Log, see the picture below. Also when an end-user ends the application normally the Information ID=102 "The EventLogger stopped 1.1.2007 13:00" is written to the Event Log.

look: System.Diagnostics.EventLog

Additional task (obligatory):

The Windows Forms NotifyIcon component displays icons in the status notification area of the taskbar for processes that run in the background and would not otherwise have user interfaces. An example would be a virus protection program that can be accessed by clicking an icon in the status notification area of the taskbar.

Add button (and functionality) for that an end-user can move the application run in Notify Icon. When an end-user clicks Icon the application comes back.

Week 17

ExPerienCe

Goal: to extend knowledge and knowhow where .NET can be used

Background: .NET covers huge area. You can build robust Windows and  Web software. It offers lot of readymade components, functionality and so on, it has many possibilities. Now it is you turn to explore possibilities of the .NET Framework.

Task:  You task is to innovate something new.
So plan and build a solution of your own with .NET. It can be whatever, it can be something about your hobbies, about your professional interest etc. It can be a mathematical software, it can be a game, it can use Direct X, it can be a study of WPF etc. The main point is that you try to do something new. You can test what are "limits" of the .NET Framework or you can research how something should be done in .NET. The choice is yours.

Before you begin use some time to research what can be done. Try to be as open-minded as possible. This is a good opportunity to learn something new. Remember that you are doing this for yourself...

First think a rough idea what you will do. List what are main goals.

Secondly analyze and write requirements, share them to two categories: must-have and nice-to-have.

Thirdly create a coarse archcitectural design for your solution, it can be quite general. Make also main design and implementation decisions.

Create your solution. Test it.

Finally evaluate how well you achieved goals and what you have learned.

Join all documentation with your return.

Why, what: .NET Framework

Week 18

Using Web Services

Goal: to get idea how to use Web Services in .NET

Background: Web Services and SOA will have (and they allready have) very big influence to business systems now and future. They are generally and widely used in different  enviroments, they are one solution how to connect different systems in heterogeneous environments. They are not used or creatd only .NET, you can use and create them with Java etc. Of course Web Services has one big role also in .NET Framework. Search and study some essential articles before you start to do you week tasks.
Task:
Create a simple Web Services and a test web application for it.
 
So plan and build a Web Services that offers data about NHL players. Get some data from top scorers in NHL in current season and put data to database. Use SQL Server as database. Generate scripts to create tables and data, return also scripts.
Create a Web Service which returns asked data. Create for example two different methods to call. Another one returns list of the names and goals of top scorers, in passing argument the calling procedure sends how many scorers it wants. In another one, calling procedure sends part of name = search criteria, and methods returns all players hows lastname has searched criteria. Create first a simple Windows application where to test this Web Services. And after that create for our end users a simple Web application that uses web services.
 

This is the last week task! Good luck and thanks for everyone.

Back