0% found this document useful (0 votes)
17 views3 pages

05LAB2ADANOEVENT

The document contains code for a student record management system using C# and Windows Forms. It includes forms for student registration (FrmRegistration), viewing student records (FrmStudentRecord), and creating/naming output files (FrmFileName, Form1). The registration form collects student details and writes them to a text file in the Documents folder. The student record form allows viewing this file and switches between forms. The file name form sets the output file name before it is created.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

05LAB2ADANOEVENT

The document contains code for a student record management system using C# and Windows Forms. It includes forms for student registration (FrmRegistration), viewing student records (FrmStudentRecord), and creating/naming output files (FrmFileName, Form1). The registration form collects student details and writes them to a text file in the Documents folder. The student record form allows viewing this file and switches between forms. The file name form sets the output file name before it is created.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Ralph Jasper Adano Even-Driven Programming

FrmStudentRecords
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 FrmLab1
{
public partial class FrmStudentRecord : Form
{
public FrmStudentRecord()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
FrmRegistration registration = new FrmRegistration();
registration.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
string docPath2 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
MessageBox.Show(docPath2, "Directory", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("'Successfully Uploaded!'", "Message", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}

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

namespace FrmLab1
{
public partial class FrmRegistration : Form
{
public FrmRegistration()
{
Ralph Jasper Adano Even-Driven Programming

InitializeComponent();
}
private void FrmRegistration_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string getBirthday = dateTimePicker1.Text;
string getProgram = comboBox1.Text;
string getFirstName = textBox4.Text;
string getMiddleName = textBox5.Text;
string getGender = comboBox2.Text;
string getStudentNo = textBox1.Text;
string getLastName = textBox2.Text;
string getAge = textBox3.Text;
string getContactNo = textBox6.Text;
string SetFileName = string.Concat(getStudentNo, ".txt");

string docPath2 = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);


StreamWriter outputFile = new StreamWriter(Path.Combine(docPath2, SetFileName));
string[] info = {"Student No.: " + getStudentNo, "Fullname: " + getFirstName + " " + getMiddleName + ". " +
getLastName,
"Program: " + getProgram, "Age: " + getAge,
"Birthday: " + getBirthday, "Contact No.: " + getContactNo};

Console.WriteLine(getStudentNo);
foreach (string i in info)
outputFile.WriteLine(i);
outputFile.Close();
Close();
}
public string[] getStudentNo { get; set; }

private void button2_Click(object sender, EventArgs e)


{
this.Hide();
FrmStudentRecord student_Record = new FrmStudentRecord();
student_Record.ShowDialog();
}
}
}

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

namespace FrmLab1
{
public partial class Form1 : Form
Ralph Jasper Adano Even-Driven Programming

{
public Form1()
{
InitializeComponent();
}

private void btnCreate_Click(object sender, EventArgs e)


{
FrmFileName fileName = new FrmFileName();
fileName.ShowDialog();
string getInput = txtInput.Text;
string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, FrmFileName.SetFileName)))
{
outputFile.WriteLine(getInput);
Console.WriteLine(getInput);
}
}
}
}

FrmFileName
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 FrmLab1
{
public partial class FrmFileName : Form
{
public FrmFileName()
{
InitializeComponent();
}
private void btnOkay_Click(object sender, EventArgs e)
{
SetFileName = txtFileName.Text + ".txt";
Close();
FrmRegistration reg = new FrmRegistration();
reg.ShowDialog();
}
public static string SetFileName { get; set; }
}
}

You might also like