using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace InterfaceSample
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private Company myCompany = new Company();

        public MainWindow()
        {
            InitializeComponent();

            myCompany.AddEmployee(new Employee("SD1234", "John Chang"));
            myCompany.AddEmployee(new Employee("SE2222", "Mary Wang"));
        }

        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            //TODO: 1.建立新员工加入myCompany对象
            Employee emp = new Employee(txtID.Text, txtName.Text);
            myCompany.AddEmployee(emp);
        }

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            //TODO: 2.将员工从myCompany删除
            bool result = myCompany.RemoveEmployee(txtID.Text);
            if (result)
            {
                MessageBox.Show(txtID.Text + "员工数据删除成功!");
            }
        }

        private void btnShowEmployee_Click(object sender, RoutedEventArgs e)
        {
            //TODO: 3.调用ToString方法显示员工数据
            if (myCompany[txtID.Text] != null)
            {
                MessageBox.Show(myCompany[txtID.Text].ToString());
            }

        }


        private void btnShowAll_Click(object sender, RoutedEventArgs e)
        {
            AllEmpForm allEmpForm = new AllEmpForm();

            //TODO: 7.传入myCompany对象
            allEmpForm.GetEmployees(myCompany);

            allEmpForm.ShowDialog();
        }



    }
}

