Beispiel #1
0
        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");
            }
        }
Beispiel #2
0
        private void GetOfficersData(Officers sub)
        {
            //Get title
            sub.title = txtTitle.Text;

            //Get user name
            sub.uname = txtUser.Text;

            //Get password
            sub.pass = txtPass.Text;
        }