private void DepartmentsTree_SelectionChanged(object sender, EventArgs _)
        {
            TreeNode node = DepartmentsTree.SelectedNode;

            Employee[] emps = ((node != null ? (Employee[])Tree.GetTreeNodeData(node) : null) ?? new Employee[0]);
            EmployeesGrid.BeginRebuild();
            foreach (Employee e in emps)
            {
                EmployeesGrid.AddItem(GetGridTexts(e), e);
            }
            EmployeesGrid.AddItem(GetGridTexts(null), null);
            EmployeesGrid.EndRebuild();
        }
        private void EditEmployeeOKButton_Click(jQueryEvent evt)
        {
            string firstName = FirstNameInput.Value.Trim(),
                   lastName  = LastNameInput.Value.Trim(),
                   title     = TitleInput.Value.Trim(),
                   email     = EmailInput.Value.Trim();

            if (firstName == "")
            {
                Window.Alert("You must enter a first name.");
                FirstNameInput.Focus();
                return;
            }
            if (lastName == "")
            {
                Window.Alert("You must enter a last name.");
                LastNameInput.Focus();
                return;
            }
            if (title == "")
            {
                title = null;
            }
            if (email == "")
            {
                Window.Alert("You must enter an email address.");
                EmailInput.Focus();
                return;
            }

            bool     add = (EmployeesGrid.GetData(EmployeesGrid.SelectedRowIndex) == null);
            Employee emp = new Employee(firstName, lastName, title, email);

            EmployeesGrid.UpdateItem(EmployeesGrid.SelectedRowIndex, GetGridTexts(emp), emp);
            if (add)
            {
                EmployeesGrid.AddItem(GetGridTexts(null), null);
            }

            Tree.SetTreeNodeData(DepartmentsTree.SelectedNode, GetCurrentEmployees());

            EditEmployeeDialog.Close();
        }