Few things:
1)
In this part of code:
private void btnDisplay_Click(object sender, EventArgs e)
{
s1.displayDetails(s1);
}
you're calling
displayDetails(s1)
method for Students class, but inside this procedure you're never use the properties of s1 (StudentId, StudentName and so on...).
2)
Have a look at this part of code:
public partial class Form1 : Form
{
public int StudentID
{
get { return Convert.ToInt16(txtStudentID.Text); }
set { txtStudentID.Text = value.ToString(); }
}
and this one:
class Students
{
public int StudentID;
If you want to use
StudentID
as a property of class
Students
, the declaration of
StudentID
should be inside of
Students
class, not in the
Form1
. So, move these properties in to right module:
private int iStudentID;
public int StudentID(int value)
{
get { return iStudentID); }
set { iStudentID = value; }
}
and then:
Students s1 = new Students();
private void btnSubmit_Click(object sender, EventArgs e)
{
s1.StudentID = Convert.ToInt16(txtStudentID.Text);
s1.StudentFirstName = txtStudentFirstName.Text;
s1.StudentLastName = txtStudentLastName.Text;
s1.StudentCourseCode = txtStudentCourseCode.Text;
s1.CurrentYear = txtCurrentYear.Text;
}
3)
Finally, the
displayDetails
function should looks like:
public void displayDetails()
{
MessageBox.Show("Your ID is: " + iStudentID.ToString() + "\nYour First Name is: " + sStudentFirstName + "\nYour Last Name is: " + sStudentLastName + "\nYour Course Code is: " + sStudentCourseCode + "\nYour year is: " + iCurrentYear.ToString());
}
where
sStudentLastName
variable (and other) is a private member of Students class.
Sorry for my bad language...
I hope you'll understand what i mean.