private void AddControlSystemComponentType(NodeView nodeView)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            var dialog = new AddEditControlSystemComponentTypeDialog();
            dialog.Show();

            dialog.Closed += (s1, e1) =>
            {
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    EventHandler<AddControlSystemComponentTypeCompletedEventArgs> addCompleted = null;
                    addCompleted = (s2, eventArgs) =>
                    {
                        var componentType = eventArgs.Result;

                        if (componentType != null)
                        {
                            var child = new NodeView(nodeView)
                            {
                                Id = componentType.Id,
                                Name = dialog.ComponentType.Name,
                                Description = dialog.ComponentType.Description,
                                Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                Type = NodeType.InterlockType,
                                HasChildren = true,
                                SortField = dialog.ComponentType.Ordinal.ToString()
                            };
                            if (nodeView.ChildrenLoaded)
                            {
                                nodeView.Children.Add(child);
                                nodeView.Sort(true);
                            }
                        }
                        cmsWebServiceClient.AddControlSystemComponentTypeCompleted -= addCompleted;
                    };

                    cmsWebServiceClient.AddControlSystemComponentTypeCompleted += addCompleted;
                    cmsWebServiceClient.AddControlSystemComponentTypeAsync(dialog.ComponentType);
                }
            };
        }
        private void EditControlSystemComponentType(NodeView nodeView)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            EventHandler<GetControlSystemComponentTypeCompletedEventArgs> getControlSystemComponentCompleted = null;
            getControlSystemComponentCompleted = (s, eventArgs) =>
            {
                var mc = eventArgs.Result;

                var dialog = new AddEditControlSystemComponentTypeDialog(mc);
                dialog.Show();
                dialog.Closed += (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        EventHandler<AddControlSystemComponentTypeCompletedEventArgs> addCompleted = null;
                        addCompleted = (s2, e2) =>
                        {
                            var controlSystemEquipmentComponentType = e2.Result;
                            nodeView.Name = controlSystemEquipmentComponentType.Name;
                            nodeView.Description = controlSystemEquipmentComponentType.Description;
                            nodeView.SortField = controlSystemEquipmentComponentType.Ordinal.ToString();

                            cmsWebServiceClient.AddControlSystemComponentTypeCompleted -= addCompleted;
                            nodeView.Parent.Sort();
                        };

                        cmsWebServiceClient.AddControlSystemComponentTypeCompleted += addCompleted;
                        cmsWebServiceClient.AddControlSystemComponentTypeAsync(dialog.ComponentType);
                    }
                };
                cmsWebServiceClient.GetControlSystemComponentTypeCompleted -= getControlSystemComponentCompleted;
            };
            cmsWebServiceClient.GetControlSystemComponentTypeCompleted += getControlSystemComponentCompleted;
            cmsWebServiceClient.GetControlSystemComponentTypeAsync(nodeView.Id);
        }