示例#1
0
        private void OnSave(object obj)
        {
            Employee        employee = null;
            EmployeeFactory factory  = new EmployeeFactory();

            switch (Position)
            {
            case "Employee":
                employee = factory.GeneralEmployee(Name, Rate, EmoploymentDate);
                break;

            case "Manager":
                employee = factory.Manager(Name, Rate, EmoploymentDate);
                break;

            case "Salesman":
                employee = factory.Salesman(Name, Rate, EmoploymentDate);
                break;

            default:
                throw new ArgumentException("Unhandled position of employee");
            }

            if (employee != null)
            {
                db.AddEmployee(employee);
            }

            OnCancel(obj);
        }