Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            Employee CEO   = new AdministrativeEmployee("Peter", "CEO", 55000);
            Employee VP    = new AdministrativeEmployee("Dobby", "VP", 50000);
            Employee VP2   = new AdministrativeEmployee("George", "VP", 50000);
            Employee prog1 = new NonAdministraticeEmployee("Slavo", "Prog", 20000);
            Employee prog2 = new NonAdministraticeEmployee("Slavo2", "Prog", 20000);
            Employee prog3 = new NonAdministraticeEmployee("Slavo3", "Prog", 20000);
            Employee prog4 = new NonAdministraticeEmployee("Slavo4", "Prog", 200);
            Employee prog5 = new NonAdministraticeEmployee("Slavo5", "Prog", 400);

            employeeList.Add(CEO);
            employeeList.Add(VP);
            employeeList.Add(VP2);
            employeeList.Add(prog1);
            employeeList.Add(prog2);
            employeeList.Add(prog3);
            employeeList.Add(prog4);
            employeeList.Add(prog5);

            VP.addEmployee(prog1);
            VP.addEmployee(prog2);
            VP.addEmployee(prog3);
            VP2.addEmployee(prog4);
            VP2.addEmployee(prog5);

            CEO.addEmployee(VP);
            CEO.addEmployee(VP2);
            Console.Out.Write(CEO);
            trvMenu.Items.Add(CEO);
            this.DataContext = CEO;
        }
Example #2
0
        private void addEmployee(object sender, RoutedEventArgs e)
        {
            Employee supperior = (Employee)this.Owner.DataContext;

            try
            {
                int.Parse(this.salary.Text);
            }
            catch {
                MessageBox.Show("Please Enter numeric salary value");
                return;
            }
            if (supperior.isAdministrative())
            {
                Employee newEmployee = new NonAdministraticeEmployee(this.name.Text, this.role.Text, int.Parse(this.salary.Text));

                supperior.addEmployee(newEmployee);

                Console.WriteLine("Employee has " + supperior.count);
            }
            else
            {
                Employee newSupperior = new NonAdministraticeEmployee(supperior.name, supperior.role, supperior.salary);
                newSupperior.boss = supperior.boss;
                supperior.boss.replaceEmployee(supperior, newSupperior);
                Employee newEmployee = new NonAdministraticeEmployee(this.name.Text, this.role.Text, int.Parse(this.salary.Text));
                newSupperior.addEmployee(newEmployee);

                Console.WriteLine("Employee has " + newSupperior.count);
            }

            this.Close();
        }