Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

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 OrganizationProfile
{
public partial class frmConfirmation : Form
{
public frmConfirmation()
{
InitializeComponent();
}

private void frmConfirmation_Load(object sender, EventArgs e)


{

lblStudentNo.Text = StudentInformationClass.SetStudentNo.ToString();
lblName.Text = StudentInformationClass.SetFullName;
lblProgram.Text = StudentInformationClass.SetProgram;
lblBirthday.Text = StudentInformationClass.SetBirthDay;
lblGender.Text = StudentInformationClass.SetGender;
lblContactNo.Text = StudentInformationClass.SetContactNo.ToString();
lblAge.Text = StudentInformationClass.SetAge.ToString();
}

private void btnSubmit_Click(object sender, EventArgs e)


{

this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

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

namespace OrgProfile
{

internal class StudentInformationClass


{

public static int SetStudentNo = 0;


public static int SetContactNo = 0;
public static int SetAge = 0;
public static string SetProgram = "";
public static string SetGender = "";
public static string SetBirthDay = "";
public static string SetFullName = "";
}
}

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

namespace OrganizationProfile
{
public partial class frmRegistration : Form
{

private string _FullName;


private int _Age;
private long _ContactNo;
private long _StudentNo;

public frmRegistration()
{
InitializeComponent();
}

private void OrganizationProfile_Load(object sender, EventArgs e)


{

string[] ListOfProgram = new string[]{


"BS Information Technology",
"BS Computer Science",
"BS Information Systems",
"BS in Accountancy",
"BS in Hospitality Management",
"BS in Tourism Management"
};

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


{
cbPrograms.Items.Add(ListOfProgram[i].ToString());
}

string[] ListOfGender = new string[]{


"Male",
"Female",
};

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


{
cbGender.Items.Add(ListOfGender[i].ToString());
}
}

public long StudentNumber(string studNum)


{
try
{
_StudentNo = long.Parse(studNum);
return _StudentNo;
}
catch (FormatException fe)
{
MessageBox.Show(fe.Message);
return _StudentNo;
}
}

public long ContactNo(string Contact)


{
long contactNo;
try
{
if (Regex.IsMatch(Contact, @"^[0-9]{10,11}$"))
{
if (long.TryParse(Contact, out contactNo))
{
_ContactNo = contactNo;
}
}

}
catch (FormatException fe)
{
MessageBox.Show("An Exception occurred: " + fe.Message);
}
catch (ArgumentNullException ane)
{
MessageBox.Show("An Exception occurred: " + ane.Message);
}
catch (OverflowException oe)
{
MessageBox.Show("An Exception occurred: " + oe.Message);
}
catch (IndexOutOfRangeException iore)
{
MessageBox.Show("An Exception occurred: " + iore.Message);
}
catch (Exception)
{
}
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 ArgumentNullException();
}
}

catch (FormatException fe)


{
MessageBox.Show("An Exception occurred: " + fe.Message);
}
catch (ArgumentNullException ane)
{
MessageBox.Show("An Exception occurred: " + ane.Message);
}
catch (OverflowException oe)
{
MessageBox.Show("An Exception occurred: " + oe.Message);
}
catch (IndexOutOfRangeException iore)
{
MessageBox.Show("An Exception occurred: " + iore.Message);
}
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 fe)
{
MessageBox.Show("An Exception occurred: " + fe.Message);
}
catch (ArgumentNullException ane)
{
MessageBox.Show("An Exception occurred: " + ane.Message);
}
catch (OverflowException oe)
{
MessageBox.Show("An Exception occurred: " + oe.Message);
}
catch (IndexOutOfRangeException iore)
{
MessageBox.Show("An Exception occurred: " + iore.Message);
}
return _Age;
}

private void btnRegister_Click(object sender, EventArgs e)


{

StudentInformationClass.SetFullName = FullName(txtLastName.Text, txtFirstName.Text,


txtMiddleInitial.Text);
StudentInformationClass.SetStudentNo = (int)StudentNumber(txtStudentNo.Text);
StudentInformationClass.SetProgram = cbPrograms.Text;
StudentInformationClass.SetGender = cbGender.Text;
StudentInformationClass.SetContactNo = (int)ContactNo(txtContactNo.Text);
StudentInformationClass.SetAge = Age(txtAge.Text);
StudentInformationClass.SetBirthDay = datePickerBirthday.Value.ToString("yyyy-MM-dd");

frmConfirmation frm = new frmConfirmation();


if (frm.ShowDialog() == DialogResult.OK)
{

txtAge.Text = "";
txtLastName.Text = "";
txtFirstName.Text = "";
txtMiddleInitial.Text = "";
txtStudentNo.Text = "";
txtContactNo.Text = "";
cbGender.Text = "";
cbPrograms.Text = "";
}
}
}
}

You might also like