private void AddExistingMechanicalComponentProperty(NodeView nodeView)
        {
            int mechanicalEquipmentComponentTypeId = nodeView.Id;
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetMechanicalEquipmentComponentTypeCompleted +=
                (s, e) =>
                {
                    AddEditExistingMechanicalComponentPropertyDialog dialog = new AddEditExistingMechanicalComponentPropertyDialog(e.Result);
                    dialog.Show();

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

                                if (pcpt != null)
                                {
                                    NodeView child = new NodeView(nodeView)
                                    {
                                        Id = pcpt.Id,
                                        Name = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentProperty.Name,
                                        Description = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentProperty.Description,
                                        Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                        Type = NodeType.MechanicalComponentTypeProperty,
                                        HasChildren = false,
                                        SortField = dialog.MechanicalEquipmentComponentTypeProperty.Ordinal.ToString()
                                    };
                                    if (nodeView.ChildrenLoaded)
                                    {
                                        nodeView.Children.Add(child);
                                        nodeView.Sort();
                                    }
                                }

                                cmsWebServiceClient.AddMechanicalComponentTypePropertyCompleted -= addCompleted;

                            };

                            cmsWebServiceClient.AddMechanicalComponentTypePropertyCompleted += addCompleted;

                            MechanicalEquipmentComponentTypeProperty mechanicalEquipmentComponentTypeProperty = new MechanicalEquipmentComponentTypeProperty
                            {
                                MechanicalEquipmentComponentTypeId = mechanicalEquipmentComponentTypeId,
                                MechanicalEquipmentPropertyId = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentPropertyId,
                                Ordinal = dialog.MechanicalEquipmentComponentTypeProperty.Ordinal
                            };

                            cmsWebServiceClient.AddMechanicalComponentTypePropertyAsync(mechanicalEquipmentComponentTypeProperty);
                        }
                    };
                };

            cmsWebServiceClient.GetMechanicalEquipmentComponentTypeAsync(mechanicalEquipmentComponentTypeId);
        }
        private void EditMechanicalComponentTypeProperty(NodeView nodeView)
        {
            AddEditExistingMechanicalComponentPropertyDialog dialog = new AddEditExistingMechanicalComponentPropertyDialog(nodeView.Id);

            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                        {
                            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                            EventHandler<AddUpdateMechanicalComponentTypePropertyCompletedEventArgs> addCompleted = null;
                            addCompleted = (s2, eventArgs) =>
                            {
                                MechanicalEquipmentComponentTypeProperty pcpt = eventArgs.Result;

                                if (pcpt != null)
                                {
                                    nodeView.Name = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentProperty.Name;
                                    nodeView.Description = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentProperty.Description;
                                    nodeView.SortField = dialog.MechanicalEquipmentComponentTypeProperty.Ordinal.ToString();
                                }

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

                            cmsWebServiceClient.AddUpdateMechanicalComponentTypePropertyCompleted += addCompleted;

                            MechanicalEquipmentComponentTypeProperty mechanicalEquipmentComponentTypeProperty = new MechanicalEquipmentComponentTypeProperty
                            {
                                MechanicalEquipmentComponentTypeId = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentComponentTypeId,
                                MechanicalEquipmentPropertyId = dialog.MechanicalEquipmentComponentTypeProperty.MechanicalEquipmentPropertyId,
                                Ordinal = dialog.MechanicalEquipmentComponentTypeProperty.Ordinal
                            };

                            cmsWebServiceClient.AddUpdateMechanicalComponentTypePropertyAsync(mechanicalEquipmentComponentTypeProperty);
                        }
                    }
                };
            dialog.Show();
        }