0% found this document useful (0 votes)
53 views4 pages

05 Laboratory Exercise Event Driven Lagyaliii

Uploaded by

jayrlagyal
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)
53 views4 pages

05 Laboratory Exercise Event Driven Lagyaliii

Uploaded by

jayrlagyal
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/ 4

LagyalIII, Brahim S.

BSIT 503

private void btnRegister_Click(object sender, EventArgs e)

string studentnumber = lblStudentNumber.Text;

string lastname = lblLastName.Text;

string firstname = lblFirstName.Text;

string middleinitial = lblMiddleInitial.Text;

string program = cbProgram.Text;

string gender = cbGender.Text;

string age = Age.Text;

string datepicker = DatePicker.Value.ToString("MM/dd/yyyy");

string contactnumber = lblContactNumber.Text;

string[] alloutput = {

"Student No.: " + studentnumber,

"Full Name: " + lastname + ", " + firstname + " " + middleinitial + ".",
"Program: " + program,

"Gender: " + gender,

"Age: " + age,

"Birthday: " + datepicker,

"Contact No.: " + contactnumber

};

string docPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

string filePath = Path.Combine(docPath, $"{studentnumber}.txt");

try

using (StreamWriter outputFile = new StreamWriter(filePath))

foreach (string line in alloutput)

outputFile.WriteLine(line);

MessageBox.Show("Registration data saved successfully!", "Success", MessageBoxButtons.OK,


MessageBoxIcon.Information);

catch (Exception ex)

MessageBox.Show("An error occurred while saving the data: " + ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);

}
private void frmRegistration_Load(object sender, EventArgs e)

You might also like