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 GetOfficersData(Officers sub) { //Get title sub.title = txtTitle.Text; //Get user name sub.uname = txtUser.Text; //Get password sub.pass = txtPass.Text; }