private void OnDataFormEditEnding(object sender, DataFormEditEndingEventArgs e)
 {
     if (e.EditAction == DataFormEditAction.Commit && FormEditOrgInfo.ValidateItem())
     {
         var org = FormEditOrgInfo.CurrentItem as Organization;
         if (org != null)
         {
             orgContext.SaveOrganizationInfo(org, obj =>
             {
                 if (Utility.Utility.CheckInvokeOperation(obj))
                 {
                     if (obj.Value > 0)
                     {
                         CustomMessageBox.Show("组织已成功保存!");
                         pendingOrgList.Remove(org);
                     }
                     else
                     {
                         CustomMessageBox.Show("保存组织失败,请重试!");
                     }
                 }
             }, null);
         }
     }
 }
        private void OnOrgTreeSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (FormEditOrgInfo.Mode == DataFormMode.Edit)
            {
                FormEditOrgInfo.CancelEdit();
                var oldOrg = e.OldValue as Organization;
                if (oldOrg != null && pendingOrgList.Any(o => o.Id == oldOrg.Id))
                {
                    var oldParent = FindParentOrganization(oldOrg);
                    if (oldParent != null && oldParent.Children != null)
                    {
                        oldParent.Children.Remove(oldOrg);
                        pendingOrgList.Remove(oldOrg);
                    }
                }
            }
            var org = e.NewValue as Organization;

            if (org != null)
            {
                btnCreateChild.IsEnabled    = true;
                btnDeleteOrg.IsEnabled      = btnCreateSibling.IsEnabled = !org.ParentId.Equals("1");
                FormEditOrgInfo.CurrentItem = org;
            }
            else
            {
                btnCreateChild.IsEnabled = btnCreateSibling.IsEnabled = btnDeleteOrg.IsEnabled = false;
            }
        }