I need to create a Windows Class Library that will contain the students, lectureres and classrooms. Each class should be able to save the data to a SQL Database containing tables matching ech class. Within the class the following:
a) A person class for basic person information
b) A student class inheriting from person, adding courses and marks properties
c) A lecturer class inheriting from person, adding classroom and courses.
The following information needs to be captured for each of these classes:
Person:
Firstname, Lastname, IDNumber, Telephone, e-mail, birthdate
Student:
studentNumber
courseAverage
Lecturer:
CertificationType
The list of certification types is: None, MCSE, MCSD, MCAD, MCPD.
Please help!!!
Mahesh ChandPosted Jul 18, 2008, 11:10 AM
Ahh .. . misssed that part.
You will have to create a table called Marks and columsn for each subject and probably one Average column. Average you can calculate by adding a database column as a forumula and have a trigger at Insert and Update subject columns.
Yes, you can have an AverageMarks property of Student class that will get and update data from the Average column of the database.
David MakolaPosted Jul 18, 2008, 3:58 AM
But how can one prompt for student marks in C# to caculate the courseAverage? Can I include marks as one of the properties in the Student Class?
Thanks. Much appreciated. I will try these ideas.
Mahesh ChandPosted Jul 17, 2008, 9:36 AM
I am not sure how much you know about OOP and .NET programming but this is how it should be done.
First of all, create a Class Library using Visual Studio. Here is a link if you don't know how:
Creating C# Class Library (DLL) Using Visual Studio .NET
1. Create Objects
In your class library, you need to treat each entity as an object and create a class for it. So you will have following classes:
Since Person class has common attributes for a Student and a Lecturer, this should have following public or protected properties:
Now you need to create a Student and a Lecturer class and inhert them from the Person class. The Student class will have two public properties:
And the Lecturer class will have a public property CertificationType.
Now you can add an enumeration CertificationType with values None, MCSE, MCSD, MCAD, MCPD.
This completes your classes.
2. Create Helper Classes
Now you need to create helper classes. For example, you can have a class called StudentHelper and it will have methods called AddStudent, DeleteStudent, and UpdateStudent. Similarly, you will have methods for Lecturer.
public bool AddStudent(Student std)
{
// Call your database library and pass Student
DBLibrary.AddStudent(Student);
}
3. Database Library
Now you need to create a database helper class that will have generic methods to execute database SPs and queries etc. This library will also have a DBHelper class that will be the communication between your library and database class. For example, this class will have a method called InsertStudent(Student student) and it will extract all properties of the Studnent class and pass them as parameters of a stored procedure in your Database class.
4. UI
Now from your UI, you need to collect all input data from your UI pages, call Business library and create Student object and pass them to your Data library.
I think that summerizes it all.