0% found this document useful (0 votes)
108 views

03 Laboratory Exercise 1

The document contains source code for a student registration form application in C#. It includes code for registration, validation of input fields, and displaying a confirmation form on submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

03 Laboratory Exercise 1

The document contains source code for a student registration form application in C#. It includes code for registration, validation of input fields, and displaying a confirmation form on submission.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

This study source was downloaded by 100000874682361 from CourseHero.

com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
REGISTRATION SOURCE CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using StudentRegistrationForm;

namespace StudentRegistrationForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string _FullName;
private int _Age;
private long _ContactNo;
private long _StudentNo;

public long StudentNumber(string studNum)

This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
{
try
{
_StudentNo = long.Parse(studNum);
}

catch(FormatExceptions)
{

MessageBox.Show("You Have Entered Wrong Non-Numeric


Character");
textBox1.Text = " ";
}

return _StudentNo;

public long ContactNo(string Contact)


{
try
{
if (Regex.IsMatch(Contact, @"^[0-9]{10,11}$"))
{
_ContactNo = long.Parse(Contact);
}
else
{
throw new OverflowException();
}
}
catch (OverflowException)
{
MessageBox.Show("Number has Exceeded or inadequate");
}

return _ContactNo;
}

public string FullName(string LastName, string FirstName, string


MiddleInitial)
{
try
{
if (Regex.IsMatch(LastName, @"^[a-zA-Z]+$") ||
Regex.IsMatch(FirstName, @"^[a-zA-Z]+$") || Regex.IsMatch(MiddleInitial, @"^[a-
zA-Z]+$"))
{
_FullName = LastName + ", " + FirstName + ", " +
MiddleInitial;
}
else
{
throw new ArgumentException();
throw new FormatException();
}
}

This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
catch (ArgumentException)
{
MessageBox.Show("Please Fill up Lastname, Firstname and
Middle Inittial");
}

return _FullName;
}

public int Age(string age)


{
try
{
if (Regex.IsMatch(age, @"^[0-9]{1,3}$"))
{
_Age = Int32.Parse(age);
}
else
{
throw new FormatException();

}
}
catch (FormatException)
{
MessageBox.Show("You have Entered Wrong Non Nurmeric
Character.");
}

return _Age;
}
private void Form1_Load(object sender, EventArgs e)
{
string[] ListofProgram = new string[]
{
"BS Information Technology",
"BS Computer Science",
"BS Information System",
"BS in Accountancy",
"BS in Hospitality Management",
"BS in Tourism Management"

};

for( int i = 0; i < 6; i++)


{
comboBox1.Items.Add(ListofProgram[i].ToString());

}
string[] GenderVariation = new string[]
{
"Male",
"Female"
};
for (int i = 0; i < 2; i++)
{
comboBox2.Items.Add(GenderVariation[i].ToString());

This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
}

private void button1_Click(object sender, EventArgs e)


{
StudentInformationClass.SetFullname = FullName(textBox5.Text,
textBox6.Text, textBox2.Text);
StudentInformationClass.SetStudentNo =
StudentNumber(textBox1.Text);
StudentInformationClass.SetProgram = comboBox1.Text;
StudentInformationClass.SetGender = comboBox2.Text;
StudentInformationClass.SetContactNo =
ContactNo(textBox8.Text);
StudentInformationClass.SetAge = Age(textBox3.Text);
StudentInformationClass.SetBirthday =
dateTimePicker1.Value.ToString("yyy-MM-dd");

Confirmation fr2 = new Confirmation();


fr2.ShowDialog();

}
}
}

CONFIRMATION SOURCECODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudentRegistrationForm
{
public partial class Confirmation : Form
{
public Confirmation()
{
InitializeComponent();
}

private void Confirmation_Load(object sender, EventArgs e)


{
label8.Text = StudentInformationClass.SetStudentNo.ToString();
label9.Text = StudentInformationClass.SetFullname;
label10.Text = StudentInformationClass.SetProgram;

This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
label12.Text = StudentInformationClass.SetBirthday;
label13.Text = StudentInformationClass.SetGender;
label14.Text = StudentInformationClass.SetContactNo.ToString();
label11.Text = StudentInformationClass.SetAge.ToString();

private void label8_Click(object sender, EventArgs e)


{

}
}
}

STUDENTREGISTRATIONFORM SOURCE CODE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentRegistrationForm
{
class StudentInformationClass
{
public static long SetStudentNo = 0;
public static long SetContactNo = 0;
public static int SetAge = 0;
public static string SetProgram = " ";
public static string SetGender = " ";
public static string SetBirthday = " ";
public static string SetFullname = " ";

}
}

This study source was downloaded by 100000874682361 from CourseHero.com on 04-28-2024 03:42:22 GMT -05:00

https://www.coursehero.com/file/121841242/03-Laboratory-Exercise-1docx/
Powered by TCPDF (www.tcpdf.org)

You might also like