Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to create this form. But only managed to create a final outlook of form itself,without any coding.Can someone help solve this?

Implement a class of type Student in C#, the class should be contained within a file Student.cs. The class should conform the following specification:

Property - Example Data -Validation

FirstName -“Basil” -Not blank
SecondName -“Fawlty”- Not blank
Date Of Birth -23/08/1946 -Not blank
Course -“MA Hotel Management” -Not blank
Matriculation Number -12345 -In the range 10000 to 99999
Year Mark- 55 -In range 0 -100

As well as get/set methods associated with properties, you class should have the
following methods:
Method Notes
hasPassed() Should return True if the student has a year mark >= 40 or
false if the marks is <40

toString() Should return a single string containing a summary of the
student details held within the class
e.g.
“12345 Basil Fawlty, 23/08/1946”


The buttons should perform the following functions:
Set: Takes the values contained in the text boxes and updates the Student class
properties.
Clear: Removes the contents of the text boxes (does not change any properties of
the class)
Get: Uses the values of the Student class methods to update the text boxes. The
Student.hasPassed() method should be used to update the pass/fail label. The
Student details summary should be updated by using Student.toString ()
Posted
Updated 4-Oct-12 2:10am
v2
Comments
Mohd. Mukhtar 4-Oct-12 7:23am    
Please elaborate what you want to create.
C123v 4-Oct-12 9:21am    
i want to create a c#form,with a seperate class.cs which should contain the table details
C123v 4-Oct-12 9:17am    
can anyone please help with this exercise?

It's pretty easy:
C#
private string _FirstName;
public string FirstName
   {
   get { return _FirstName; }
   set
      {
      if (string.IsNullOrWhiteSpace(value))
           {
           throw new Exception("FirstName cannot be blank");
           }
      _FirstName = value;
      }
   }
The others are similar to that.
 
Share this answer
 
It means u want server side validation . u write function like that :

C#
Protected string fnValidate()
 {
    string strMsg = string.Empty;
     try
     {
       // For checking textbox is blank or not
         if (textbox1.Text ==string.Empty )
            {
             strMsg ="Enter Name";
              return strMsg;
             }
        return strMsg;
     }
     catch (Exception ex)
     {

         strMsg ="Exception error occured.!";
         return strMsg;
     }
 }

u can try like that for your controls.
suppose u r validating on your button click event then u should call this function on that event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900