Пример #1
0
        private void buttonNewSalaried_Click(object sender, EventArgs e)
        {
            //creates a new instance of a salaried employee
            Salaried2 salaried = new Salaried2( );

            salaried.Employees = employees;

            salaried.ShowDialog();
            //saves employee
            employees.Save(employeesFile);
            PopulateListBox( );
        }
Пример #2
0
        //opens the form to edit an employee
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            var selected = employees[listBoxEmployees.SelectedIndex];

            //checks wether employee is a salaried or hourly
            if (selected is SalariedEmployee)
            {
                var dialog = new Salaried2( );
                dialog.Employee = (selected as SalariedEmployee);
                dialog.ShowDialog( );
            }
            else
            {
                var dialog = new Hourly( );
                dialog.Employee = (selected as HourlyEmployee);
                dialog.ShowDialog( );
            }

            employees.Save(employeesFile);
            PopulateListBox( );
        }