public void btnSubmit_Click(object sender, EventArgs e) { //Create employee profile Employee newEmployee = new Employee(); Officers newOfficer = new Officers(); //Get data from Employee class GetEmployeeData(newEmployee); //Get data from Officers class GetOfficersData(newOfficer); //Assign fields to global variable allEmployee = newEmployee.fname + " " + newEmployee.lname + " " + newEmployee.city + " " + newEmployee.state + " " + newEmployee.email + " " + newOfficer.title + " " + newOfficer.uname + " " + newOfficer.pass; try { //Open Streamwriter with amend boolean true System.IO.StreamWriter people = new System.IO.StreamWriter("people.txt", true); //Write values to file people.WriteLine(allEmployee); //Give notice that ifo has been written MessageBox.Show("Data has been written to file"); //Close file people.Close(); } catch { MessageBox.Show("Could not write to file"); } }
private void GetEmployeeData(Employee emp) { //Get first name emp.fname = txtFirstName.Text; //Get last name emp.lname = txtLastName.Text; //Get city emp.city = txtCity.Text; //Get state emp.state = txtState.Text; //Get email emp.email = txtEmail.Text; }